diff --git a/compositor/src/input.rs b/compositor/src/input.rs index f2602c0..08cdf70 100644 --- a/compositor/src/input.rs +++ b/compositor/src/input.rs @@ -153,7 +153,20 @@ impl Ferese { utime: (event.time_msec() as u64).saturating_mul(1_000), }, ); + let requested = self.clamp_pointer_position(position + delta); + let location = self.constrain_pointer_position(&pointer, requested); + + pointer.motion( + self, + self.surface_under(location), + &MotionEvent { + location, + serial: SERIAL_COUNTER.next_serial(), + time: event.time() as u32, + }, + ); pointer.frame(self); + self.activate_focused_pointer_constraint(&pointer); } InputEvent::PointerButton { event, .. } => { let pointer = self.seat.get_pointer().expect("seat has a pointer"); @@ -245,6 +258,26 @@ impl Ferese { }); } + fn clamp_pointer_position(&self, requested: Point) -> Point { + let Some(output) = self.space.outputs().next() else { + return requested; + }; + let Some(geometry) = self.space.output_geometry(output) else { + return requested; + }; + + Point::from(( + requested.x.clamp( + f64::from(geometry.loc.x), + f64::from(geometry.loc.x + geometry.size.w - 1), + ), + requested.y.clamp( + f64::from(geometry.loc.y), + f64::from(geometry.loc.y + geometry.size.h - 1), + ), + )) + } + fn constrain_pointer_position( &self, pointer: &PointerHandle,