forge
Explore
Log in

Don't you dare go Hollow

Simplify/deduplicate hot corner computation

Browse files at this commit

c9e85a0fe2b423da55453417d1202c3fa95efe60Ivan MolodetskikhParent: 0a8b4e0
src/input/mod.rsmodified+13 -27
@@ -29,7 +29,7 @@ use smithay::input::touch::{
29 };29 };
30 use smithay::input::SeatHandler;30 use smithay::input::SeatHandler;
31 use smithay::output::Output;31 use smithay::output::Output;
32-use smithay::utils::{Logical, Point, Rectangle, Size, Transform, SERIAL_COUNTER};32+use smithay::utils::{Logical, Point, Rectangle, Transform, SERIAL_COUNTER};
33 use smithay::wayland::keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitor;33 use smithay::wayland::keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitor;
34 use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint};34 use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint};
35 use smithay::wayland::selection::data_device::DnDGrab;35 use smithay::wayland::selection::data_device::DnDGrab;
@@ -2295,20 +2295,13 @@ impl State {
2295 2295
2296 pointer.frame(self);2296 pointer.frame(self);
2297 2297
2298- // contents_under() will return no surface when the hot corner should trigger.2298+ // contents_under() will return no surface when the hot corner should trigger, so
2299- let hot_corners = self.niri.config.borrow().gestures.hot_corners;2299+ // pointer.motion() will set the current focus to None.
2300- if !hot_corners.off2300+ if under.hot_corner && pointer.current_focus().is_none() {
2301- && pointer.current_focus().is_none()2301+ if !was_inside_hot_corner {
2302- && !self.niri.screenshot_ui.is_open()2302+ self.niri.layout.toggle_overview();
2303- {
2304- let hot_corner = Rectangle::from_size(Size::from((1., 1.)));
2305- if let Some((_, pos_within_output)) = self.niri.output_under(pos) {
2306- let inside_hot_corner = hot_corner.contains(pos_within_output);
2307- if inside_hot_corner && !was_inside_hot_corner {
2308- self.niri.layout.toggle_overview();
2309- }
2310- self.niri.pointer_inside_hot_corner = inside_hot_corner;
2311 }2303 }
2304+ self.niri.pointer_inside_hot_corner = true;
2312 }2305 }
2313 2306
2314 // Activate a new confinement if necessary.2307 // Activate a new confinement if necessary.
@@ -2384,20 +2377,13 @@ impl State {
2384 2377
2385 pointer.frame(self);2378 pointer.frame(self);
2386 2379
2387- // contents_under() will return no surface when the hot corner should trigger.2380+ // contents_under() will return no surface when the hot corner should trigger, so
2388- let hot_corners = self.niri.config.borrow().gestures.hot_corners;2381+ // pointer.motion() will set the current focus to None.
2389- if !hot_corners.off2382+ if under.hot_corner && pointer.current_focus().is_none() {
2390- && pointer.current_focus().is_none()2383+ if !was_inside_hot_corner {
2391- && !self.niri.screenshot_ui.is_open()2384+ self.niri.layout.toggle_overview();
2392- {
2393- let hot_corner = Rectangle::from_size(Size::from((1., 1.)));
2394- if let Some((_, pos_within_output)) = self.niri.output_under(pos) {
2395- let inside_hot_corner = hot_corner.contains(pos_within_output);
2396- if inside_hot_corner && !was_inside_hot_corner {
2397- self.niri.layout.toggle_overview();
2398- }
2399- self.niri.pointer_inside_hot_corner = inside_hot_corner;
2400 }2385 }
2386+ self.niri.pointer_inside_hot_corner = true;
2401 }2387 }
2402 2388
2403 self.niri.maybe_activate_pointer_constraint();2389 self.niri.maybe_activate_pointer_constraint();
src/niri.rsmodified+3 -0
@@ -528,6 +528,8 @@ pub struct PointContents {
528 pub window: Option<(Window, HitType)>,528 pub window: Option<(Window, HitType)>,
529 // If surface belongs to a layer surface, this is that layer surface.529 // If surface belongs to a layer surface, this is that layer surface.
530 pub layer: Option<LayerSurface>,530 pub layer: Option<LayerSurface>,
531+ // Pointer is over a hot corner.
532+ pub hot_corner: bool,
531 }533 }
532 534
533 #[derive(Debug, Default)]535 #[derive(Debug, Default)]
@@ -3403,6 +3405,7 @@ impl Niri {
3403 if !hot_corners.off {3405 if !hot_corners.off {
3404 let hot_corner = Rectangle::from_size(Size::from((1., 1.)));3406 let hot_corner = Rectangle::from_size(Size::from((1., 1.)));
3405 if hot_corner.contains(pos_within_output) {3407 if hot_corner.contains(pos_within_output) {
3408+ rv.hot_corner = true;
3406 return rv;3409 return rv;
3407 }3410 }
3408 }3411 }