From 5de4f0962ff4b238a67adde999e4a19ee7f12cb0 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Fri, 22 Jul 2022 13:11:57 +0200 Subject: [PATCH] input: don't send motion events when cursor is locked --- src/ifs/wl_seat/event_handling.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ifs/wl_seat/event_handling.rs b/src/ifs/wl_seat/event_handling.rs index 9fca68df..7192f971 100644 --- a/src/ifs/wl_seat/event_handling.rs +++ b/src/ifs/wl_seat/event_handling.rs @@ -624,8 +624,15 @@ impl WlSeatGlobal { // Motion callbacks impl WlSeatGlobal { pub fn motion_surface(&self, n: &WlSurface, x: Fixed, y: Fixed) { - let time = (self.pos_time_usec.get() / 1000) as u32; - self.surface_pointer_event(0, n, |p| p.send_motion(time, x, y)); + 'send_motion: { + if let Some(constraint) = self.constraint.get() { + if constraint.ty == ConstraintType::Lock { + break 'send_motion; + } + } + let time = (self.pos_time_usec.get() / 1000) as u32; + self.surface_pointer_event(0, n, |p| p.send_motion(time, x, y)); + } self.surface_pointer_frame(n); self.maybe_constrain(n, x, y); }