From f5d91c5ecc8d2f8ee0e7dd03889844f46e480026 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 3 Nov 2024 09:16:06 +0300 Subject: Rename pointer_focus to pointer_contents, clarify comments This is not pointer focus and it shouldn't be pointer focus, let's be clear about it. --- src/handlers/mod.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/handlers') diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index ed9f224c..a60de97f 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -140,7 +140,7 @@ impl PointerConstraintsHandler for State { fn new_constraint(&mut self, _surface: &WlSurface, pointer: &PointerHandle) { self.niri.maybe_activate_pointer_constraint( pointer.current_location(), - &self.niri.pointer_focus, + &self.niri.pointer_contents, ); } @@ -158,19 +158,20 @@ impl PointerConstraintsHandler for State { return; } - // Logically the following two checks should always succeed (so, they should print - // error!()s if they fail). However, currently both can fail because niri's pointer focus - // doesn't take pointer grabs into account. So if you start, say, a middle-drag in Blender, - // then touchpad-swipe the window away, the niri pointer focus will change, even though the - // real pointer focus remains on the Blender surface due to the click grab. + // Note: this is surface under pointer, not pointer focus. So if you start, say, a + // middle-drag in Blender, then touchpad-swipe the window away, the surface under pointer + // will change, even though the real pointer focus remains on the Blender surface due to + // the click grab. // - // FIXME: add error!()s when niri pointer focus takes grabs into account. Alternatively, - // recompute the surface origin here (but that is a bit clunky). - let Some((ref focused_surface, origin)) = self.niri.pointer_focus.surface else { + // Ideally we would just use the constraint surface, but we need its origin. So this is + // more of a hack because pointer contents has the surface origin available. + // + // FIXME: use the constraint surface somehow, don't use pointer contents. + let Some((ref surface_under_pointer, origin)) = self.niri.pointer_contents.surface else { return; }; - if focused_surface != surface { + if surface_under_pointer != surface { return; } -- cgit