From bc1dc1fd634a6b348093ba5799a5474e85ec9453 Mon Sep 17 00:00:00 2001 From: Lassi Pulkkinen Date: Thu, 3 Feb 2022 12:46:29 +0200 Subject: [PATCH] On Wayland, report unaccelerated mouse deltas in `DeviceEvent::MouseMotion` --- CHANGELOG.md | 1 + .../linux/wayland/seat/pointer/handlers.rs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34824dcf..7c013879 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre # Unreleased +- On Wayland, report unaccelerated mouse deltas in `DeviceEvent::MouseMotion`. - **Breaking:** Bump `ndk` version to 0.6, ndk-sys to `v0.3`, `ndk-glue` to `0.6`. - Remove no longer needed `WINIT_LINK_COLORSYNC` environment variable. - **Breaking:** Rename the `Exit` variant of `ControlFlow` to `ExitWithCode`, which holds a value to control the exit code after running. Add an `Exit` constant which aliases to `ExitWithCode(0)` instead to avoid major breakage. This shouldn't affect most existing programs. diff --git a/src/platform_impl/linux/wayland/seat/pointer/handlers.rs b/src/platform_impl/linux/wayland/seat/pointer/handlers.rs index 8c2474a9..56c64799 100644 --- a/src/platform_impl/linux/wayland/seat/pointer/handlers.rs +++ b/src/platform_impl/linux/wayland/seat/pointer/handlers.rs @@ -297,9 +297,17 @@ pub(super) fn handle_pointer( #[inline] pub(super) fn handle_relative_pointer(event: RelativePointerEvent, winit_state: &mut WinitState) { - if let RelativePointerEvent::RelativeMotion { dx, dy, .. } = event { - winit_state - .event_sink - .push_device_event(DeviceEvent::MouseMotion { delta: (dx, dy) }, DeviceId) + match event { + RelativePointerEvent::RelativeMotion { + dx_unaccel, + dy_unaccel, + .. + } => winit_state.event_sink.push_device_event( + DeviceEvent::MouseMotion { + delta: (dx_unaccel, dy_unaccel), + }, + DeviceId, + ), + _ => (), } }