Skip to content

Commit

Permalink
wayland: allow to send touch frame for touch up
Browse files Browse the repository at this point in the history
sending wl_touch.frame for a wl_touch.up is valid and we
should not prevent it. wl_touch.cancel explicitly states that
no frame should be sent.
  • Loading branch information
cmeissl authored and Drakulix committed May 10, 2024
1 parent 4838c9a commit f7638e8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/input/touch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub(crate) struct TouchInternal<D: SeatHandler> {

struct TouchSlotState<D: SeatHandler> {
focus: Option<(<D as SeatHandler>::TouchFocus, Point<i32, Logical>)>,
frame_pending: Option<<D as SeatHandler>::TouchFocus>,
pending: Serial,
current: Option<Serial>,
}
Expand All @@ -91,6 +92,7 @@ impl<D: SeatHandler> fmt::Debug for TouchSlotState<D> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TouchSlotState")
.field("focus", &self.focus)
.field("frame_pending", &self.frame_pending)
.field("pending", &self.pending)
.field("current", &self.current)
.finish()
Expand Down Expand Up @@ -504,10 +506,12 @@ impl<D: SeatHandler + 'static> TouchInternal<D> {
.entry(event.slot)
.and_modify(|state| {
state.pending = seq;
state.frame_pending = None;
state.focus.clone_from(&focus);
})
.or_insert_with(|| TouchSlotState {
focus,
frame_pending: None,
pending: seq,
current: None,
});
Expand All @@ -526,6 +530,10 @@ impl<D: SeatHandler + 'static> TouchInternal<D> {
state.pending = seq;
if let Some((focus, _)) = state.focus.take() {
focus.up(seat, data, event, seq);

// Keep the focus around to be able to send a frame event after up, but move
// it out of the current focus to prevent sending other events.
state.frame_pending = Some(focus);
}
}

Expand Down Expand Up @@ -554,6 +562,12 @@ impl<D: SeatHandler + 'static> TouchInternal<D> {
continue;
}
state.current = Some(seq);

// Send the frame event for any stored focus in the up handler
if let Some(focus) = state.frame_pending.take() {
focus.frame(seat, data, seq);
}

if let Some((focus, _)) = state.focus.as_ref() {
focus.frame(seat, data, seq);
}
Expand Down

0 comments on commit f7638e8

Please sign in to comment.