From 19190a95a0d882e4fd816d5fde9b8897afa29d31 Mon Sep 17 00:00:00 2001 From: Andriy <75628709+JustLinuxUser@users.noreply.github.com> Date: Tue, 20 Feb 2024 10:34:05 +0100 Subject: [PATCH] On Wayland, send DeviceEvent::Motion --- CHANGELOG.md | 1 + .../wayland/seat/pointer/relative_pointer.rs | 41 +++++++++++++------ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 289c921d..1d447ae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Unreleased` header. # Unreleased +- On Wayland, fix DeviceEvent::Motion not being sent - On X11, don't require XIM to run. - On X11, fix xkb state not being updated correctly sometimes leading to wrong input. - Fix compatibility with 32-bit platforms without 64-bit atomics. diff --git a/src/platform_impl/linux/wayland/seat/pointer/relative_pointer.rs b/src/platform_impl/linux/wayland/seat/pointer/relative_pointer.rs index 23a6e219..f7364e37 100644 --- a/src/platform_impl/linux/wayland/seat/pointer/relative_pointer.rs +++ b/src/platform_impl/linux/wayland/seat/pointer/relative_pointer.rs @@ -60,19 +60,34 @@ impl Dispatch for RelativePointerS _conn: &Connection, _qhandle: &QueueHandle, ) { - if let zwp_relative_pointer_v1::Event::RelativeMotion { - dx_unaccel, - dy_unaccel, - .. - } = event - { - state.events_sink.push_device_event( - DeviceEvent::MouseMotion { - delta: (dx_unaccel, dy_unaccel), - }, - super::DeviceId, - ); - } + let (dx_unaccel, dy_unaccel) = match event { + zwp_relative_pointer_v1::Event::RelativeMotion { + dx_unaccel, + dy_unaccel, + .. + } => (dx_unaccel, dy_unaccel), + _ => return, + }; + state.events_sink.push_device_event( + DeviceEvent::Motion { + axis: 0, + value: dx_unaccel, + }, + super::DeviceId, + ); + state.events_sink.push_device_event( + DeviceEvent::Motion { + axis: 1, + value: dy_unaccel, + }, + super::DeviceId, + ); + state.events_sink.push_device_event( + DeviceEvent::MouseMotion { + delta: (dx_unaccel, dy_unaccel), + }, + super::DeviceId, + ); } }