mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
Simplify/deduplicate hot corner computation
This commit is contained in:
+13
-27
@@ -29,7 +29,7 @@ use smithay::input::touch::{
|
|||||||
};
|
};
|
||||||
use smithay::input::SeatHandler;
|
use smithay::input::SeatHandler;
|
||||||
use smithay::output::Output;
|
use smithay::output::Output;
|
||||||
use smithay::utils::{Logical, Point, Rectangle, Size, Transform, SERIAL_COUNTER};
|
use smithay::utils::{Logical, Point, Rectangle, Transform, SERIAL_COUNTER};
|
||||||
use smithay::wayland::keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitor;
|
use smithay::wayland::keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitor;
|
||||||
use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint};
|
use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraint};
|
||||||
use smithay::wayland::selection::data_device::DnDGrab;
|
use smithay::wayland::selection::data_device::DnDGrab;
|
||||||
@@ -2295,20 +2295,13 @@ impl State {
|
|||||||
|
|
||||||
pointer.frame(self);
|
pointer.frame(self);
|
||||||
|
|
||||||
// contents_under() will return no surface when the hot corner should trigger.
|
// contents_under() will return no surface when the hot corner should trigger, so
|
||||||
let hot_corners = self.niri.config.borrow().gestures.hot_corners;
|
// pointer.motion() will set the current focus to None.
|
||||||
if !hot_corners.off
|
if under.hot_corner && pointer.current_focus().is_none() {
|
||||||
&& pointer.current_focus().is_none()
|
if !was_inside_hot_corner {
|
||||||
&& !self.niri.screenshot_ui.is_open()
|
self.niri.layout.toggle_overview();
|
||||||
{
|
|
||||||
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.pointer_inside_hot_corner = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activate a new confinement if necessary.
|
// Activate a new confinement if necessary.
|
||||||
@@ -2384,20 +2377,13 @@ impl State {
|
|||||||
|
|
||||||
pointer.frame(self);
|
pointer.frame(self);
|
||||||
|
|
||||||
// contents_under() will return no surface when the hot corner should trigger.
|
// contents_under() will return no surface when the hot corner should trigger, so
|
||||||
let hot_corners = self.niri.config.borrow().gestures.hot_corners;
|
// pointer.motion() will set the current focus to None.
|
||||||
if !hot_corners.off
|
if under.hot_corner && pointer.current_focus().is_none() {
|
||||||
&& pointer.current_focus().is_none()
|
if !was_inside_hot_corner {
|
||||||
&& !self.niri.screenshot_ui.is_open()
|
self.niri.layout.toggle_overview();
|
||||||
{
|
|
||||||
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.pointer_inside_hot_corner = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.niri.maybe_activate_pointer_constraint();
|
self.niri.maybe_activate_pointer_constraint();
|
||||||
|
|||||||
@@ -528,6 +528,8 @@ pub struct PointContents {
|
|||||||
pub window: Option<(Window, HitType)>,
|
pub window: Option<(Window, HitType)>,
|
||||||
// If surface belongs to a layer surface, this is that layer surface.
|
// If surface belongs to a layer surface, this is that layer surface.
|
||||||
pub layer: Option<LayerSurface>,
|
pub layer: Option<LayerSurface>,
|
||||||
|
// Pointer is over a hot corner.
|
||||||
|
pub hot_corner: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
@@ -3403,6 +3405,7 @@ impl Niri {
|
|||||||
if !hot_corners.off {
|
if !hot_corners.off {
|
||||||
let hot_corner = Rectangle::from_size(Size::from((1., 1.)));
|
let hot_corner = Rectangle::from_size(Size::from((1., 1.)));
|
||||||
if hot_corner.contains(pos_within_output) {
|
if hot_corner.contains(pos_within_output) {
|
||||||
|
rv.hot_corner = true;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user