From 03dad26c43f91cf4c985fb0a7dafa8f3ef48b746 Mon Sep 17 00:00:00 2001 From: Pavel Strakhov Date: Fri, 24 Oct 2025 12:07:10 +0100 Subject: [PATCH] x11: ignore mouse scroll button release events --- winit-x11/src/event_processor.rs | 21 ++++++++++++--------- winit/src/changelog/unreleased.md | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/winit-x11/src/event_processor.rs b/winit-x11/src/event_processor.rs index 69c99e61..068e3f6b 100644 --- a/winit-x11/src/event_processor.rs +++ b/winit-x11/src/event_processor.rs @@ -1020,16 +1020,19 @@ impl EventProcessor { // 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..=7 => WindowEvent::MouseWheel { - device_id, - delta: match event.detail { - 4 => MouseScrollDelta::LineDelta(0.0, 1.0), - 5 => MouseScrollDelta::LineDelta(0.0, -1.0), - 6 => MouseScrollDelta::LineDelta(1.0, 0.0), - 7 => MouseScrollDelta::LineDelta(-1.0, 0.0), - _ => unreachable!(), + 4..=7 => match state { + ElementState::Pressed => WindowEvent::MouseWheel { + device_id, + delta: match event.detail { + 4 => MouseScrollDelta::LineDelta(0.0, 1.0), + 5 => MouseScrollDelta::LineDelta(0.0, -1.0), + 6 => MouseScrollDelta::LineDelta(1.0, 0.0), + 7 => MouseScrollDelta::LineDelta(-1.0, 0.0), + _ => unreachable!(), + }, + phase: TouchPhase::Moved, }, - phase: TouchPhase::Moved, + ElementState::Released => return, }, 8 => WindowEvent::PointerButton { device_id, diff --git a/winit/src/changelog/unreleased.md b/winit/src/changelog/unreleased.md index 7b166c41..4cf24e99 100644 --- a/winit/src/changelog/unreleased.md +++ b/winit/src/changelog/unreleased.md @@ -269,3 +269,4 @@ changelog entry. - On Windows 11, prevent incorrect shifting when dragging window onto a monitor with different DPI. - On Web, device events are emitted regardless of cursor type. - On Wayland, `axis_value120` scroll events now generate `MouseScrollDelta::LineDelta` +- On X11, mouse scroll button events no longer cause duplicated `WindowEvent::MouseWheel` events.