fix(touch): hand on a touch lift without waiting for the next frame (Issues #28, #55)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
haraldandClaude Opus 5.5 committed 2026-11-09 22:34:27 +01:00
1 parent ab0f49199b
commit 7bd3d9e82f
2 files changed
+39 -3

No files matched your search

+4
View File
@@ -22,6 +22,10 @@ docs of the original crate were removed.
the app (`AboutToWait`), also when the events belong to another queue on the same connection.
octotablet's pen events live on such a queue and only `dispatch_pending` it, so before, pen
strokes waited until something else woke the loop (Issue #53).
- `src/platform_impl/linux/wayland/seat/touch/mod.rs`: a touch lift (`wl_touch.up`) is handed
on right away instead of waiting for the next `wl_touch.frame`. On a GNOME laptop the lift
of a swipe only arrived with the next touch, which fits a frame sent before the lift: the page did not glide after a
swipe (Issue #28), and a ruler moved with the finger followed the hovering pen (Issue #55).
- `Cargo.toml`: `[lints.rust] warnings = "allow"`, because a path dependency is not built with
capped lints like a crates.io dependency.
@@ -2,14 +2,15 @@
use sctk::reexports::client::protocol::wl_seat::WlSeat;
use sctk::reexports::client::protocol::wl_surface::WlSurface;
use sctk::reexports::client::protocol::wl_touch::WlTouch;
use sctk::reexports::client::{Connection, Proxy, QueueHandle};
use sctk::reexports::client::protocol::wl_touch::{self, WlTouch};
use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle};
use sctk::reexports::csd_frame::FrameClick;
use std::time::Duration;
use sctk::compositor::SurfaceData;
use sctk::seat::touch::{TouchData, TouchHandler};
use sctk::seat::SeatState;
use crate::dpi::LogicalPosition;
use crate::event::{Touch, TouchPhase, WindowEvent};
@@ -286,4 +287,35 @@ impl TouchDataExt for WlTouch {
}
}
sctk::delegate_touch!(WinitState);
// ink-notes patch: sctk holds every touch event back until the compositor sends the
// `wl_touch.frame` that closes its group. On a GNOME laptop the lift of a swipe only arrived
// together with the next touch, which fits a frame sent before the matching `up`: the page could
// not glide (Issue #28) and a ruler moved with the finger followed the hovering pen (Issue #55).
// A lift is now handed on right away, after the events that came before it.
impl Dispatch<WlTouch, TouchData> for WinitState {
fn event(
state: &mut Self,
touch: &WlTouch,
event: wl_touch::Event,
data: &TouchData,
conn: &Connection,
qh: &QueueHandle<Self>,
) {
if let wl_touch::Event::Up { serial, time, id } = event {
// Hand on what sctk still holds, then the lift itself
<SeatState as Dispatch<WlTouch, TouchData, Self>>::event(
state,
touch,
wl_touch::Event::Frame,
data,
conn,
qh,
);
state.up(conn, qh, touch, serial, time, id);
} else {
<SeatState as Dispatch<WlTouch, TouchData, Self>>::event(
state, touch, event, data, conn, qh,
);
}
}
}