From 092ca0d470b7eb2eaad791d58dc8a02b50c81f07 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 5 Apr 2024 14:19:26 -0700 Subject: [PATCH] seat/touch: Track latest `touch_down` event serial This is needed to call things like `xdg_toplevel::move` for touch events. --- src/seat/pointer/mod.rs | 2 +- src/seat/touch.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/seat/pointer/mod.rs b/src/seat/pointer/mod.rs index da920afef..a29a23748 100644 --- a/src/seat/pointer/mod.rs +++ b/src/seat/pointer/mod.rs @@ -215,7 +215,7 @@ pub(crate) struct PointerDataInner { /// The serial of the latest enter event for the pointer pub(crate) latest_enter: Option, - /// The serial of the latest enter event for the pointer + /// The serial of the latest button event for the pointer pub(crate) latest_btn: Option, } diff --git a/src/seat/touch.rs b/src/seat/touch.rs index 725314ed6..c7abbea50 100644 --- a/src/seat/touch.rs +++ b/src/seat/touch.rs @@ -25,12 +25,20 @@ impl TouchData { pub fn seat(&self) -> &WlSeat { &self.seat } + + /// Serial from the latest touch down event. + pub fn latest_down_serial(&self) -> Option { + self.inner.lock().unwrap().latest_down + } } #[derive(Debug, Default)] pub(crate) struct TouchDataInner { events: Vec, active_touch_points: Vec, + + /// The serial of the latest touch down event + latest_down: Option, } #[macro_export] @@ -171,7 +179,8 @@ where match &event { // Buffer events until frame is received. - TouchEvent::Down { id, .. } => { + TouchEvent::Down { serial, id, .. } => { + guard.latest_down = Some(*serial); save_event = true; if let Err(insert_pos) = guard.active_touch_points.binary_search(id) { guard.active_touch_points.insert(insert_pos, *id);