1
1
mirror of https://github.com/wez/wezterm.git synced 2024-08-17 02:00:25 +03:00

Fix compilation

This commit is contained in:
V 2024-04-08 03:26:58 +02:00 committed by Wez Furlong
parent 7c77f407fa
commit fdc805bb2e
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387
10 changed files with 131 additions and 71 deletions

View File

@ -4,7 +4,7 @@ use std::os::fd::AsRawFd;
use std::rc::Rc;
use std::sync::atomic::AtomicUsize;
use anyhow::{bail, Context};
use anyhow::{anyhow, bail, Context};
use mio::unix::SourceFd;
use mio::{Events, Interest, Poll, Token};
use wayland_client::backend::WaylandError;
@ -58,7 +58,11 @@ impl WaylandConnection {
let mut events = Events::with_capacity(8);
let wl_fd = {
let read_guard = self.event_queue.borrow().prepare_read()?;
let read_guard = self
.event_queue
.borrow()
.prepare_read()
.ok_or_else(|| anyhow!(""))?;
read_guard.connection_fd().as_raw_fd()
};
@ -100,7 +104,7 @@ impl WaylandConnection {
continue;
}
if let Ok(guard) = event_q.prepare_read() {
if let Some(guard) = event_q.prepare_read() {
if let Err(err) = guard.read() {
log::trace!("Event Q error: {:?}", err);
if let WaylandError::Protocol(perr) = err {

View File

@ -56,7 +56,7 @@ impl CopyAndPaste {
.as_ref()
.ok_or_else(|| anyhow!("no primary selection offer"))?;
let pipe = Pipe::new().map_err(Error::msg)?;
offer.receive(TEXT_MIME_TYPE.to_string(), pipe.write.as_raw_fd());
offer.receive(TEXT_MIME_TYPE.to_string(), todo!());
Ok(pipe.read)
}
None => {
@ -65,7 +65,7 @@ impl CopyAndPaste {
.as_ref()
.ok_or_else(|| anyhow!("no data offer"))?;
let pipe = Pipe::new().map_err(Error::msg)?;
offer.receive(TEXT_MIME_TYPE.to_string(), pipe.write.as_raw_fd());
offer.receive(TEXT_MIME_TYPE.to_string(), todo!());
Ok(pipe.read)
}
}

View File

@ -0,0 +1,33 @@
use smithay_client_toolkit::globals::GlobalData;
use wayland_client::Dispatch;
use wayland_protocols::wp::cursor_shape::v1::client::wp_cursor_shape_device_v1::WpCursorShapeDeviceV1;
use wayland_protocols::wp::cursor_shape::v1::client::wp_cursor_shape_manager_v1::WpCursorShapeManagerV1;
use super::state::WaylandState;
pub(super) struct CursorShapeManagerState {}
impl Dispatch<WpCursorShapeManagerV1, GlobalData, WaylandState> for CursorShapeManagerState {
fn event(
state: &mut WaylandState,
proxy: &WpCursorShapeManagerV1,
event: <WpCursorShapeManagerV1 as wayland_client::Proxy>::Event,
data: &GlobalData,
conn: &wayland_client::Connection,
qhandle: &wayland_client::QueueHandle<WaylandState>,
) {
todo!()
}
}
impl Dispatch<WpCursorShapeDeviceV1, GlobalData, WaylandState> for CursorShapeManagerState {
fn event(
state: &mut WaylandState,
proxy: &WpCursorShapeDeviceV1,
event: <WpCursorShapeDeviceV1 as wayland_client::Proxy>::Event,
data: &GlobalData,
conn: &wayland_client::Connection,
qhandle: &wayland_client::QueueHandle<WaylandState>,
) {
todo!()
}
}

View File

@ -1,12 +1,13 @@
use std::os::fd::{FromRawFd, IntoRawFd};
use filedescriptor::FileDescriptor;
use smithay_client_toolkit::data_device_manager::data_device::{
DataDevice, DataDeviceDataExt, DataDeviceHandler,
use smithay_client_toolkit::data_device_manager::data_device::DataDeviceHandler;
use smithay_client_toolkit::data_device_manager::data_offer::{
DataOfferHandler, DragOffer, SelectionOffer,
};
use smithay_client_toolkit::data_device_manager::data_offer::DataOfferHandler;
use smithay_client_toolkit::data_device_manager::data_source::DataSourceHandler;
use smithay_client_toolkit::data_device_manager::WritePipe;
use smithay_client_toolkit::reexports::client::protocol::wl_data_device::WlDataDevice;
use wayland_client::protocol::wl_data_device_manager::DndAction;
use wayland_client::Proxy;
@ -26,22 +27,20 @@ impl DataDeviceHandler for WaylandState {
&mut self,
_conn: &wayland_client::Connection,
_qh: &wayland_client::QueueHandle<Self>,
data_device: DataDevice,
data_device: &WlDataDevice,
) {
let mut drag_offer = data_device.drag_offer().unwrap();
log::trace!(
"Data offer entered: {:?}, mime_types: {:?}",
drag_offer,
data_device.drag_mime_types()
);
let mut drag_offer = data_device.data::<DragOffer>().unwrap();
drag_offer.with_mime_types(|mime_types| {
log::trace!(
"Data offer entered: {:?}, mime_types: {:?}",
drag_offer,
mime_types
);
if let Some(m) = data_device
.drag_mime_types()
.iter()
.find(|s| *s == URI_MIME_TYPE)
{
drag_offer.accept_mime_type(*self.last_serial.borrow(), Some(m.clone()));
}
if let Some(mime) = mime_types.iter().find(|s| *s == URI_MIME_TYPE) {
drag_offer.accept_mime_type(*self.last_serial.borrow(), Some(mime.clone()));
}
});
drag_offer.set_actions(DndAction::None | DndAction::Copy, DndAction::None);
@ -64,7 +63,7 @@ impl DataDeviceHandler for WaylandState {
&mut self,
_conn: &wayland_client::Connection,
_qh: &wayland_client::QueueHandle<Self>,
_data_device: DataDevice,
_data_device: &WlDataDevice,
) {
let pointer = self.pointer.as_mut().unwrap();
let mut pstate = pointer
@ -83,7 +82,7 @@ impl DataDeviceHandler for WaylandState {
&mut self,
_conn: &wayland_client::Connection,
_qh: &wayland_client::QueueHandle<Self>,
_data_device: DataDevice,
_data_device: &WlDataDevice,
) {
}
@ -91,14 +90,13 @@ impl DataDeviceHandler for WaylandState {
&mut self,
_conn: &wayland_client::Connection,
_qh: &wayland_client::QueueHandle<Self>,
data_device: DataDevice,
data_device: &WlDataDevice,
) {
let mime_types = data_device.selection_mime_types();
if !mime_types.iter().any(|s| s == TEXT_MIME_TYPE) {
return;
}
if let Some(offer) = data_device.data::<SelectionOffer>() {
if !offer.with_mime_types(|mime_types| mime_types.iter().any(|s| s == TEXT_MIME_TYPE)) {
return;
}
if let Some(offer) = data_device.selection_offer() {
if let Some(copy_and_paste) = self.resolve_copy_and_paste() {
copy_and_paste
.lock()
@ -112,7 +110,7 @@ impl DataDeviceHandler for WaylandState {
&mut self,
_conn: &wayland_client::Connection,
_qh: &wayland_client::QueueHandle<Self>,
_data_device: DataDevice,
_data_device: &WlDataDevice,
) {
let pointer = self.pointer.as_mut().unwrap();
let mut pstate = pointer
@ -135,21 +133,21 @@ impl DataDeviceHandler for WaylandState {
}
impl DataOfferHandler for WaylandState {
fn offer(
&mut self,
_conn: &wayland_client::Connection,
_qh: &wayland_client::QueueHandle<Self>,
offer: &mut smithay_client_toolkit::data_device_manager::data_offer::DataDeviceOffer,
mime_type: String,
) {
log::trace!("Received offer with mime type: {mime_type}");
if mime_type == TEXT_MIME_TYPE {
offer.accept_mime_type(*self.last_serial.borrow(), Some(mime_type));
} else {
// Refuse other mime types
offer.accept_mime_type(*self.last_serial.borrow(), None);
}
}
// fn offer(
// &mut self,
// _conn: &wayland_client::Connection,
// _qh: &wayland_client::QueueHandle<Self>,
// offer: &mut smithay_client_toolkit::data_device_manager::data_offer::DataDeviceOffer,
// mime_type: String,
// ) {
// log::trace!("Received offer with mime type: {mime_type}");
// if mime_type == TEXT_MIME_TYPE {
// offer.accept_mime_type(*self.last_serial.borrow(), Some(mime_type));
// } else {
// // Refuse other mime types
// offer.accept_mime_type(*self.last_serial.borrow(), None);
// }
// }
// Ignore drag and drop events
fn source_actions(

View File

@ -2,7 +2,6 @@ use crate::wayland::read_pipe_with_timeout;
use crate::ConnectionOps;
use filedescriptor::{FileDescriptor, Pipe};
use smithay_client_toolkit as toolkit;
use std::os::unix::io::AsRawFd;
use std::path::PathBuf;
use toolkit::reexports::client::protocol::wl_data_offer::WlDataOffer;
use url::Url;
@ -33,7 +32,7 @@ impl DragAndDrop {
let pipe = Pipe::new()
.map_err(|err| log::error!("Unable to create pipe: {:#}", err))
.ok()?;
offer.receive(URI_MIME_TYPE.to_string(), pipe.write.as_raw_fd());
offer.receive(URI_MIME_TYPE.to_string(), todo!());
let read = pipe.read;
offer.finish();
Some(SurfaceAndPipe { window_id, read })

View File

@ -8,6 +8,7 @@ pub use self::window::*;
pub use connection::*;
pub use output::*;
mod copy_and_paste;
mod cursor_shape;
mod drag_and_drop;
// mod frame;
mod data_device;

View File

@ -2,10 +2,10 @@ use std::cell::RefCell;
use std::sync::{Arc, Mutex};
use smithay_client_toolkit::compositor::SurfaceData;
use smithay_client_toolkit::reexports::csd_frame::{DecorationsFrame, FrameClick};
use smithay_client_toolkit::seat::pointer::{
PointerData, PointerDataExt, PointerEvent, PointerEventKind, PointerHandler,
};
use smithay_client_toolkit::shell::xdg::frame::{DecorationsFrame, FrameClick};
use wayland_client::backend::ObjectId;
use wayland_client::protocol::wl_pointer::{ButtonState, WlPointer};
use wayland_client::protocol::wl_seat::WlSeat;
@ -220,13 +220,17 @@ impl WaylandState {
match evt.kind {
PointerEventKind::Enter { .. } => {
inner.window_frame.click_point_moved(&evt.surface, x, y);
inner
.window_frame
.click_point_moved(todo!(), &evt.surface.id(), x, y);
}
PointerEventKind::Leave { .. } => {
inner.window_frame.click_point_left();
}
PointerEventKind::Motion { .. } => {
inner.window_frame.click_point_moved(&evt.surface, x, y);
inner
.window_frame
.click_point_moved(todo!(), &evt.surface.id(), x, y);
}
PointerEventKind::Press { button, serial, .. }
| PointerEventKind::Release { button, serial, .. } => {
@ -240,7 +244,7 @@ impl WaylandState {
0x111 => FrameClick::Alternate,
_ => continue,
};
if let Some(action) = inner.window_frame.on_click(click, pressed) {
if let Some(action) = inner.window_frame.on_click(todo!(), click, pressed) {
inner.frame_action(pointer, serial, action);
}
}

View File

@ -6,6 +6,7 @@ use wayland_client::{Connection, QueueHandle};
use crate::wayland::copy_and_paste::PrimarySelectionManagerData;
use crate::wayland::keyboard::KeyboardData;
use crate::wayland::pointer::PointerUserData;
use crate::wayland::SurfaceUserData;
use super::state::WaylandState;
@ -39,9 +40,11 @@ impl SeatHandler for WaylandState {
log::trace!("Setting pointer capability");
let pointer = self
.seat
.get_pointer_with_theme_and_data(
.get_pointer_with_theme_and_data::<WaylandState, SurfaceUserData, PointerUserData>(
qh,
&seat,
todo!(),
todo!(),
ThemeSpec::System,
PointerUserData::new(seat.clone()),
)

View File

@ -3,7 +3,7 @@ use std::collections::HashMap;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use smithay_client_toolkit::compositor::CompositorState;
use smithay_client_toolkit::compositor::{CompositorState, SurfaceData};
use smithay_client_toolkit::data_device_manager::data_device::DataDevice;
use smithay_client_toolkit::data_device_manager::data_source::CopyPasteSource;
use smithay_client_toolkit::data_device_manager::DataDeviceManagerState;
@ -20,15 +20,16 @@ use smithay_client_toolkit::shm::slot::SlotPool;
use smithay_client_toolkit::shm::{Shm, ShmHandler};
use smithay_client_toolkit::subcompositor::SubcompositorState;
use smithay_client_toolkit::{
delegate_compositor, delegate_data_device, delegate_data_device_manager, delegate_data_offer, delegate_data_source, delegate_output, delegate_registry, delegate_seat, delegate_shm, delegate_subcompositor, delegate_xdg_shell, delegate_xdg_window, registry_handlers
delegate_compositor, delegate_data_device, delegate_output, delegate_registry, delegate_seat, delegate_shm, delegate_subcompositor, delegate_xdg_shell, delegate_xdg_window, registry_handlers
};
use wayland_client::backend::ObjectId;
use wayland_client::globals::GlobalList;
use wayland_client::protocol::wl_keyboard::WlKeyboard;
use wayland_client::protocol::wl_output::WlOutput;
use wayland_client::protocol::wl_pointer::WlPointer;
use wayland_client::protocol::wl_surface::WlSurface;
use wayland_client::{delegate_dispatch, Connection, QueueHandle};
use wayland_protocols::wp::cursor_shape::v1::client::wp_cursor_shape_device_v1::WpCursorShapeDeviceV1;
use wayland_protocols::wp::cursor_shape::v1::client::wp_cursor_shape_manager_v1::WpCursorShapeManagerV1;
use wayland_protocols::wp::primary_selection::zv1::client::zwp_primary_selection_device_manager_v1::ZwpPrimarySelectionDeviceManagerV1;
use wayland_protocols::wp::primary_selection::zv1::client::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1;
use wayland_protocols::wp::primary_selection::zv1::client::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1;
@ -39,6 +40,7 @@ use wayland_protocols::wp::text_input::zv3::client::zwp_text_input_v3::ZwpTextIn
use crate::x11::KeyboardWithFallback;
use super::copy_and_paste::{PrimarySelectionManagerData, PrimarySelectionManagerState};
use super::cursor_shape::CursorShapeManagerState;
use super::inputhandler::{TextInputData, TextInputState};
use super::pointer::{PendingMouse, PointerUserData};
use super::{OutputManagerData, OutputManagerState, SurfaceUserData, WaylandWindowInner};
@ -154,23 +156,21 @@ impl OutputHandler for WaylandState {
}
}
// Undocumented in sctk 0.17: This is required to use have user data with a surface
// Will be just delegate_compositor!(WaylandState, surface: [SurfaceData, SurfaceUserData]) in 0.18
delegate_dispatch!(WaylandState: [ WlSurface: SurfaceUserData] => CompositorState);
// Will be just this in 0.18:
delegate_compositor!(WaylandState, surface: [SurfaceData, SurfaceUserData]);
// delegate_dispatch!(WaylandState: [ WlSurface: SurfaceUserData] => CompositorState);
delegate_registry!(WaylandState);
delegate_shm!(WaylandState);
delegate_output!(WaylandState);
delegate_compositor!(WaylandState);
// delegate_compositor!(WaylandState);
delegate_subcompositor!(WaylandState);
delegate_seat!(WaylandState);
delegate_data_device_manager!(WaylandState);
delegate_data_device!(WaylandState);
delegate_data_source!(WaylandState);
delegate_data_offer!(WaylandState);
// Updating to 0.18 should have this be able to work
// delegate_pointer!(WaylandState, pointer: [PointerUserData]);
@ -179,6 +179,9 @@ delegate_dispatch!(WaylandState: [WlPointer: PointerUserData] => SeatState);
delegate_xdg_shell!(WaylandState);
delegate_xdg_window!(WaylandState);
delegate_dispatch!(WaylandState: [WpCursorShapeManagerV1: GlobalData] => CursorShapeManagerState);
delegate_dispatch!(WaylandState: [WpCursorShapeDeviceV1: GlobalData] => CursorShapeManagerState);
delegate_dispatch!(WaylandState: [ZwpTextInputManagerV3: GlobalData] => TextInputState);
delegate_dispatch!(WaylandState: [ZwpTextInputV3: TextInputData] => TextInputState);

View File

@ -21,11 +21,13 @@ use raw_window_handle::{
WaylandDisplayHandle, WaylandWindowHandle,
};
use smithay_client_toolkit::compositor::{CompositorHandler, SurfaceData, SurfaceDataExt};
use smithay_client_toolkit::shell::xdg::frame::fallback_frame::FallbackFrame;
use smithay_client_toolkit::shell::xdg::frame::{DecorationsFrame, FrameAction};
use smithay_client_toolkit::reexports::csd_frame::{
DecorationsFrame, FrameAction, WindowState as SCTKWindowState,
};
use smithay_client_toolkit::shell::xdg::fallback_frame::FallbackFrame;
use smithay_client_toolkit::shell::xdg::window::{
DecorationMode, Window as XdgWindow, WindowConfigure, WindowDecorations as Decorations,
WindowHandler, WindowState as SCTKWindowState,
WindowHandler,
};
use smithay_client_toolkit::shell::xdg::XdgSurface;
use smithay_client_toolkit::shell::WaylandSurface;
@ -917,13 +919,13 @@ impl WaylandWindowInner {
let (shm, pointer) =
RefMut::map_split(state, |s| (&mut s.shm, s.pointer.as_mut().unwrap()));
// Much different API in 0.18
if let Err(err) = pointer.set_cursor(
&conn.connection,
name,
shm.wl_shm(),
&self.pointer_surface,
1,
todo!(),
// name,
// shm.wl_shm(),
// &self.pointer_surface,
// 1,
) {
log::error!("set_cursor: {}", err);
}
@ -1156,8 +1158,11 @@ impl WaylandWindowInner {
.unwrap()
.show_window_menu(seat, serial, (x, y))
}
FrameAction::Resize(edge) => self.window.as_ref().unwrap().resize(seat, serial, edge),
FrameAction::Resize(edge) => {
self.window.as_ref().unwrap().resize(seat, serial, todo!())
}
FrameAction::Move => self.window.as_ref().unwrap().move_(seat, serial),
_ => todo!(),
}
}
}
@ -1267,6 +1272,16 @@ impl CompositorHandler for WaylandState {
Ok(())
});
}
fn transform_changed(
&mut self,
conn: &WConnection,
qh: &wayland_client::QueueHandle<Self>,
surface: &wayland_client::protocol::wl_surface::WlSurface,
new_transform: wayland_client::protocol::wl_output::Transform,
) {
todo!()
}
}
impl WindowHandler for WaylandState {