diff --git a/examples/winit.rs b/examples/winit.rs index 0148c07..e7de959 100644 --- a/examples/winit.rs +++ b/examples/winit.rs @@ -16,7 +16,7 @@ use helpers::{init_shell, GliumDrawer, MyWindowMap}; use slog::{Drain, Logger}; use smithay::backend::graphics::egl::EGLGraphicsBackend; use smithay::backend::input::{self, Event, InputBackend, InputHandler, KeyboardKeyEvent, PointerButtonEvent, - PointerMotionAbsoluteEvent}; + PointerMotionAbsoluteEvent, PointerAxisEvent}; use smithay::backend::winit; use smithay::wayland::compositor::{SubsurfaceRole, TraversalAction}; use smithay::wayland::compositor::roles::Role; @@ -97,8 +97,12 @@ impl InputHandler for WinitInputHandler { }; self.pointer.button(button, state, serial, evt.time()); } - fn on_pointer_axis(&mut self, _: &input::Seat, _: winit::WinitMouseWheelEvent) { - /* not done in this example */ + fn on_pointer_axis(&mut self, _: &input::Seat, evt: winit::WinitMouseWheelEvent) { + let axis = match evt.axis() { + input::Axis::Vertical => wayland_server::protocol::wl_pointer::Axis::VerticalScroll, + input::Axis::Horizontal => wayland_server::protocol::wl_pointer::Axis::HorizontalScroll, + }; + self.pointer.axis(axis, evt.amount(), evt.time()); } fn on_touch_down(&mut self, _: &input::Seat, _: winit::WinitTouchStartedEvent) { /* not done in this example */ diff --git a/src/wayland/seat/pointer.rs b/src/wayland/seat/pointer.rs index 5c631a0..7fa87a6 100644 --- a/src/wayland/seat/pointer.rs +++ b/src/wayland/seat/pointer.rs @@ -104,7 +104,13 @@ impl PointerHandle { }) } - // TODO: handle axis + /// send axis events + pub fn axis(&self, axis: wl_pointer::Axis, value: f64, time: u32) { + let guard = self.inner.lock().unwrap(); + guard.with_focused_pointers(|pointer, _| { + pointer.axis(time, axis, value); + }) + } pub(crate) fn cleanup_old_pointers(&self) { let mut guard = self.inner.lock().unwrap();