Skip to content

Commit

Permalink
Ignore all multi-touch compositor events
Browse files Browse the repository at this point in the history
This patch increases the strictness for multi-touch events for
compositor input.

Previously when multiple touch slots were active, the first touch slot
was consumed and all others were ignored, which lead to issues with
triggering double-taps too easily.

To ensure double-taps are only activated without any other touch slots
being present in between, we now ignore **both** touch sequences when
more than one touch slot is active at the same time, rather than just
the secondary ones.
  • Loading branch information
chrisduerr committed Feb 2, 2025
1 parent 2935bf8 commit df86bf7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion catacomb_ipc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ pub fn send_message(message: &IpcMessage) -> Result<Option<IpcMessage>, Box<dyn

// Write message to socket.
let json = serde_json::to_string(&message)?;
stream.write_all(json[..].as_bytes())?;
stream.write_all(json.as_bytes())?;
stream.flush()?;

// Shutdown write, to allow reading.
Expand Down
7 changes: 3 additions & 4 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ impl TouchState {

/// Start a new touch session.
fn start(&mut self, canvas: &Canvas, slot: TouchSlot, position: Point<f64, Logical>) {
// Allow only a single touch at a time.
if self.slot.is_some() {
// Invalidate both sequences if more than one slot is active.
if self.slot.take().is_some() {
self.last_tap = None;
return;
}
Expand Down Expand Up @@ -448,8 +448,7 @@ impl Catacomb {
let canvas = self.windows.canvas();
self.touch_state.start(canvas, event.slot, event.position);
},
TouchEventType::Up if self.touch_state.slot == Some(event.slot) => {
self.touch_state.slot = None;
TouchEventType::Up if self.touch_state.slot.take() == Some(event.slot) => {
match self.touch_state.action(self.windows.canvas()) {
Some(TouchAction::Tap) => {
self.touch_state.last_tap =
Expand Down
2 changes: 1 addition & 1 deletion src/ipc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fn send_reply_fallible(
message: &IpcMessage,
) -> Result<(), Box<dyn Error>> {
let json = serde_json::to_string(&message)?;
stream.write_all(json[..].as_bytes())?;
stream.write_all(json.as_bytes())?;
stream.flush()?;
Ok(())
}
2 changes: 1 addition & 1 deletion src/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ impl Udev {
None,
allocator,
gbm.clone(),
SUPPORTED_COLOR_FORMATS.into_iter().copied(),
SUPPORTED_COLOR_FORMATS.iter().copied(),
formats,
Size::default(),
None,
Expand Down

0 comments on commit df86bf7

Please sign in to comment.