Skip to content

Commit 5e6e999

Browse files
committed
Init hot corner pressure
only bottom left is working
1 parent 2a9d0e4 commit 5e6e999

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/input/mod.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2600,15 +2600,43 @@ impl State {
26002600
// contents_under() will return no surface when the hot corner should trigger, so
26012601
// pointer.motion() will set the current focus to None.
26022602
if under.hot_corner && pointer.current_focus().is_none() {
2603-
if !was_inside_hot_corner
2603+
// Main pressure constants
2604+
let dividend = 14.;
2605+
let pressure_cap = 20;
2606+
let target = 200;
2607+
2608+
if (!was_inside_hot_corner
26042609
&& pointer
26052610
.with_grab(|_, grab| grab_allows_hot_corner(grab))
26062611
.unwrap_or(true)
2612+
&& self.niri.hot_corner_pressure >= pressure_cap)
2613+
|| pointer
2614+
.with_grab(|_, grab| grab_allows_hot_corner(grab))
2615+
.unwrap_or(true)
2616+
&& self.niri.hot_corner_pressure > target
26072617
{
26082618
self.niri.layout.toggle_overview();
2619+
// set to minimum after trigger to avoid re-triggers without exiting
2620+
self.niri.hot_corner_pressure = i32::MIN;
2621+
info!("TRIGGERED");
2622+
}
2623+
2624+
// TODO: Only works for bottom-left right now
2625+
2626+
let vec = ((event.delta().y - event.delta().x) / dividend) as i32;
2627+
2628+
//TODO: Check addition for overflow
2629+
if vec < pressure_cap {
2630+
self.niri.hot_corner_pressure += vec;
2631+
} else {
2632+
self.niri.hot_corner_pressure += pressure_cap;
2633+
info!("Max pressure velocity reached");
26092634
}
26102635
self.niri.pointer_inside_hot_corner = true;
2636+
} else {
2637+
self.niri.hot_corner_pressure = 0;
26112638
}
2639+
info!("{}", self.niri.hot_corner_pressure);
26122640

26132641
// Activate a new confinement if necessary.
26142642
self.niri.maybe_activate_pointer_constraint();

src/niri.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ pub struct Niri {
363363
/// resolution mice.
364364
pub notified_activity_this_iteration: bool,
365365
pub pointer_inside_hot_corner: bool,
366+
pub hot_corner_pressure: i32,
366367
pub tablet_cursor_location: Option<Point<f64, Logical>>,
367368
pub gesture_swipe_3f_cumulative: Option<(f64, f64)>,
368369
pub overview_scroll_swipe_gesture: ScrollSwipeGesture,
@@ -2768,6 +2769,7 @@ impl Niri {
27682769
pointer_inactivity_timer_got_reset: false,
27692770
notified_activity_this_iteration: false,
27702771
pointer_inside_hot_corner: false,
2772+
hot_corner_pressure: 0,
27712773
tablet_cursor_location: None,
27722774
gesture_swipe_3f_cumulative: None,
27732775
overview_scroll_swipe_gesture: ScrollSwipeGesture::new(),

0 commit comments

Comments
 (0)