diff options
| author | abmantis <amfcalt@gmail.com> | 2025-07-13 15:49:08 +0100 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-07-14 06:48:56 +0300 |
| commit | 51b6a495c5ab701bb3ef4d1180e4fe190acc4f60 (patch) | |
| tree | f221965e5a0d7dde37868674bd75c6be7c1d86ed /src | |
| parent | bb40a35ccf6edbe2c838686562cbdad1ef98ce72 (diff) | |
| download | niri-51b6a495c5ab701bb3ef4d1180e4fe190acc4f60.tar.gz niri-51b6a495c5ab701bb3ef4d1180e4fe190acc4f60.tar.bz2 niri-51b6a495c5ab701bb3ef4d1180e4fe190acc4f60.zip | |
Simplify pointer handling in constraint check
Minor change so that `get_pointer()` (which has a lock) does not get
called twice. Also moved the call to `current_location()` to the scope
where it is needed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/niri.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/niri.rs b/src/niri.rs index cb4306c6..9bc83302 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -5769,18 +5769,16 @@ impl Niri { /// /// Make sure the pointer location and contents are up to date before calling this. pub fn maybe_activate_pointer_constraint(&self) { - let pointer = self.seat.get_pointer().unwrap(); - let pointer_pos = pointer.current_location(); - let Some((surface, surface_loc)) = &self.pointer_contents.surface else { return; }; + + let pointer = self.seat.get_pointer().unwrap(); if Some(surface) != pointer.current_focus().as_ref() { return; } - let pointer = &self.seat.get_pointer().unwrap(); - with_pointer_constraint(surface, pointer, |constraint| { + with_pointer_constraint(surface, &pointer, |constraint| { let Some(constraint) = constraint else { return }; if constraint.is_active() { @@ -5789,6 +5787,7 @@ impl Niri { // Constraint does not apply if not within region. if let Some(region) = constraint.region() { + let pointer_pos = pointer.current_location(); let pos_within_surface = pointer_pos - *surface_loc; if !region.contains(pos_within_surface.to_i32_round()) { return; |
