From c508d68d1d0cc79d002c97e3a6f5c3b9632929b9 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sun, 30 Jul 2017 11:40:52 -0700 Subject: [PATCH] Fix evdev emulated scroll events When X's evdev input module is configured to emulate scroll events (as used with e.g. trackpoints), it generates non-emulated scroll button presses and does not generate motion events. This is contrary to the behavior of all other hardware I've tested, and contrary to the behavior of libinput, but nonetheless should be supported. --- src/platform/linux/x11/mod.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/platform/linux/x11/mod.rs b/src/platform/linux/x11/mod.rs index 86458547..f655ce48 100644 --- a/src/platform/linux/x11/mod.rs +++ b/src/platform/linux/x11/mod.rs @@ -370,7 +370,19 @@ impl EventsLoop { // Suppress emulated scroll wheel clicks, since we handle the real motion events for those. // In practice, even clicky scroll wheels appear to be reported by evdev (and XInput2 in // turn) as axis motion, so we don't otherwise special-case these button presses. - 4 | 5 | 6 | 7 if xev.flags & ffi::XIPointerEmulated != 0 => {} + 4 | 5 | 6 | 7 => if xev.flags & ffi::XIPointerEmulated == 0 { + callback(Event::WindowEvent { window_id: wid, event: MouseWheel { + device_id: did, + delta: match xev.detail { + 4 => LineDelta(0.0, 1.0), + 5 => LineDelta(0.0, -1.0), + 6 => LineDelta(-1.0, 0.0), + 7 => LineDelta(1.0, 0.0), + _ => unreachable!() + }, + phase: TouchPhase::Moved, + }}); + }, x => callback(Event::WindowEvent { window_id: wid, event: MouseInput { device_id: did, state: state, button: Other(x as u8) } }) }