diff --git a/build.rs b/build.rs index 2e3d6730..cdbaf049 100644 --- a/build.rs +++ b/build.rs @@ -63,11 +63,6 @@ fn main() -> anyhow::Result<()> { write_ty(&mut f, pixman::OPS, "PixmanOp")?; let mut f = open("xkbcommon_tys.rs")?; - write_ty( - &mut f, - xkbcommon::XKB_X11_SETUP_XKB_EXTENSION_FLAGS, - "xkb_x11_setup_xkb_extension_flags", - )?; write_ty(&mut f, xkbcommon::XKB_LOG_LEVEL, "xkb_log_level")?; write_ty(&mut f, xkbcommon::XKB_CONTEXT_FLAGS, "xkb_context_flags")?; write_ty( diff --git a/src/backends/xorg/mod.rs b/src/backends/xorg/mod.rs index 61b55513..e5220a1e 100644 --- a/src/backends/xorg/mod.rs +++ b/src/backends/xorg/mod.rs @@ -374,7 +374,7 @@ impl XorgBackend { let seat = Rc::new(XorgSeat { id: self.state.seat_ids.next(), backend: self.clone(), - kb: info.deviceid, + _kb: info.deviceid, mouse: info.attachment, removed: Cell::new(false), cb: RefCell::new(None), @@ -481,7 +481,7 @@ impl XorgBackend { 1 => BTN_LEFT, 2 => BTN_MIDDLE, 3 => BTN_RIGHT, - n => n + BTN_SIDE - 8, + n => BTN_SIDE + n - 8, }; seat.event(SeatEvent::Button(button, state)); } @@ -516,7 +516,9 @@ impl XorgBackend { }; for info in infos { if info.flags & ffi::XCB_INPUT_HIERARCHY_MASK_MASTER_ADDED != 0 { - self.query_devices(info.deviceid); + if let Err(e) = self.query_devices(info.deviceid) { + log::error!("Could not query device {}: {:#}", info.deviceid, e); + } } else if info.flags & ffi::XCB_INPUT_HIERARCHY_MASK_MASTER_REMOVED != 0 { self.mouse_seats.remove(&info.attachment); if let Some(seat) = self.seats.remove(&info.deviceid) { @@ -654,7 +656,7 @@ impl XorgBackend { node_extents.x - surface_extents.x1, node_extents.y - surface_extents.y1, ); - image.fill_insert_border( + let _ = image.fill_insert_border( 255, 0, 0, @@ -700,7 +702,15 @@ impl XorgBackend { } fn render_buffer(&self, image: &Image>, buffer: &Rc, x: i32, y: i32) { - image.add_image(&buffer.image, x, y); + if let Err(e) = image.add_image(&buffer.image, x, y) { + let client = &buffer.client; + log::error!("Could not access client {} memory: {:#}", client.id, e); + if let Ok(d) = client.display() { + client.fatal_event(d.implementation_error(format!("Could not access memory: {:#}", e))); + } else { + self.state.clients.kill(client.id); + } + } } fn render(&self) -> Result<(), XorgBackendError> { @@ -711,7 +721,7 @@ impl XorgBackend { Some(i) => i, None => continue, }; - image.fill(0, 0, 0, 255); + let _ = image.fill(0, 0, 0, 255); let node = match self.state.root.outputs.get(&output.id) { Some(n) => n, _ => continue, @@ -808,7 +818,7 @@ impl Output for XorgOutput { struct XorgSeat { id: SeatId, backend: Rc, - kb: ffi::xcb_input_device_id_t, + _kb: ffi::xcb_input_device_id_t, mouse: ffi::xcb_input_device_id_t, removed: Cell, cb: RefCell>>, diff --git a/src/client/mod.rs b/src/client/mod.rs index 8c9d4e11..83b2d638 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -217,7 +217,7 @@ impl Clients { global: &Rc, socket: OwnedFd, ) -> Result<(), ClientError> { - let (uid, pid) = unsafe { + let (uid, pid) = { let mut cred = c::ucred { pid: 0, uid: 0, diff --git a/src/client/objects.rs b/src/client/objects.rs index 3aa8e7d9..dc6c2c14 100644 --- a/src/client/objects.rs +++ b/src/client/objects.rs @@ -63,6 +63,7 @@ impl Objects { self.buffers.clear(); } + #[allow(dead_code)] fn id(&self, client_data: &Client) -> Result where ObjectId: Into, diff --git a/src/format.rs b/src/format.rs index 438a233b..11f5d049 100644 --- a/src/format.rs +++ b/src/format.rs @@ -17,6 +17,7 @@ pub fn formats() -> AHashMap { map } +#[allow(dead_code)] const fn fourcc_code(a: char, b: char, c: char, d: char) -> u32 { (a as u32) | ((b as u32) << 8) | ((c as u32) << 16) | ((d as u32) << 24) } diff --git a/src/globals.rs b/src/globals.rs index b1d5f97f..81363cf5 100644 --- a/src/globals.rs +++ b/src/globals.rs @@ -82,7 +82,6 @@ pub trait Global: GlobalBind { fn singleton(&self) -> bool; fn interface(&self) -> Interface; fn version(&self) -> u32; - fn pre_remove(&self); fn break_loops(&self) {} } @@ -127,8 +126,7 @@ impl Globals { } pub async fn remove(&self, state: &State, name: GlobalName) -> Result<(), GlobalError> { - let global = self.take(name, true)?; - global.pre_remove(); + let _global = self.take(name, true)?; self.broadcast(state, |r| r.global_remove(name)).await; Ok(()) } @@ -187,6 +185,7 @@ impl Globals { } } + #[allow(dead_code)] pub fn get_output(&self, output: GlobalName) -> Result, GlobalError> { match self.outputs.get(&output) { Some(o) => Ok(o), diff --git a/src/ifs/wl_buffer/mod.rs b/src/ifs/wl_buffer/mod.rs index 1b79c833..262f2a75 100644 --- a/src/ifs/wl_buffer/mod.rs +++ b/src/ifs/wl_buffer/mod.rs @@ -19,12 +19,12 @@ id!(WlBufferId); pub struct WlBuffer { id: WlBufferId, - client: Rc, - offset: usize, + pub client: Rc, + _offset: usize, pub width: u32, pub height: u32, - stride: u32, - format: &'static Format, + _stride: u32, + _format: &'static Format, pub image: Rc>, pub(super) surfaces: CopyHashMap>, } @@ -54,11 +54,11 @@ impl WlBuffer { Ok(Self { id, client: client.clone(), - offset, + _offset: offset, width, height, - stride, - format, + _stride: stride, + _format: format, image: Rc::new(image), surfaces: Default::default(), }) diff --git a/src/ifs/wl_compositor/mod.rs b/src/ifs/wl_compositor/mod.rs index d39bf42d..533ffa22 100644 --- a/src/ifs/wl_compositor/mod.rs +++ b/src/ifs/wl_compositor/mod.rs @@ -19,10 +19,9 @@ pub struct WlCompositorGlobal { } pub struct WlCompositorObj { - global: Rc, id: WlCompositorId, client: Rc, - version: u32, + _version: u32, } impl WlCompositorGlobal { @@ -37,10 +36,9 @@ impl WlCompositorGlobal { version: u32, ) -> Result<(), WlCompositorError> { let obj = Rc::new(WlCompositorObj { - global: self, id, client: client.clone(), - version, + _version: version, }); client.add_client_obj(&obj)?; Ok(()) @@ -94,10 +92,6 @@ impl Global for WlCompositorGlobal { fn version(&self) -> u32 { 4 } - - fn pre_remove(&self) { - unreachable!() - } } handle_request!(WlCompositorObj); diff --git a/src/ifs/wl_data_device/mod.rs b/src/ifs/wl_data_device/mod.rs index 62fc9fe6..6c12a26b 100644 --- a/src/ifs/wl_data_device/mod.rs +++ b/src/ifs/wl_data_device/mod.rs @@ -17,7 +17,7 @@ const MOTION: u32 = 4; const DROP: u32 = 5; const SELECTION: u32 = 5; -const ROLE: u32 = 0; +#[allow(dead_code)] const ROLE: u32 = 0; id!(WlDataDeviceId); diff --git a/src/ifs/wl_data_device_manager/mod.rs b/src/ifs/wl_data_device_manager/mod.rs index 012a75f9..0c6b5b1a 100644 --- a/src/ifs/wl_data_device_manager/mod.rs +++ b/src/ifs/wl_data_device_manager/mod.rs @@ -12,10 +12,10 @@ use crate::ifs::wl_data_source::WlDataSource; const CREATE_DATA_SOURCE: u32 = 0; const GET_DATA_DEVICE: u32 = 1; -const DND_NONE: u32 = 0; -const DND_COPY: u32 = 1; -const DND_MOVE: u32 = 2; -const DND_ASK: u32 = 4; +#[allow(dead_code)] const DND_NONE: u32 = 0; +#[allow(dead_code)] const DND_COPY: u32 = 1; +#[allow(dead_code)] const DND_MOVE: u32 = 2; +#[allow(dead_code)] const DND_ASK: u32 = 4; id!(WlDataDeviceManagerId); @@ -98,10 +98,6 @@ impl Global for WlDataDeviceManagerGlobal { fn version(&self) -> u32 { 3 } - - fn pre_remove(&self) { - unreachable!() - } } handle_request!(WlDataDeviceManagerObj); diff --git a/src/ifs/wl_data_offer/mod.rs b/src/ifs/wl_data_offer/mod.rs index c1d49dd0..f4496c23 100644 --- a/src/ifs/wl_data_offer/mod.rs +++ b/src/ifs/wl_data_offer/mod.rs @@ -16,10 +16,10 @@ const OFFER: u32 = 0; const SOURCE_ACTIONS: u32 = 1; const ACTION: u32 = 2; -const INVALID_FINISH: u32 = 0; -const INVALID_ACTION_MASK: u32 = 1; -const INVALID_ACTION: u32 = 2; -const INVALID_OFFER: u32 = 3; +#[allow(dead_code)] const INVALID_FINISH: u32 = 0; +#[allow(dead_code)] const INVALID_ACTION_MASK: u32 = 1; +#[allow(dead_code)] const INVALID_ACTION: u32 = 2; +#[allow(dead_code)] const INVALID_OFFER: u32 = 3; id!(WlDataOfferId); @@ -80,7 +80,7 @@ impl Object for WlDataOffer { } fn interface(&self) -> Interface { - Interface::WlDataSource + Interface::WlDataOffer } fn num_requests(&self) -> u32 { diff --git a/src/ifs/wl_data_source/mod.rs b/src/ifs/wl_data_source/mod.rs index 7bc0211b..e96c5ec9 100644 --- a/src/ifs/wl_data_source/mod.rs +++ b/src/ifs/wl_data_source/mod.rs @@ -17,8 +17,8 @@ const DND_DROP_PERFORMED: u32 = 4; const DND_FINISHED: u32 = 5; const ACTION: u32 = 5; -const INVALID_ACTION_MASK: u32 = 0; -const INVALID_SOURCE: u32 = 1; +#[allow(dead_code)] const INVALID_ACTION_MASK: u32 = 0; +#[allow(dead_code)] const INVALID_SOURCE: u32 = 1; id!(WlDataSourceId); diff --git a/src/ifs/wl_display/mod.rs b/src/ifs/wl_display/mod.rs index 5f6da1a2..2fd310e7 100644 --- a/src/ifs/wl_display/mod.rs +++ b/src/ifs/wl_display/mod.rs @@ -16,7 +16,7 @@ const DELETE_ID: u32 = 1; const INVALID_OBJECT: u32 = 0; const INVALID_METHOD: u32 = 1; -const NO_MEMORY: u32 = 2; +#[allow(dead_code)] const NO_MEMORY: u32 = 2; const IMPLEMENTATION: u32 = 3; pub struct WlDisplay { diff --git a/src/ifs/wl_output/mod.rs b/src/ifs/wl_output/mod.rs index 48d44037..4a9275bc 100644 --- a/src/ifs/wl_output/mod.rs +++ b/src/ifs/wl_output/mod.rs @@ -22,23 +22,23 @@ const DONE: u32 = 2; const SCALE: u32 = 3; const SP_UNKNOWN: i32 = 0; -const SP_NONE: i32 = 1; -const SP_HORIZONTAL_RGB: i32 = 2; -const SP_HORIZONTAL_BGR: i32 = 3; -const SP_VERTICAL_RGB: i32 = 4; -const SP_VERTICAL_BGR: i32 = 5; +#[allow(dead_code)] const SP_NONE: i32 = 1; +#[allow(dead_code)] const SP_HORIZONTAL_RGB: i32 = 2; +#[allow(dead_code)] const SP_HORIZONTAL_BGR: i32 = 3; +#[allow(dead_code)] const SP_VERTICAL_RGB: i32 = 4; +#[allow(dead_code)] const SP_VERTICAL_BGR: i32 = 5; const TF_NORMAL: i32 = 0; -const TF_90: i32 = 1; -const TF_180: i32 = 2; -const TF_270: i32 = 3; -const TF_FLIPPED: i32 = 4; -const TF_FLIPPED_90: i32 = 5; -const TF_FLIPPED_180: i32 = 6; -const TF_FLIPPED_270: i32 = 7; +#[allow(dead_code)] const TF_90: i32 = 1; +#[allow(dead_code)] const TF_180: i32 = 2; +#[allow(dead_code)] const TF_270: i32 = 3; +#[allow(dead_code)] const TF_FLIPPED: i32 = 4; +#[allow(dead_code)] const TF_FLIPPED_90: i32 = 5; +#[allow(dead_code)] const TF_FLIPPED_180: i32 = 6; +#[allow(dead_code)] const TF_FLIPPED_270: i32 = 7; const MODE_CURRENT: u32 = 1; -const MODE_PREFERRED: u32 = 2; +#[allow(dead_code)] const MODE_PREFERRED: u32 = 2; pub struct WlOutputGlobal { name: GlobalName, @@ -109,13 +109,18 @@ impl WlOutputGlobal { global: self.clone(), id, client: client.clone(), + version, }); client.add_client_obj(&obj)?; self.bindings.set((client.id, id), obj.clone()); client.event(obj.geometry()).await?; client.event(obj.mode()).await?; - client.event(obj.scale()).await?; - client.event(obj.done()).await?; + if obj.send_scale() { + client.event(obj.scale()).await?; + } + if obj.send_done() { + client.event(obj.done()).await?; + } Ok(()) } } @@ -139,10 +144,6 @@ impl Global for WlOutputGlobal { 3 } - fn pre_remove(&self) { - // - } - fn break_loops(&self) { self.bindings.clear(); } @@ -152,9 +153,18 @@ pub struct WlOutputObj { global: Rc, id: WlOutputId, client: Rc, + version: u32, } impl WlOutputObj { + fn send_done(&self) -> bool { + self.version >= 2 + } + + fn send_scale(&self) -> bool { + self.version >= 2 + } + fn geometry(self: &Rc) -> DynEventFormatter { Box::new(Geometry { obj: self.clone(), @@ -222,7 +232,11 @@ impl Object for WlOutputObj { } fn num_requests(&self) -> u32 { - RELEASE + 1 + if self.version < 3 { + 0 + } else { + RELEASE + 1 + } } fn break_loops(&self) { diff --git a/src/ifs/wl_seat/mod.rs b/src/ifs/wl_seat/mod.rs index 2cff5bf4..c1913c37 100644 --- a/src/ifs/wl_seat/mod.rs +++ b/src/ifs/wl_seat/mod.rs @@ -36,14 +36,14 @@ const NAME: u32 = 1; const POINTER: u32 = 1; const KEYBOARD: u32 = 2; -const TOUCH: u32 = 4; +#[allow(dead_code)] const TOUCH: u32 = 4; -const MISSING_CAPABILITY: u32 = 0; +#[allow(dead_code)] const MISSING_CAPABILITY: u32 = 0; pub struct WlSeatGlobal { name: GlobalName, state: Rc, - seat: Rc, + _seat: Rc, move_: Cell, move_start_pos: Cell<(Fixed, Fixed)>, extents_start_pos: Cell<(i32, i32)>, @@ -75,7 +75,7 @@ impl WlSeatGlobal { Self { name, state: state.clone(), - seat: seat.clone(), + _seat: seat.clone(), move_: Cell::new(false), move_start_pos: Cell::new((Fixed(0), Fixed(0))), extents_start_pos: Cell::new((0, 0)), @@ -217,7 +217,7 @@ impl WlSeatGlobal { } } - async fn key_event(&self, key: u32, state: KeyState) {} + async fn key_event(&self, _key: u32, _state: KeyState) {} async fn bind_( self: Rc, @@ -231,6 +231,7 @@ impl WlSeatGlobal { client: client.clone(), pointers: Default::default(), keyboards: Default::default(), + version, }); client.add_client_obj(&obj)?; client.event(obj.capabilities()).await?; @@ -261,11 +262,7 @@ impl Global for WlSeatGlobal { } fn version(&self) -> u32 { - 3 - } - - fn pre_remove(&self) { - // + 7 } fn break_loops(&self) { @@ -279,6 +276,7 @@ pub struct WlSeatObj { client: Rc, pointers: CopyHashMap>, keyboards: CopyHashMap>, + version: u32, } impl WlSeatObj { @@ -369,7 +367,11 @@ impl Object for WlSeatObj { } fn num_requests(&self) -> u32 { - RELEASE + 1 + if self.version < 5 { + GET_TOUCH + 1 + } else { + RELEASE + 1 + } } fn break_loops(&self) { diff --git a/src/ifs/wl_seat/wl_keyboard/mod.rs b/src/ifs/wl_seat/wl_keyboard/mod.rs index a4d2cb6d..a84dcd8a 100644 --- a/src/ifs/wl_seat/wl_keyboard/mod.rs +++ b/src/ifs/wl_seat/wl_keyboard/mod.rs @@ -18,11 +18,11 @@ const KEY: u32 = 3; const MODIFIERS: u32 = 4; const REPEAT_INFO: u32 = 5; -const NO_KEYMAP: u32 = 0; +#[allow(dead_code)] const NO_KEYMAP: u32 = 0; pub(super) const XKB_V1: u32 = 1; -const RELEASED: u32 = 0; -const PRESSED: u32 = 1; +#[allow(dead_code)] const RELEASED: u32 = 0; +#[allow(dead_code)] const PRESSED: u32 = 1; id!(WlKeyboardId); @@ -48,6 +48,7 @@ impl WlKeyboard { }) } + #[allow(dead_code)] pub fn enter( self: &Rc, serial: u32, @@ -62,6 +63,7 @@ impl WlKeyboard { }) } + #[allow(dead_code)] pub fn leave(self: &Rc, serial: u32, surface: WlSurfaceId) -> DynEventFormatter { Box::new(Leave { obj: self.clone(), @@ -70,6 +72,7 @@ impl WlKeyboard { }) } + #[allow(dead_code)] pub fn key(self: &Rc, serial: u32, time: u32, key: u32, state: u32) -> DynEventFormatter { Box::new(Key { obj: self.clone(), @@ -80,6 +83,7 @@ impl WlKeyboard { }) } + #[allow(dead_code)] pub fn modifiers( self: &Rc, serial: u32, @@ -98,6 +102,7 @@ impl WlKeyboard { }) } + #[allow(dead_code)] pub fn repeat_info(self: &Rc, rate: i32, delay: i32) -> DynEventFormatter { Box::new(RepeatInfo { obj: self.clone(), diff --git a/src/ifs/wl_seat/wl_pointer/mod.rs b/src/ifs/wl_seat/wl_pointer/mod.rs index e379361f..f70a58f7 100644 --- a/src/ifs/wl_seat/wl_pointer/mod.rs +++ b/src/ifs/wl_seat/wl_pointer/mod.rs @@ -22,7 +22,7 @@ const AXIS_SOURCE: u32 = 6; const AXIS_STOP: u32 = 7; const AXIS_DISCRETE: u32 = 8; -const ROLE: u32 = 0; +#[allow(dead_code)] const ROLE: u32 = 0; pub(super) const RELEASED: u32 = 0; pub(super) const PRESSED: u32 = 1; @@ -30,10 +30,10 @@ pub(super) const PRESSED: u32 = 1; pub(super) const VERTICAL_SCROLL: u32 = 0; pub(super) const HORIZONTAL_SCROLL: u32 = 1; -const WHEEL: u32 = 0; -const FINGER: u32 = 1; -const CONTINUOUS: u32 = 2; -const WHEEL_TILT: u32 = 3; +#[allow(dead_code)] const WHEEL: u32 = 0; +#[allow(dead_code)] const FINGER: u32 = 1; +#[allow(dead_code)] const CONTINUOUS: u32 = 2; +#[allow(dead_code)] const WHEEL_TILT: u32 = 3; id!(WlPointerId); @@ -108,10 +108,12 @@ impl WlPointer { }) } + #[allow(dead_code)] pub fn frame(self: &Rc) -> DynEventFormatter { Box::new(Frame { obj: self.clone() }) } + #[allow(dead_code)] pub fn axis_source(self: &Rc, axis_source: u32) -> DynEventFormatter { Box::new(AxisSource { obj: self.clone(), @@ -119,6 +121,7 @@ impl WlPointer { }) } + #[allow(dead_code)] pub fn axis_stop(self: &Rc, time: u32, axis: u32) -> DynEventFormatter { Box::new(AxisStop { obj: self.clone(), @@ -127,6 +130,7 @@ impl WlPointer { }) } + #[allow(dead_code)] pub fn axis_discrete(self: &Rc, axis: u32, discrete: i32) -> DynEventFormatter { Box::new(AxisDiscrete { obj: self.clone(), diff --git a/src/ifs/wl_seat/wl_touch/mod.rs b/src/ifs/wl_seat/wl_touch/mod.rs index 9fa9658a..31f80777 100644 --- a/src/ifs/wl_seat/wl_touch/mod.rs +++ b/src/ifs/wl_seat/wl_touch/mod.rs @@ -9,13 +9,13 @@ pub use types::*; const RELEASE: u32 = 0; -const DOWN: u32 = 0; -const UP: u32 = 1; -const MOTION: u32 = 2; -const FRAME: u32 = 3; -const CANCEL: u32 = 4; -const SHAPE: u32 = 5; -const ORIENTATION: u32 = 6; +#[allow(dead_code)] const DOWN: u32 = 0; +#[allow(dead_code)] const UP: u32 = 1; +#[allow(dead_code)] const MOTION: u32 = 2; +#[allow(dead_code)] const FRAME: u32 = 3; +#[allow(dead_code)] const CANCEL: u32 = 4; +#[allow(dead_code)] const SHAPE: u32 = 5; +#[allow(dead_code)] const ORIENTATION: u32 = 6; id!(WlTouchId); diff --git a/src/ifs/wl_shm/mod.rs b/src/ifs/wl_shm/mod.rs index 58493aa5..f4a9661a 100644 --- a/src/ifs/wl_shm/mod.rs +++ b/src/ifs/wl_shm/mod.rs @@ -19,7 +19,7 @@ pub struct WlShmGlobal { } pub struct WlShmObj { - global: Rc, + _global: Rc, id: WlShmId, client: Rc, } @@ -36,7 +36,7 @@ impl WlShmGlobal { _version: u32, ) -> Result<(), WlShmError> { let obj = Rc::new(WlShmObj { - global: self, + _global: self, id, client: client.clone(), }); @@ -100,10 +100,6 @@ impl Global for WlShmGlobal { fn version(&self) -> u32 { 1 } - - fn pre_remove(&self) { - unreachable!() - } } handle_request!(WlShmObj); diff --git a/src/ifs/wl_subcompositor/mod.rs b/src/ifs/wl_subcompositor/mod.rs index ab4c02a3..60b9ef29 100644 --- a/src/ifs/wl_subcompositor/mod.rs +++ b/src/ifs/wl_subcompositor/mod.rs @@ -11,7 +11,7 @@ pub use types::*; const DESTROY: u32 = 0; const GET_SUBSURFACE: u32 = 1; -const BAD_SURFACE: u32 = 0; +#[allow(dead_code)] const BAD_SURFACE: u32 = 0; id!(WlSubcompositorId); @@ -20,7 +20,6 @@ pub struct WlSubcompositorGlobal { } pub struct WlSubcompositorObj { - global: Rc, id: WlSubcompositorId, client: Rc, } @@ -37,7 +36,6 @@ impl WlSubcompositorGlobal { _version: u32, ) -> Result<(), WlSubcompositorError> { let obj = Rc::new(WlSubcompositorObj { - global: self, id, client: client.clone(), }); @@ -95,10 +93,6 @@ impl Global for WlSubcompositorGlobal { fn version(&self) -> u32 { 1 } - - fn pre_remove(&self) { - unreachable!() - } } handle_request!(WlSubcompositorObj); diff --git a/src/ifs/wl_surface/mod.rs b/src/ifs/wl_surface/mod.rs index bb2483a0..246ac005 100644 --- a/src/ifs/wl_surface/mod.rs +++ b/src/ifs/wl_surface/mod.rs @@ -33,12 +33,12 @@ const SET_BUFFER_TRANSFORM: u32 = 7; const SET_BUFFER_SCALE: u32 = 8; const DAMAGE_BUFFER: u32 = 9; -const ENTER: u32 = 0; -const LEAVE: u32 = 1; +#[allow(dead_code)] const ENTER: u32 = 0; +#[allow(dead_code)] const LEAVE: u32 = 1; -const INVALID_SCALE: u32 = 0; -const INVALID_TRANSFORM: u32 = 1; -const INVALID_SIZE: u32 = 2; +#[allow(dead_code)] const INVALID_SCALE: u32 = 0; +#[allow(dead_code)] const INVALID_TRANSFORM: u32 = 1; +#[allow(dead_code)] const INVALID_SIZE: u32 = 2; id!(WlSurfaceId); @@ -143,7 +143,7 @@ impl XdgSurfaceRoleData { } struct XdgPopupData { - popup: Rc, + _popup: Rc, parent: Option>, } @@ -229,7 +229,7 @@ impl WlSurface { for surface in children.subsurfaces.values() { let rd = surface.role_data.borrow(); if let RoleData::Subsurface(ss) = &*rd { - let mut ss_extents = surface.extents.get(); + let ss_extents = surface.extents.get(); extents.x1 = extents.x1.min(ss_extents.x1 + ss.x); extents.y1 = extents.y1.min(ss_extents.y1 + ss.y); extents.x2 = extents.x2.max(ss_extents.x2 + ss.x); @@ -249,10 +249,6 @@ impl WlSurface { parent.calculate_extents(); } - pub fn is_subsurface(&self) -> bool { - self.role.get() == SurfaceRole::Subsurface - } - pub fn get_root(self: &Rc) -> Rc { let mut root = self.clone(); loop { @@ -381,7 +377,7 @@ impl WlSurface { } async fn damage(&self, parser: MsgParser<'_, '_>) -> Result<(), DamageError> { - let req: Damage = self.parse(parser)?; + let _req: Damage = self.parse(parser)?; Ok(()) } @@ -518,17 +514,17 @@ impl WlSurface { &self, parser: MsgParser<'_, '_>, ) -> Result<(), SetBufferTransformError> { - let req: SetBufferTransform = self.parse(parser)?; + let _req: SetBufferTransform = self.parse(parser)?; Ok(()) } async fn set_buffer_scale(&self, parser: MsgParser<'_, '_>) -> Result<(), SetBufferScaleError> { - let req: SetBufferScale = self.parse(parser)?; + let _req: SetBufferScale = self.parse(parser)?; Ok(()) } async fn damage_buffer(&self, parser: MsgParser<'_, '_>) -> Result<(), DamageBufferError> { - let req: DamageBuffer = self.parse(parser)?; + let _req: DamageBuffer = self.parse(parser)?; Ok(()) } diff --git a/src/ifs/wl_surface/wl_subsurface/mod.rs b/src/ifs/wl_surface/wl_subsurface/mod.rs index 61f50cec..83dcd608 100644 --- a/src/ifs/wl_surface/wl_subsurface/mod.rs +++ b/src/ifs/wl_surface/wl_subsurface/mod.rs @@ -17,7 +17,7 @@ const PLACE_BELOW: u32 = 3; const SET_SYNC: u32 = 4; const SET_DESYNC: u32 = 5; -const BAD_SURFACE: u32 = 0; +#[allow(dead_code)] const BAD_SURFACE: u32 = 0; const MAX_SUBSURFACE_DEPTH: u32 = 100; @@ -29,7 +29,7 @@ pub struct WlSubsurface { pub(super) parent: Rc, } -fn update_children_sync(surface: &Rc, sync: bool) -> Result<(), WlSubsurfaceError> { +fn update_children_sync(surface: &Rc, sync: bool) { let children = surface.children.borrow(); if let Some(children) = &*children { for child in children.subsurfaces.values() { @@ -44,7 +44,6 @@ fn update_children_sync(surface: &Rc, sync: bool) -> Result<(), WlSub } } } - Ok(()) } fn update_children_attach( @@ -63,7 +62,7 @@ fn update_children_attach( } data.sync_ancestor = sync; let sync = data.sync_ancestor || data.sync_requested; - update_children_attach(child, sync, depth + 1); + update_children_attach(child, sync, depth + 1)?; } } } diff --git a/src/ifs/wl_surface/xdg_surface/mod.rs b/src/ifs/wl_surface/xdg_surface/mod.rs index fe4eb921..87c27c51 100644 --- a/src/ifs/wl_surface/xdg_surface/mod.rs +++ b/src/ifs/wl_surface/xdg_surface/mod.rs @@ -24,17 +24,16 @@ const ACK_CONFIGURE: u32 = 4; const CONFIGURE: u32 = 0; -const NOT_CONSTRUCTED: u32 = 1; +#[allow(dead_code)] const NOT_CONSTRUCTED: u32 = 1; const ALREADY_CONSTRUCTED: u32 = 2; -const UNCONFIGURED_BUFFER: u32 = 3; +#[allow(dead_code)] const UNCONFIGURED_BUFFER: u32 = 3; id!(XdgSurfaceId); pub struct XdgSurface { id: XdgSurfaceId, - wm_base: Rc, + base: Rc, pub surface: Rc, - version: u32, } impl XdgSurface { @@ -42,13 +41,11 @@ impl XdgSurface { wm_base: &Rc, id: XdgSurfaceId, surface: &Rc, - version: u32, ) -> Self { Self { id, - wm_base: wm_base.clone(), + base: wm_base.clone(), surface: surface.clone(), - version, } } @@ -64,6 +61,7 @@ impl XdgSurface { if !matches!(old_role, SurfaceRole::None | SurfaceRole::XdgSurface) { return Err(XdgSurfaceError::IncompatibleRole(self.surface.id, old_role)); } + self.surface.role.set(SurfaceRole::XdgSurface); let mut data = self.surface.role_data.borrow_mut(); if data.is_some() { return Err(XdgSurfaceError::AlreadyAttached(self.surface.id)); @@ -101,7 +99,7 @@ impl XdgSurface { } *data = RoleData::None; } - self.wm_base.surfaces.remove(&self.id); + self.base.surfaces.remove(&self.id); self.surface.client.remove_obj(self).await?; Ok(()) } @@ -128,7 +126,7 @@ impl XdgSurface { return Err(GetToplevelError::AlreadyConstructed); } data.role = XdgSurfaceRole::Toplevel; - let toplevel = Rc::new(XdgToplevel::new(req.id, self, self.version)); + let toplevel = Rc::new(XdgToplevel::new(req.id, self)); self.surface.client.add_client_obj(&toplevel)?; data.role_data = XdgSurfaceRoleData::Toplevel(XdgToplevelData { toplevel, @@ -161,7 +159,7 @@ impl XdgSurface { return Err(GetPopupError::AlreadyConstructed); } data.role = XdgSurfaceRole::Popup; - let popup = Rc::new(XdgPopup::new(req.id, self, self.version)); + let popup = Rc::new(XdgPopup::new(req.id, self)); self.surface.client.add_client_obj(&popup)?; if let Some(parent) = &parent { let mut data = parent.surface.role_data.borrow_mut(); @@ -169,7 +167,7 @@ impl XdgSurface { xdg.popups.set(self.surface.id, popup.clone()); } } - data.role_data = XdgSurfaceRoleData::Popup(XdgPopupData { popup, parent }); + data.role_data = XdgSurfaceRoleData::Popup(XdgPopupData { _popup: popup, parent }); } Ok(()) } diff --git a/src/ifs/wl_surface/xdg_surface/xdg_popup/mod.rs b/src/ifs/wl_surface/xdg_surface/xdg_popup/mod.rs index cee098e8..7dd3bb48 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_popup/mod.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_popup/mod.rs @@ -15,22 +15,20 @@ const CONFIGURE: u32 = 0; const POPUP_DONE: u32 = 1; const REPOSITIONED: u32 = 2; -const INVALID_GRAB: u32 = 1; +#[allow(dead_code)] const INVALID_GRAB: u32 = 1; id!(XdgPopupId); pub struct XdgPopup { id: XdgPopupId, pub(in super::super) surface: Rc, - version: u32, } impl XdgPopup { - pub fn new(id: XdgPopupId, surface: &Rc, version: u32) -> Self { + pub fn new(id: XdgPopupId, surface: &Rc) -> Self { Self { id, surface: surface.clone(), - version, } } diff --git a/src/ifs/wl_surface/xdg_surface/xdg_toplevel/mod.rs b/src/ifs/wl_surface/xdg_surface/xdg_toplevel/mod.rs index 9d044115..fa651e3d 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_toplevel/mod.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_toplevel/mod.rs @@ -40,29 +40,27 @@ pub enum ResizeEdge { BottomRight = 10, } -const STATE_MAXIMIZED: u32 = 1; -const STATE_FULLSCREEN: u32 = 2; -const STATE_RESIZING: u32 = 3; -const STATE_ACTIVATED: u32 = 4; -const STATE_TILED_LEFT: u32 = 5; -const STATE_TILED_RIGHT: u32 = 6; -const STATE_TILED_TOP: u32 = 7; -const STATE_TILED_BOTTOM: u32 = 8; +#[allow(dead_code)] const STATE_MAXIMIZED: u32 = 1; +#[allow(dead_code)] const STATE_FULLSCREEN: u32 = 2; +#[allow(dead_code)] const STATE_RESIZING: u32 = 3; +#[allow(dead_code)] const STATE_ACTIVATED: u32 = 4; +#[allow(dead_code)] const STATE_TILED_LEFT: u32 = 5; +#[allow(dead_code)] const STATE_TILED_RIGHT: u32 = 6; +#[allow(dead_code)] const STATE_TILED_TOP: u32 = 7; +#[allow(dead_code)] const STATE_TILED_BOTTOM: u32 = 8; id!(XdgToplevelId); pub struct XdgToplevel { id: XdgToplevelId, pub surface: Rc, - version: u32, } impl XdgToplevel { - pub fn new(id: XdgToplevelId, surface: &Rc, version: u32) -> Self { + pub fn new(id: XdgToplevelId, surface: &Rc) -> Self { Self { id, surface: surface.clone(), - version, } } diff --git a/src/ifs/xdg_positioner/mod.rs b/src/ifs/xdg_positioner/mod.rs index c638ee37..9e35287f 100644 --- a/src/ifs/xdg_positioner/mod.rs +++ b/src/ifs/xdg_positioner/mod.rs @@ -9,6 +9,7 @@ use num_traits::FromPrimitive; use std::cell::RefCell; use std::rc::Rc; pub use types::*; +use crate::ifs::xdg_wm_base::XdgWmBaseObj; const DESTROY: u32 = 0; const SET_SIZE: u32 = 1; @@ -78,8 +79,8 @@ id!(XdgPositionerId); pub struct XdgPositioner { id: XdgPositionerId, + base: Rc, client: Rc, - version: u32, position: RefCell, } @@ -103,15 +104,16 @@ pub struct XdgPositioned { } impl XdgPositioner { - pub fn new(id: XdgPositionerId, client: &Rc, version: u32) -> Self { + pub fn new(base: &Rc, id: XdgPositionerId, client: &Rc) -> Self { Self { id, client: client.clone(), - version, + base: base.clone(), position: RefCell::new(Default::default()), } } + #[allow(dead_code)] pub fn clone(&self) -> Box { Box::new(*self.position.borrow()) } @@ -266,6 +268,10 @@ impl Object for XdgPositioner { } fn num_requests(&self) -> u32 { - SET_PARENT_CONFIGURE + 1 + if self.base.version < 3 { + SET_OFFSET + 1 + } else { + SET_PARENT_CONFIGURE + 1 + } } } diff --git a/src/ifs/xdg_wm_base/mod.rs b/src/ifs/xdg_wm_base/mod.rs index e0da002a..b9d39468 100644 --- a/src/ifs/xdg_wm_base/mod.rs +++ b/src/ifs/xdg_wm_base/mod.rs @@ -17,12 +17,12 @@ const PONG: u32 = 3; const PING: u32 = 0; -const ROLE: u32 = 0; +#[allow(dead_code)] const ROLE: u32 = 0; const DEFUNCT_SURFACES: u32 = 1; -const NOT_THE_TOPMOST_POPUP: u32 = 2; -const INVALID_POPUP_PARENT: u32 = 3; -const INVALID_SURFACE_STATE: u32 = 4; -const INVALID_POSITIONER: u32 = 5; +#[allow(dead_code)] const NOT_THE_TOPMOST_POPUP: u32 = 2; +#[allow(dead_code)] const INVALID_POPUP_PARENT: u32 = 3; +#[allow(dead_code)] const INVALID_SURFACE_STATE: u32 = 4; +#[allow(dead_code)] const INVALID_POSITIONER: u32 = 5; id!(XdgWmBaseId); @@ -31,10 +31,9 @@ pub struct XdgWmBaseGlobal { } pub struct XdgWmBaseObj { - global: Rc, id: XdgWmBaseId, client: Rc, - version: u32, + pub version: u32, pub(super) surfaces: CopyHashMap>, } @@ -50,7 +49,6 @@ impl XdgWmBaseGlobal { version: u32, ) -> Result<(), XdgWmBaseError> { let obj = Rc::new(XdgWmBaseObj { - global: self, id, client: client.clone(), version, @@ -80,11 +78,11 @@ impl XdgWmBaseObj { } async fn create_positioner( - &self, + self: &Rc, parser: MsgParser<'_, '_>, ) -> Result<(), CreatePositionerError> { - let req: CreatePositioner = self.client.parse(self, parser)?; - let pos = Rc::new(XdgPositioner::new(req.id, &self.client, 3)); + let req: CreatePositioner = self.client.parse(&**self, parser)?; + let pos = Rc::new(XdgPositioner::new(self, req.id, &self.client)); self.client.add_client_obj(&pos)?; Ok(()) } @@ -95,7 +93,7 @@ impl XdgWmBaseObj { ) -> Result<(), GetXdgSurfaceError> { let req: GetXdgSurface = self.client.parse(&**self, parser)?; let surface = self.client.get_surface(req.surface)?; - let xdg_surface = Rc::new(XdgSurface::new(self, req.id, &surface, 3)); + let xdg_surface = Rc::new(XdgSurface::new(self, req.id, &surface)); self.client.add_client_obj(&xdg_surface)?; xdg_surface.install()?; self.surfaces.set(req.id, xdg_surface); @@ -141,10 +139,6 @@ impl Global for XdgWmBaseGlobal { fn version(&self) -> u32 { 3 } - - fn pre_remove(&self) { - unreachable!() - } } handle_request!(XdgWmBaseObj); diff --git a/src/macros.rs b/src/macros.rs index c91869b6..d165afd0 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -117,6 +117,7 @@ macro_rules! linear_ids { pub struct $id(u32); impl $id { + #[allow(dead_code)] pub fn raw(&self) -> u32 { self.0 } diff --git a/src/object.rs b/src/object.rs index 835b6482..917ae7fb 100644 --- a/src/object.rs +++ b/src/object.rs @@ -11,8 +11,6 @@ pub const WL_DISPLAY_ID: ObjectId = ObjectId(1); pub struct ObjectId(u32); impl ObjectId { - pub const NONE: Self = ObjectId(0); - pub fn from_raw(raw: u32) -> Self { Self(raw) } diff --git a/src/pixman/mod.rs b/src/pixman/mod.rs index e6dd0e65..c03edc97 100644 --- a/src/pixman/mod.rs +++ b/src/pixman/mod.rs @@ -350,6 +350,7 @@ where Ok(()) } + #[allow(dead_code)] pub fn memory(&self) -> &T { &self.memory } diff --git a/src/tasks.rs b/src/tasks.rs index 0c36ec63..08bc225c 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -99,7 +99,7 @@ impl OutputHandler { ae.triggered().await; } self.state.outputs.remove(&self.output.id()); - self.state.globals.remove(&self.state, name).await; + let _ = self.state.globals.remove(&self.state, name).await; self.state .output_handlers .borrow_mut() @@ -131,7 +131,7 @@ impl SeatHandler { } ae.triggered().await; } - self.state.globals.remove(&self.state, name).await; + let _ = self.state.globals.remove(&self.state, name).await; self.state .seat_handlers .borrow_mut() diff --git a/src/tree.rs b/src/tree.rs index f23dbb2f..a812ba99 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -1,5 +1,4 @@ use crate::backend::{Output, OutputId}; -use crate::ifs::wl_seat::WlSeatGlobal; use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel; use crate::utils::copyhashmap::CopyHashMap; use crate::utils::linkedlist::{LinkedList, Node as LinkedNode}; @@ -47,12 +46,6 @@ pub enum NodeKind { Container(Rc), } -impl NodeKind { - pub async fn leave(&self, seat: &WlSeatGlobal) {} - - pub async fn enter(&self, seat: &WlSeatGlobal) {} -} - #[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] pub struct NodeExtents { pub x: i32, @@ -195,6 +188,7 @@ impl Node for ToplevelNode { } } +#[allow(dead_code)] #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum ContainerSplit { Horizontal, diff --git a/src/utils/buffd/parser.rs b/src/utils/buffd/parser.rs index 38fdf601..9905cb35 100644 --- a/src/utils/buffd/parser.rs +++ b/src/utils/buffd/parser.rs @@ -57,6 +57,7 @@ impl<'a, 'b> MsgParser<'a, 'b> { self.int().map(|i| GlobalName::from_raw(i as u32)) } + #[allow(dead_code)] pub fn fixed(&mut self) -> Result { self.int().map(|i| Fixed(i)) } diff --git a/src/utils/copyhashmap.rs b/src/utils/copyhashmap.rs index a6e8141e..e376ff68 100644 --- a/src/utils/copyhashmap.rs +++ b/src/utils/copyhashmap.rs @@ -28,14 +28,6 @@ impl CopyHashMap { self.map.borrow_mut().get(k).cloned() } - pub fn get_or_insert_default(&self, k: K) -> V - where - V: Default, - { - let mut map = self.map.borrow_mut(); - map.entry(k).or_insert_with(|| Default::default()).clone() - } - pub fn remove(&self, k: &K) -> Option { self.map.borrow_mut().remove(k) } diff --git a/src/utils/lock.rs b/src/utils/lock.rs deleted file mode 100644 index 3e11b2d2..00000000 --- a/src/utils/lock.rs +++ /dev/null @@ -1,63 +0,0 @@ -use std::cell::{RefCell, RefMut}; -use std::future::Future; -use std::ops::{Deref, DerefMut}; -use std::pin::Pin; -use std::task::{Context, Poll, Waker}; - -pub struct AsyncLock { - data: RefCell, - waiters: RefCell>, -} - -impl AsyncLock { - pub fn lock<'a>(&'a self) -> LockedFuture<'a, T> { - LockedFuture { lock: self } - } -} - -pub struct LockedFuture<'a, T> { - lock: &'a AsyncLock, -} - -impl<'a, T> Future for LockedFuture<'a, T> { - type Output = Locked<'a, T>; - - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - if let Ok(data) = self.lock.data.try_borrow_mut() { - Poll::Ready(Locked { - data, - lock: self.lock, - }) - } else { - self.lock.waiters.borrow_mut().push(cx.waker().clone()); - Poll::Pending - } - } -} - -pub struct Locked<'a, T> { - data: RefMut<'a, T>, - lock: &'a AsyncLock, -} - -impl<'a, T> Deref for Locked<'a, T> { - type Target = T; - - fn deref(&self) -> &Self::Target { - self.data.deref() - } -} - -impl<'a, T> DerefMut for Locked<'a, T> { - fn deref_mut(&mut self) -> &mut Self::Target { - self.data.deref_mut() - } -} - -impl<'a, T> Drop for Locked<'a, T> { - fn drop(&mut self) { - for waiter in self.lock.waiters.borrow_mut().drain(..) { - waiter.wake(); - } - } -} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 059ff96e..0a51459e 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -2,7 +2,6 @@ pub mod asyncevent; pub mod buffd; pub mod copyhashmap; pub mod linkedlist; -pub mod lock; pub mod numcell; pub mod oneshot; pub mod ptr_ext; diff --git a/src/xkbcommon/consts.rs b/src/xkbcommon/consts.rs index 6114fdcf..9b4d7b11 100644 --- a/src/xkbcommon/consts.rs +++ b/src/xkbcommon/consts.rs @@ -1,13 +1,5 @@ #![allow(dead_code)] -cenum! { - XkbX11SetupXkbExtensionFlags, XKB_X11_SETUP_XKB_EXTENSION_FLAGS; - - XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS = 0, -} - -bitor!(XkbX11SetupXkbExtensionFlags); - cenum! { XkbLogLevel, XKB_LOG_LEVEL; diff --git a/src/xkbcommon/mod.rs b/src/xkbcommon/mod.rs index fcf6e525..8dcad0c5 100644 --- a/src/xkbcommon/mod.rs +++ b/src/xkbcommon/mod.rs @@ -1,4 +1,4 @@ -#![allow(non_camel_case_types)] +#![allow(non_camel_case_types, improper_ctypes)] mod consts; @@ -11,21 +11,11 @@ use std::ops::Deref; use std::ptr; use crate::utils::ptr_ext::PtrExt; -use libloading::Library; use thiserror::Error; use uapi::c; -use xcb_dl::ffi::xcb_connection_t; #[derive(Debug, Error)] pub enum XkbCommonError { - #[error("xkbcommon-x11 could not be loaded")] - LoadXkbCommonX11(#[source] libloading::Error), - #[error("One of the xkbcommon-x11 symbols could not be loaded")] - LoadXkbCommonX11Sym(#[source] libloading::Error), - #[error("Could not create keymap from X11 device")] - CreateKeymapFromDevice, - #[error("Could not create state from X11 device")] - CreateStateFromDevice, #[error("Could not create an xkbcommon context")] CreateContext, #[error("Could not create keymap from names")] @@ -81,10 +71,8 @@ extern "C" { keymap: *mut xkb_keymap, format: xkb_keymap_format, ) -> *mut c::c_char; - fn xkb_keymap_ref(keymap: *mut xkb_keymap) -> *mut xkb_keymap; fn xkb_keymap_unref(keymap: *mut xkb_keymap); fn xkb_state_unref(state: *mut xkb_state); - fn xkb_state_get_keymap(state: *mut xkb_state) -> *mut xkb_keymap; } pub struct XkbContext { @@ -170,16 +158,6 @@ pub struct XkbState { state: *mut xkb_state, } -impl XkbState { - pub fn keymap(&self) -> XkbKeymap { - unsafe { - let res = xkb_state_get_keymap(self.state); - xkb_keymap_ref(res); - XkbKeymap { keymap: res } - } - } -} - impl Drop for XkbState { fn drop(&mut self) { unsafe { @@ -188,91 +166,6 @@ impl Drop for XkbState { } } -pub struct XkbCommonX11 { - library: Library, - fns: XkbCommonX11Fns, -} - -struct XkbCommonX11Fns { - xkb_x11_keymap_new_from_device: unsafe fn( - context: *mut xkb_context, - c: *mut xcb_connection_t, - device_id: i32, - flags: xkb_x11_setup_xkb_extension_flags, - ) -> *mut xkb_keymap, - xkb_x11_state_new_from_device: unsafe fn( - keymap: *mut xkb_keymap, - c: *mut xcb_connection_t, - device_id: i32, - ) -> *mut xkb_state, -} - -impl XkbCommonX11 { - pub fn load() -> Result { - let library = unsafe { - match Library::new("libxkbcommon-x11.so") { - Ok(l) => l, - Err(e) => return Err(XkbCommonError::LoadXkbCommonX11(e)), - } - }; - let fns = match get_xkbcommon_x11_fns(&library) { - Ok(f) => f, - Err(e) => return Err(XkbCommonError::LoadXkbCommonX11Sym(e)), - }; - Ok(Self { library, fns }) - } - - pub unsafe fn keymap_from_device( - &self, - context: &XkbContext, - c: *mut xcb_connection_t, - device_id: i32, - flags: XkbX11SetupXkbExtensionFlags, - ) -> Result { - let res = (self.fns.xkb_x11_keymap_new_from_device)( - context.context, - c, - device_id, - flags.raw() as _, - ); - if res.is_null() { - return Err(XkbCommonError::CreateKeymapFromDevice); - } - Ok(XkbKeymap { keymap: res }) - } - - pub unsafe fn state_from_device( - &self, - keymap: &XkbKeymap, - c: *mut xcb_connection_t, - device_id: i32, - ) -> Result { - let res = (self.fns.xkb_x11_state_new_from_device)(keymap.keymap, c, device_id); - if res.is_null() { - return Err(XkbCommonError::CreateStateFromDevice); - } - Ok(XkbState { state: res }) - } -} - -fn get_xkbcommon_x11_fns(lib: &Library) -> Result { - macro_rules! syms { - ($($sym:ident,)*) => { - Ok(XkbCommonX11Fns { - $( - $sym: std::mem::transmute(lib.get::(concat!(stringify!($sym), "\0").as_bytes())?.into_raw().into_raw()), - )* - }) - } - } - unsafe { - syms! { - xkb_x11_keymap_new_from_device, - xkb_x11_state_new_from_device, - } - } -} - unsafe extern "C" fn xkbcommon_logger( _ctx: *mut xkb_context, level: xkb_log_level,