Skip to content

Commit

Permalink
seat/touch: Track latest touch_down event serial
Browse files Browse the repository at this point in the history
This is needed to call things like `xdg_toplevel::move` for touch
events.
  • Loading branch information
ids1024 committed Apr 5, 2024
1 parent 3bed072 commit 092ca0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/seat/pointer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ pub(crate) struct PointerDataInner {
/// The serial of the latest enter event for the pointer
pub(crate) latest_enter: Option<u32>,

/// 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<u32>,
}

Expand Down
11 changes: 10 additions & 1 deletion src/seat/touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32> {
self.inner.lock().unwrap().latest_down
}
}

#[derive(Debug, Default)]
pub(crate) struct TouchDataInner {
events: Vec<TouchEvent>,
active_touch_points: Vec<i32>,

/// The serial of the latest touch down event
latest_down: Option<u32>,
}

#[macro_export]
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 092ca0d

Please sign in to comment.