diff --git a/src/capture/wayland.rs b/src/capture/wayland.rs index 043db5e..9f2b82c 100644 --- a/src/capture/wayland.rs +++ b/src/capture/wayland.rs @@ -111,6 +111,7 @@ struct State { qh: QueueHandle, pending_events: VecDeque<(ClientHandle, Event)>, output_info: Vec<(WlOutput, OutputInfo)>, + scroll_discrete_pending: bool, } struct Inner { @@ -351,6 +352,7 @@ impl WaylandInputCapture { read_guard: None, pending_events: VecDeque::new(), output_info: vec![], + scroll_discrete_pending: false, }; // dispatch registry to () again, in order to read all wl_outputs @@ -752,17 +754,25 @@ impl Dispatch for State { } wl_pointer::Event::Axis { time, axis, value } => { let (_, client) = app.focused.as_ref().unwrap(); - app.pending_events.push_back(( - *client, - Event::Pointer(PointerEvent::Axis { - time, - axis: u32::from(axis) as u8, - value, - }), - )); + if app.scroll_discrete_pending { + // each axisvalue120 event is coupled with + // a corresponding axis event, which needs to + // be ignored to not duplicate the scrolling + app.scroll_discrete_pending = false; + } else { + app.pending_events.push_back(( + *client, + Event::Pointer(PointerEvent::Axis { + time, + axis: u32::from(axis) as u8, + value, + }), + )); + } } wl_pointer::Event::AxisValue120 { axis, value120 } => { let (_, client) = app.focused.as_ref().unwrap(); + app.scroll_discrete_pending = true; app.pending_events.push_back(( *client, Event::Pointer(PointerEvent::AxisDiscrete120 {