added scroll events to pointer and winit demo

This commit is contained in:
William W Wold 2017-10-14 17:11:04 -07:00 committed by Victor Berger
parent 50aa38df72
commit 291ba17a5c
2 changed files with 14 additions and 4 deletions

View File

@ -16,7 +16,7 @@ use helpers::{init_shell, GliumDrawer, MyWindowMap};
use slog::{Drain, Logger}; use slog::{Drain, Logger};
use smithay::backend::graphics::egl::EGLGraphicsBackend; use smithay::backend::graphics::egl::EGLGraphicsBackend;
use smithay::backend::input::{self, Event, InputBackend, InputHandler, KeyboardKeyEvent, PointerButtonEvent, use smithay::backend::input::{self, Event, InputBackend, InputHandler, KeyboardKeyEvent, PointerButtonEvent,
PointerMotionAbsoluteEvent}; PointerMotionAbsoluteEvent, PointerAxisEvent};
use smithay::backend::winit; use smithay::backend::winit;
use smithay::wayland::compositor::{SubsurfaceRole, TraversalAction}; use smithay::wayland::compositor::{SubsurfaceRole, TraversalAction};
use smithay::wayland::compositor::roles::Role; use smithay::wayland::compositor::roles::Role;
@ -97,8 +97,12 @@ impl InputHandler<winit::WinitInputBackend> for WinitInputHandler {
}; };
self.pointer.button(button, state, serial, evt.time()); self.pointer.button(button, state, serial, evt.time());
} }
fn on_pointer_axis(&mut self, _: &input::Seat, _: winit::WinitMouseWheelEvent) { fn on_pointer_axis(&mut self, _: &input::Seat, evt: winit::WinitMouseWheelEvent) {
/* not done in this example */ 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) { fn on_touch_down(&mut self, _: &input::Seat, _: winit::WinitTouchStartedEvent) {
/* not done in this example */ /* not done in this example */

View File

@ -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) { pub(crate) fn cleanup_old_pointers(&self) {
let mut guard = self.inner.lock().unwrap(); let mut guard = self.inner.lock().unwrap();