forge
Explore
Log in

Don't you dare go Hollow

Avoid triggering hot corner during some grabs

Browse files at this commit

94eeecac8c67b2b3f03536bbe4f74b4030afcea8Ivan MolodetskikhParent: 739834d
src/input/mod.rsmodified+30 -3
@@ -22,7 +22,7 @@ use smithay::input::pointer::{
22 AxisFrame, ButtonEvent, CursorIcon, CursorImageStatus, Focus, GestureHoldBeginEvent,22 AxisFrame, ButtonEvent, CursorIcon, CursorImageStatus, Focus, GestureHoldBeginEvent,
23 GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,23 GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
24 GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,24 GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
25- GrabStartData as PointerGrabStartData, MotionEvent, RelativeMotionEvent,25+ GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, RelativeMotionEvent,
26 };26 };
27 use smithay::input::touch::{27 use smithay::input::touch::{
28 DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent, UpEvent,28 DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent, UpEvent,
@@ -2366,7 +2366,11 @@ impl State {
2366 // contents_under() will return no surface when the hot corner should trigger, so2366 // contents_under() will return no surface when the hot corner should trigger, so
2367 // pointer.motion() will set the current focus to None.2367 // pointer.motion() will set the current focus to None.
2368 if under.hot_corner && pointer.current_focus().is_none() {2368 if under.hot_corner && pointer.current_focus().is_none() {
2369- if !was_inside_hot_corner {2369+ if !was_inside_hot_corner
2370+ && pointer
2371+ .with_grab(|_, grab| grab_allows_hot_corner(grab))
2372+ .unwrap_or(true)
2373+ {
2370 self.niri.layout.toggle_overview();2374 self.niri.layout.toggle_overview();
2371 }2375 }
2372 self.niri.pointer_inside_hot_corner = true;2376 self.niri.pointer_inside_hot_corner = true;
@@ -2448,7 +2452,11 @@ impl State {
2448 // contents_under() will return no surface when the hot corner should trigger, so2452 // contents_under() will return no surface when the hot corner should trigger, so
2449 // pointer.motion() will set the current focus to None.2453 // pointer.motion() will set the current focus to None.
2450 if under.hot_corner && pointer.current_focus().is_none() {2454 if under.hot_corner && pointer.current_focus().is_none() {
2451- if !was_inside_hot_corner {2455+ if !was_inside_hot_corner
2456+ && pointer
2457+ .with_grab(|_, grab| grab_allows_hot_corner(grab))
2458+ .unwrap_or(true)
2459+ {
2452 self.niri.layout.toggle_overview();2460 self.niri.layout.toggle_overview();
2453 }2461 }
2454 self.niri.pointer_inside_hot_corner = true;2462 self.niri.pointer_inside_hot_corner = true;
@@ -4669,6 +4677,25 @@ pub fn mods_with_finger_scroll_binds(mod_key: ModKey, binds: &Binds) -> HashSet<
4669 )4677 )
4670 }4678 }
4671 4679
4680+fn grab_allows_hot_corner(grab: &(dyn PointerGrab<State> + 'static)) -> bool {
4681+ let grab = grab.as_any();
4682+
4683+ // We lean on the blocklist approach here since it's not a terribly big deal if hot corner
4684+ // works where it shouldn't, but it could prevent some workflows if the hot corner doesn't work
4685+ // when it should.
4686+ //
4687+ // Some notable grabs not mentioned here:
4688+ // - DnDGrab allows hot corner to DnD across workspaces.
4689+ // - MoveGrab allows hot corner to DnD across workspaces.
4690+ // - ClickGrab keeps pointer focus on the window, so the hot corner doesn't trigger.
4691+ // - Touch grabs: touch doesn't trigger the hot corner.
4692+ if grab.is::<ResizeGrab>() || grab.is::<SpatialMovementGrab>() {
4693+ return false;
4694+ }
4695+
4696+ true
4697+}
4698+
4672 #[cfg(test)]4699 #[cfg(test)]
4673 mod tests {4700 mod tests {
4674 use std::cell::Cell;4701 use std::cell::Cell;