diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/input/mod.rs | 42 | ||||
| -rw-r--r-- | src/niri.rs | 12 |
2 files changed, 53 insertions, 1 deletions
diff --git a/src/input/mod.rs b/src/input/mod.rs index 8ab9bde1..e7c2e38f 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -29,7 +29,7 @@ use smithay::input::touch::{ }; use smithay::input::SeatHandler; use smithay::output::Output; -use smithay::utils::{Logical, Point, Rectangle, Transform, SERIAL_COUNTER}; +use smithay::utils::{Logical, Point, Rectangle, Size, Transform, SERIAL_COUNTER}; use smithay::wayland::keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitor; use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint}; use smithay::wayland::selection::data_device::DnDGrab; @@ -1995,6 +1995,10 @@ impl State { } fn on_pointer_motion<I: InputBackend>(&mut self, event: I::PointerMotionEvent) { + let was_inside_hot_corner = self.niri.pointer_inside_hot_corner; + // Any of the early returns here mean that the pointer is not inside the hot corner. + self.niri.pointer_inside_hot_corner = false; + // We need an output to be able to move the pointer. if self.niri.global_space.outputs().next().is_none() { return; @@ -2171,6 +2175,22 @@ impl State { pointer.frame(self); + // contents_under() will return no surface when the hot corner should trigger. + let hot_corners = self.niri.config.borrow().gestures.hot_corners; + if !hot_corners.off + && pointer.current_focus().is_none() + && !self.niri.screenshot_ui.is_open() + { + let hot_corner = Rectangle::from_size(Size::from((1., 1.))); + if let Some((_, pos_within_output)) = self.niri.output_under(pos) { + let inside_hot_corner = hot_corner.contains(pos_within_output); + if inside_hot_corner && !was_inside_hot_corner { + self.niri.layout.toggle_overview(); + } + self.niri.pointer_inside_hot_corner = inside_hot_corner; + } + } + // Activate a new confinement if necessary. self.niri.maybe_activate_pointer_constraint(); @@ -2195,6 +2215,10 @@ impl State { &mut self, event: I::PointerMotionAbsoluteEvent, ) { + let was_inside_hot_corner = self.niri.pointer_inside_hot_corner; + // Any of the early returns here mean that the pointer is not inside the hot corner. + self.niri.pointer_inside_hot_corner = false; + let Some(pos) = self.compute_absolute_location(&event, None).or_else(|| { self.global_bounding_rectangle().map(|output_geo| { event.position_transformed(output_geo.size) + output_geo.loc.to_f64() @@ -2240,6 +2264,22 @@ impl State { pointer.frame(self); + // contents_under() will return no surface when the hot corner should trigger. + let hot_corners = self.niri.config.borrow().gestures.hot_corners; + if !hot_corners.off + && pointer.current_focus().is_none() + && !self.niri.screenshot_ui.is_open() + { + let hot_corner = Rectangle::from_size(Size::from((1., 1.))); + if let Some((_, pos_within_output)) = self.niri.output_under(pos) { + let inside_hot_corner = hot_corner.contains(pos_within_output); + if inside_hot_corner && !was_inside_hot_corner { + self.niri.layout.toggle_overview(); + } + self.niri.pointer_inside_hot_corner = inside_hot_corner; + } + } + self.niri.maybe_activate_pointer_constraint(); // We moved the pointer, show it. diff --git a/src/niri.rs b/src/niri.rs index 225a3702..fd317f2b 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -347,6 +347,7 @@ pub struct Niri { /// Used for limiting the notify to once per iteration, so that it's not spammed with high /// resolution mice. pub notified_activity_this_iteration: bool, + pub pointer_inside_hot_corner: bool, pub tablet_cursor_location: Option<Point<f64, Logical>>, pub gesture_swipe_3f_cumulative: Option<(f64, f64)>, pub overview_scroll_swipe_gesture: ScrollSwipeGesture, @@ -2427,6 +2428,7 @@ impl Niri { pointer_inactivity_timer: None, pointer_inactivity_timer_got_reset: false, notified_activity_this_iteration: false, + pointer_inside_hot_corner: false, tablet_cursor_location: None, gesture_swipe_3f_cumulative: None, overview_scroll_swipe_gesture: ScrollSwipeGesture::new(), @@ -2920,6 +2922,11 @@ impl Niri { return false; } + let hot_corner = Rectangle::from_size(Size::from((1., 1.))); + if hot_corner.contains(pos_within_output) { + return true; + } + if layer_popup_under(Layer::Top) || layer_toplevel_under(Layer::Top) { return true; } @@ -3175,6 +3182,11 @@ impl Niri { .or_else(|| layer_toplevel_under(Layer::Bottom)) .or_else(|| layer_toplevel_under(Layer::Background)); } else { + let hot_corner = Rectangle::from_size(Size::from((1., 1.))); + if hot_corner.contains(pos_within_output) { + return rv; + } + under = under .or_else(|| layer_popup_under(Layer::Top)) .or_else(|| layer_toplevel_under(Layer::Top)); |
