Reintroduce wl_seat 4 support

This commit is contained in:
Drakulix 2018-03-20 17:35:02 +01:00
parent 2fb36af926
commit daccddf9b6
3 changed files with 36 additions and 22 deletions

View File

@ -209,7 +209,7 @@ impl InputHandler<LibinputInputBackend> for LibinputInputHandler {
if let input::AxisSource::Wheel = evt.source() { if let input::AxisSource::Wheel = evt.source() {
event.discrete(axis, evt.amount() as i32); event.discrete(axis, evt.amount() as i32);
} }
// drop and submit the axis event event.done();
} }
} }
fn on_touch_down( fn on_touch_down(

View File

@ -130,7 +130,7 @@ impl InputHandler<winit::WinitInputBackend> for WinitInputHandler {
if let input::AxisSource::Wheel = evt.source() { if let input::AxisSource::Wheel = evt.source() {
event.discrete(axis, evt.amount() as i32); event.discrete(axis, evt.amount() as i32);
} }
// drop and submit the axis event event.done();
} }
} }
fn on_touch_down( fn on_touch_down(

View File

@ -73,7 +73,9 @@ impl PointerHandle {
if leave { if leave {
guard.with_focused_pointers(|pointer, surface| { guard.with_focused_pointers(|pointer, surface| {
pointer.leave(serial, surface); pointer.leave(serial, surface);
pointer.frame(); if pointer.version() >= 5 {
pointer.frame();
}
}); });
guard.focus = None; guard.focus = None;
} }
@ -84,13 +86,17 @@ impl PointerHandle {
guard.focus = surface.clone(); guard.focus = surface.clone();
guard.with_focused_pointers(|pointer, surface| { guard.with_focused_pointers(|pointer, surface| {
pointer.enter(serial, surface, x, y); pointer.enter(serial, surface, x, y);
pointer.frame(); if pointer.version() >= 5 {
pointer.frame();
}
}) })
} else { } else {
// we were on top of a surface and remained on it // we were on top of a surface and remained on it
guard.with_focused_pointers(|pointer, _| { guard.with_focused_pointers(|pointer, _| {
pointer.motion(time, x, y); pointer.motion(time, x, y);
pointer.frame(); if pointer.version() >= 5 {
pointer.frame();
}
}) })
} }
} }
@ -104,15 +110,17 @@ impl PointerHandle {
let guard = self.inner.lock().unwrap(); let guard = self.inner.lock().unwrap();
guard.with_focused_pointers(|pointer, _| { guard.with_focused_pointers(|pointer, _| {
pointer.button(serial, time, button, state); pointer.button(serial, time, button, state);
pointer.frame(); if pointer.version() >= 5 {
pointer.frame();
}
}) })
} }
/// Start an axis frame /// Start an axis frame
/// ///
/// A single frame will group multiple scroll events as if they happended in the same instance. /// A single frame will group multiple scroll events as if they happended in the same instance.
/// Dropping the returned `PointerAxisHandle` will group the events together. /// Dropping the returned `PointerAxisHandle` will group the events together.
pub fn axis<'a>(&'a self) -> PointerAxisHandle<'a> { pub fn axis<'a>(&'a self) -> PointerAxisHandle<'a> {
PointerAxisHandle { PointerAxisHandle {
inner: self.inner.lock().unwrap(), inner: self.inner.lock().unwrap(),
} }
@ -127,7 +135,7 @@ impl PointerHandle {
} }
/// A frame of pointer axis events. /// A frame of pointer axis events.
/// ///
/// Can be used with the builder pattern, e.g.: /// Can be used with the builder pattern, e.g.:
/// ```ignore /// ```ignore
/// pointer.axis() /// pointer.axis()
@ -137,32 +145,36 @@ impl PointerHandle {
/// .stop(Axis::Vertical); /// .stop(Axis::Vertical);
/// ``` /// ```
pub struct PointerAxisHandle<'a> { pub struct PointerAxisHandle<'a> {
inner: MutexGuard<'a, PointerInternal> inner: MutexGuard<'a, PointerInternal>,
} }
impl<'a> PointerAxisHandle<'a> { impl<'a> PointerAxisHandle<'a> {
/// Specify the source of the axis events /// Specify the source of the axis events
/// ///
/// This event is optional, if no source is known, you can ignore this call. /// This event is optional, if no source is known, you can ignore this call.
/// Only one source event is allowed per frame. /// Only one source event is allowed per frame.
/// ///
/// Using the `AxisSource::Finger` requires a stop event to be send, /// Using the `AxisSource::Finger` requires a stop event to be send,
/// when the user lifts off the finger (not necessarily in the same frame). /// when the user lifts off the finger (not necessarily in the same frame).
pub fn source(&mut self, source: wl_pointer::AxisSource) -> &mut Self { pub fn source(&mut self, source: wl_pointer::AxisSource) -> &mut Self {
self.inner.with_focused_pointers(|pointer, _| { self.inner.with_focused_pointers(|pointer, _| {
pointer.axis_source(source); if pointer.version() >= 5 {
pointer.axis_source(source);
}
}); });
self self
} }
/// Specify discrete scrolling steps additionally to the computed value. /// Specify discrete scrolling steps additionally to the computed value.
/// ///
/// This event is optional and gives the client additional information about /// This event is optional and gives the client additional information about
/// the nature of the axis event. E.g. a scroll wheel might issue separate steps, /// the nature of the axis event. E.g. a scroll wheel might issue separate steps,
/// while a touchpad may never issue this event as it has no steps. /// while a touchpad may never issue this event as it has no steps.
pub fn discrete(&mut self, axis: wl_pointer::Axis, steps: i32) -> &mut Self { pub fn discrete(&mut self, axis: wl_pointer::Axis, steps: i32) -> &mut Self {
self.inner.with_focused_pointers(|pointer, _| { self.inner.with_focused_pointers(|pointer, _| {
pointer.axis_discrete(axis, steps); if pointer.version() >= 5 {
pointer.axis_discrete(axis, steps);
}
}); });
self self
} }
@ -177,21 +189,23 @@ impl<'a> PointerAxisHandle<'a> {
} }
/// Notification of stop of scrolling on an axis. /// Notification of stop of scrolling on an axis.
/// ///
/// This event is required for sources of the `AxisSource::Finger` type /// This event is required for sources of the `AxisSource::Finger` type
/// and otherwise optional. /// and otherwise optional.
pub fn stop(&mut self, axis: wl_pointer::Axis, time: u32) -> &mut Self { pub fn stop(&mut self, axis: wl_pointer::Axis, time: u32) -> &mut Self {
self.inner.with_focused_pointers(|pointer, _| { self.inner.with_focused_pointers(|pointer, _| {
pointer.axis_stop(time, axis); if pointer.version() >= 5 {
pointer.axis_stop(time, axis);
}
}); });
self self
} }
}
impl<'a> Drop for PointerAxisHandle<'a> { pub fn done(&mut self) {
fn drop(&mut self) {
self.inner.with_focused_pointers(|pointer, _| { self.inner.with_focused_pointers(|pointer, _| {
pointer.frame(); if pointer.version() >= 5 {
pointer.frame();
}
}) })
} }
} }