diff --git a/protocols.md b/protocols.md index 6d79e8bd..968f9010 100644 --- a/protocols.md +++ b/protocols.md @@ -11,6 +11,7 @@ - kde-server-decoration - mesa-drm - presentation-time +- relative-pointer # planned @@ -20,7 +21,6 @@ - session-lock - linux-explicit-synchronization - pointer-constraints -- relative-pointer - tablet - xwayland-keyboard-grabbing diff --git a/src/backends/metal/input.rs b/src/backends/metal/input.rs index b6517089..9843e740 100644 --- a/src/backends/metal/input.rs +++ b/src/backends/metal/input.rs @@ -3,6 +3,7 @@ use { async_engine::FdStatus, backend::{AxisSource, InputEvent, KeyState, ScrollAxis}, backends::metal::MetalBackend, + fixed::Fixed, ifs::wl_seat::PX_PER_SCROLL, libinput::{ consts::{ @@ -15,7 +16,6 @@ use { }, std::rc::Rc, }; -use crate::fixed::Fixed; macro_rules! unpack { ($slf:expr, $ev:expr) => {{ diff --git a/src/backends/x.rs b/src/backends/x.rs index b24d9d10..3a965f45 100644 --- a/src/backends/x.rs +++ b/src/backends/x.rs @@ -761,7 +761,10 @@ impl XBackend { }; seat.mouse_event(InputEvent::AxisSource(AxisSource::Wheel)); seat.mouse_event(InputEvent::AxisDiscrete(val, axis)); - seat.mouse_event(InputEvent::Axis(Fixed::from_f64(val as f64 * PX_PER_SCROLL), axis)); + seat.mouse_event(InputEvent::Axis( + Fixed::from_f64(val as f64 * PX_PER_SCROLL), + axis, + )); seat.mouse_event(InputEvent::Frame); } } else { diff --git a/src/client/objects.rs b/src/client/objects.rs index 5c69cc99..ef32eac9 100644 --- a/src/client/objects.rs +++ b/src/client/objects.rs @@ -11,7 +11,7 @@ use { wl_output::WlOutput, wl_region::WlRegion, wl_registry::WlRegistry, - wl_seat::WlSeat, + wl_seat::{wl_pointer::WlPointer, WlSeat}, wl_surface::{ xdg_surface::{xdg_toplevel::XdgToplevel, XdgSurface}, WlSurface, @@ -26,15 +26,13 @@ use { copyhashmap::{CopyHashMap, Locked}, }, wire::{ - WlBufferId, WlDataSourceId, WlOutputId, WlRegionId, WlRegistryId, WlSeatId, - WlSurfaceId, XdgPositionerId, XdgSurfaceId, XdgToplevelId, XdgWmBaseId, + WlBufferId, WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId, + WlSeatId, WlSurfaceId, XdgPositionerId, XdgSurfaceId, XdgToplevelId, XdgWmBaseId, ZwpPrimarySelectionSourceV1Id, }, }, std::{cell::RefCell, mem, ops::DerefMut, rc::Rc}, }; -use crate::ifs::wl_seat::wl_pointer::WlPointer; -use crate::wire::WlPointerId; pub struct Objects { pub display: CloneCell>>, diff --git a/src/globals.rs b/src/globals.rs index 397806e7..2871382d 100644 --- a/src/globals.rs +++ b/src/globals.rs @@ -13,7 +13,9 @@ use { wl_drm::WlDrmGlobal, wl_output::WlOutputGlobal, wl_registry::WlRegistry, - wl_seat::WlSeatGlobal, + wl_seat::{ + zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1Global, WlSeatGlobal, + }, wl_shm::WlShmGlobal, wl_subcompositor::WlSubcompositorGlobal, wp_presentation::WpPresentationGlobal, @@ -39,7 +41,6 @@ use { }, thiserror::Error, }; -use crate::ifs::wl_seat::zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1Global; #[derive(Debug, Error)] pub enum GlobalsError { diff --git a/src/ifs/wl_seat.rs b/src/ifs/wl_seat.rs index 806980e4..e5aabd67 100644 --- a/src/ifs/wl_seat.rs +++ b/src/ifs/wl_seat.rs @@ -28,6 +28,7 @@ use { wl_keyboard::{WlKeyboard, WlKeyboardError, REPEAT_INFO_SINCE}, wl_pointer::WlPointer, wl_touch::WlTouch, + zwp_relative_pointer_v1::ZwpRelativePointerV1, }, wl_surface::WlSurface, }, @@ -50,7 +51,7 @@ use { }, wire::{ wl_seat::*, WlDataDeviceId, WlKeyboardId, WlPointerId, WlSeatId, - ZwpPrimarySelectionDeviceV1Id, + ZwpPrimarySelectionDeviceV1Id, ZwpRelativePointerV1Id, }, xkbcommon::{XkbKeymap, XkbState}, }, @@ -67,8 +68,6 @@ use { thiserror::Error, uapi::{c, Errno, OwnedFd}, }; -use crate::ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1; -use crate::wire::ZwpRelativePointerV1Id; const POINTER: u32 = 1; const KEYBOARD: u32 = 2; diff --git a/src/ifs/wl_seat/event_handling.rs b/src/ifs/wl_seat/event_handling.rs index 45346f46..111ec5ca 100644 --- a/src/ifs/wl_seat/event_handling.rs +++ b/src/ifs/wl_seat/event_handling.rs @@ -16,6 +16,7 @@ use { AXIS_SOURCE_SINCE_VERSION, AXIS_STOP_SINCE_VERSION, POINTER_FRAME_SINCE_VERSION, WHEEL_TILT, WHEEL_TILT_SINCE_VERSION, }, + zwp_relative_pointer_v1::ZwpRelativePointerV1, Dnd, SeatId, WlSeat, WlSeatGlobal, CHANGE_CURSOR_MOVED, }, wl_surface::{xdg_surface::xdg_popup::XdgPopup, WlSurface}, @@ -33,7 +34,6 @@ use { smallvec::SmallVec, std::rc::Rc, }; -use crate::ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1; #[derive(Default)] pub struct NodeSeatState { @@ -156,7 +156,13 @@ impl WlSeatGlobal { match event { InputEvent::Key(k, s) => self.key_event(k, s), InputEvent::ConnectorPosition(o, x, y) => self.connector_position_event(o, x, y), - InputEvent::Motion { dx, dy, dx_unaccelerated, dy_unaccelerated, time_usec } => self.motion_event(time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated), + InputEvent::Motion { + dx, + dy, + dx_unaccelerated, + dy_unaccelerated, + time_usec, + } => self.motion_event(time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated), InputEvent::Button(b, s) => self.pointer_owner.button(self, b, s), InputEvent::AxisSource(s) => self.pointer_owner.axis_source(s), @@ -184,8 +190,22 @@ impl WlSeatGlobal { self.set_new_position(x, y); } - fn motion_event(self: &Rc, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) { - self.pointer_owner.relative_motion(self, time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated); + fn motion_event( + self: &Rc, + time_usec: u64, + dx: Fixed, + dy: Fixed, + dx_unaccelerated: Fixed, + dy_unaccelerated: Fixed, + ) { + self.pointer_owner.relative_motion( + self, + time_usec, + dx, + dy, + dx_unaccelerated, + dy_unaccelerated, + ); let (mut x, mut y) = self.pos.get(); x += dx; y += dy; @@ -329,8 +349,8 @@ impl WlSeatGlobal { } fn for_each_pointer(&self, ver: u32, client: ClientId, mut f: C) - where - C: FnMut(&Rc), + where + C: FnMut(&Rc), { self.for_each_seat(ver, client, |seat| { let pointers = seat.pointers.lock(); @@ -397,8 +417,8 @@ impl WlSeatGlobal { } fn surface_pointer_event(&self, ver: u32, surface: &WlSurface, mut f: F) - where - F: FnMut(&Rc), + where + F: FnMut(&Rc), { let client = &surface.client; self.for_each_pointer(ver, client.id, |p| { @@ -518,7 +538,15 @@ impl WlSeatGlobal { // Relative motion callbacks impl WlSeatGlobal { - pub fn relative_motion_surface(&self, surface: &WlSurface, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) { + pub fn relative_motion_surface( + &self, + surface: &WlSurface, + time_usec: u64, + dx: Fixed, + dy: Fixed, + dx_unaccelerated: Fixed, + dy_unaccelerated: Fixed, + ) { self.surface_relative_pointer_event(surface, |p| { p.send_relative_motion(time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated); }); diff --git a/src/ifs/wl_seat/pointer_owner.rs b/src/ifs/wl_seat/pointer_owner.rs index e5ed775f..4a2de702 100644 --- a/src/ifs/wl_seat/pointer_owner.rs +++ b/src/ifs/wl_seat/pointer_owner.rs @@ -58,9 +58,24 @@ impl PointerOwnerHolder { } } - pub fn relative_motion(&self, seat: &Rc, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) { + pub fn relative_motion( + &self, + seat: &Rc, + time_usec: u64, + dx: Fixed, + dy: Fixed, + dx_unaccelerated: Fixed, + dy_unaccelerated: Fixed, + ) { if let Some(n) = self.owner.get().axis_node(seat) { - n.node_on_pointer_relative_motion(seat, time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated); + n.node_on_pointer_relative_motion( + seat, + time_usec, + dx, + dy, + dx_unaccelerated, + dy_unaccelerated, + ); } } diff --git a/src/ifs/wl_seat/zwp_relative_pointer_manager_v1.rs b/src/ifs/wl_seat/zwp_relative_pointer_manager_v1.rs index 3b37fbcd..9f0cf69f 100644 --- a/src/ifs/wl_seat/zwp_relative_pointer_manager_v1.rs +++ b/src/ifs/wl_seat/zwp_relative_pointer_manager_v1.rs @@ -1,13 +1,16 @@ -use std::rc::Rc; -use thiserror::Error; -use crate::client::{Client, ClientError}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::{MsgParser, MsgParserError}; -use crate::wire::ZwpRelativePointerManagerV1Id; -use crate::wire::zwp_relative_pointer_manager_v1::*; +use { + crate::{ + client::{Client, ClientError}, + globals::{Global, GlobalName}, + ifs::wl_seat::zwp_relative_pointer_v1::ZwpRelativePointerV1, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{zwp_relative_pointer_manager_v1::*, ZwpRelativePointerManagerV1Id}, + }, + std::rc::Rc, + thiserror::Error, +}; pub struct ZwpRelativePointerManagerV1Global { pub name: GlobalName, @@ -41,7 +44,11 @@ impl ZwpRelativePointerManagerV1Global { } } -global_base!(ZwpRelativePointerManagerV1Global, ZwpRelativePointerManagerV1, ZwpRelativePointerManagerV1Error); +global_base!( + ZwpRelativePointerManagerV1Global, + ZwpRelativePointerManagerV1, + ZwpRelativePointerManagerV1Error +); impl Global for ZwpRelativePointerManagerV1Global { fn singleton(&self) -> bool { @@ -62,7 +69,10 @@ impl ZwpRelativePointerManagerV1 { Ok(()) } - fn get_relative_pointer(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpRelativePointerManagerV1Error> { + fn get_relative_pointer( + &self, + parser: MsgParser<'_, '_>, + ) -> Result<(), ZwpRelativePointerManagerV1Error> { let req: GetRelativePointer = self.client.parse(self, parser)?; let pointer = self.client.lookup(req.pointer)?; let rp = Rc::new(ZwpRelativePointerV1 { diff --git a/src/ifs/wl_seat/zwp_relative_pointer_v1.rs b/src/ifs/wl_seat/zwp_relative_pointer_v1.rs index 46c1ecc1..e853e705 100644 --- a/src/ifs/wl_seat/zwp_relative_pointer_v1.rs +++ b/src/ifs/wl_seat/zwp_relative_pointer_v1.rs @@ -1,13 +1,16 @@ -use std::rc::Rc; -use thiserror::Error; -use crate::client::{Client, ClientError}; -use crate::fixed::Fixed; -use crate::ifs::wl_seat::{WlSeat}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::{MsgParser, MsgParserError}; -use crate::wire::ZwpRelativePointerV1Id; -use crate::wire::zwp_relative_pointer_v1::*; +use { + crate::{ + client::{Client, ClientError}, + fixed::Fixed, + ifs::wl_seat::WlSeat, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{zwp_relative_pointer_v1::*, ZwpRelativePointerV1Id}, + }, + std::rc::Rc, + thiserror::Error, +}; pub struct ZwpRelativePointerV1 { pub id: ZwpRelativePointerV1Id, @@ -17,7 +20,14 @@ pub struct ZwpRelativePointerV1 { } impl ZwpRelativePointerV1 { - pub fn send_relative_motion(&self, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) { + pub fn send_relative_motion( + &self, + time_usec: u64, + dx: Fixed, + dy: Fixed, + dx_unaccelerated: Fixed, + dy_unaccelerated: Fixed, + ) { self.client.event(RelativeMotion { self_id: self.id, utime_hi: (time_usec >> 32) as u32, diff --git a/src/ifs/wl_surface.rs b/src/ifs/wl_surface.rs index 6a6a195e..901341ac 100644 --- a/src/ifs/wl_surface.rs +++ b/src/ifs/wl_surface.rs @@ -796,7 +796,15 @@ impl Node for WlSurface { seat.motion_surface(&*self, x, y) } - fn node_on_pointer_relative_motion(&self, seat: &Rc, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) { + fn node_on_pointer_relative_motion( + &self, + seat: &Rc, + time_usec: u64, + dx: Fixed, + dy: Fixed, + dx_unaccelerated: Fixed, + dy_unaccelerated: Fixed, + ) { seat.relative_motion_surface(self, time_usec, dx, dy, dx_unaccelerated, dy_unaccelerated); } diff --git a/src/libinput/event.rs b/src/libinput/event.rs index 5974e4e6..90514e54 100644 --- a/src/libinput/event.rs +++ b/src/libinput/event.rs @@ -9,14 +9,14 @@ use { libinput_event_keyboard_get_key_state, libinput_event_keyboard_get_time_usec, libinput_event_pointer, libinput_event_pointer_get_button, libinput_event_pointer_get_button_state, libinput_event_pointer_get_dx, - libinput_event_pointer_get_dy, libinput_event_pointer_get_scroll_value, + libinput_event_pointer_get_dx_unaccelerated, libinput_event_pointer_get_dy, + libinput_event_pointer_get_dy_unaccelerated, libinput_event_pointer_get_scroll_value, libinput_event_pointer_get_scroll_value_v120, libinput_event_pointer_get_time_usec, libinput_event_pointer_has_axis, }, }, std::marker::PhantomData, }; -use crate::libinput::sys::{libinput_event_pointer_get_dx_unaccelerated, libinput_event_pointer_get_dy_unaccelerated}; pub struct LibInputEvent<'a> { pub(super) event: *mut libinput_event, diff --git a/src/tree.rs b/src/tree.rs index 346675d2..8a55483f 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -198,7 +198,15 @@ pub trait Node: 'static { let _ = y; } - fn node_on_pointer_relative_motion(&self, seat: &Rc, time_usec: u64, dx: Fixed, dy: Fixed, dx_unaccelerated: Fixed, dy_unaccelerated: Fixed) { + fn node_on_pointer_relative_motion( + &self, + seat: &Rc, + time_usec: u64, + dx: Fixed, + dy: Fixed, + dx_unaccelerated: Fixed, + dy_unaccelerated: Fixed, + ) { let _ = seat; let _ = time_usec; let _ = dx; diff --git a/src/tree/toplevel.rs b/src/tree/toplevel.rs index 56854470..798f55ac 100644 --- a/src/tree/toplevel.rs +++ b/src/tree/toplevel.rs @@ -1,7 +1,7 @@ use { crate::{ client::Client, - ifs::wl_seat::{collect_kb_foci, NodeSeatState, SeatId}, + ifs::wl_seat::{collect_kb_foci, collect_kb_foci2, NodeSeatState, SeatId}, rect::Rect, state::State, tree::{ContainingNode, Node, OutputNode, PlaceholderNode, WorkspaceNode}, @@ -14,7 +14,6 @@ use { rc::Rc, }, }; -use crate::ifs::wl_seat::collect_kb_foci2; tree_id!(ToplevelNodeId);