mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Make idle notify lazy
This commit is contained in:
+1
-1
@@ -478,7 +478,7 @@ impl Tty {
|
||||
|
||||
self.refresh_ipc_outputs(niri);
|
||||
|
||||
niri.idle_notifier_state.notify_activity(&niri.seat);
|
||||
niri.notify_activity();
|
||||
niri.monitors_active = true;
|
||||
self.set_monitors_active(true);
|
||||
niri.queue_redraw_all();
|
||||
|
||||
+1
-3
@@ -451,9 +451,7 @@ impl SessionLockHandler for State {
|
||||
fn unlock(&mut self) {
|
||||
self.niri.unlock();
|
||||
self.niri.activate_monitors(&mut self.backend);
|
||||
self.niri
|
||||
.idle_notifier_state
|
||||
.notify_activity(&self.niri.seat);
|
||||
self.niri.notify_activity();
|
||||
}
|
||||
|
||||
fn new_surface(&mut self, surface: LockSurface, output: WlOutput) {
|
||||
|
||||
+2
-7
@@ -97,10 +97,7 @@ impl State {
|
||||
if self.niri.monitors_active {
|
||||
// Notify the idle-notifier of activity.
|
||||
if should_notify_activity(&event) {
|
||||
let _span = tracy_client::span!("IdleNotifierState::notify_activity");
|
||||
self.niri
|
||||
.idle_notifier_state
|
||||
.notify_activity(&self.niri.seat);
|
||||
self.niri.notify_activity();
|
||||
}
|
||||
} else {
|
||||
// Power on monitors if they were off.
|
||||
@@ -109,9 +106,7 @@ impl State {
|
||||
|
||||
// Notify the idle-notifier of activity only if we're also powering on the
|
||||
// monitors.
|
||||
self.niri
|
||||
.idle_notifier_state
|
||||
.notify_activity(&self.niri.seat);
|
||||
self.niri.notify_activity();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+19
@@ -334,6 +334,11 @@ pub struct Niri {
|
||||
/// Used for limiting the reset to once per iteration, so that it's not spammed with high
|
||||
/// resolution mice.
|
||||
pub pointer_inactivity_timer_got_reset: bool,
|
||||
/// Whether the (idle notifier) activity was notified this event loop iteration.
|
||||
///
|
||||
/// 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 tablet_cursor_location: Option<Point<f64, Logical>>,
|
||||
pub gesture_swipe_3f_cumulative: Option<(f64, f64)>,
|
||||
pub vertical_wheel_tracker: ScrollTracker,
|
||||
@@ -627,6 +632,7 @@ impl State {
|
||||
// Clear the time so it's fetched afresh next iteration.
|
||||
self.niri.clock.clear();
|
||||
self.niri.pointer_inactivity_timer_got_reset = false;
|
||||
self.niri.notified_activity_this_iteration = false;
|
||||
}
|
||||
|
||||
fn refresh(&mut self) {
|
||||
@@ -2146,6 +2152,7 @@ impl Niri {
|
||||
pointer_hidden: false,
|
||||
pointer_inactivity_timer: None,
|
||||
pointer_inactivity_timer_got_reset: false,
|
||||
notified_activity_this_iteration: false,
|
||||
tablet_cursor_location: None,
|
||||
gesture_swipe_3f_cumulative: None,
|
||||
vertical_wheel_tracker: ScrollTracker::new(120),
|
||||
@@ -5293,6 +5300,18 @@ impl Niri {
|
||||
|
||||
self.pointer_inactivity_timer_got_reset = true;
|
||||
}
|
||||
|
||||
pub fn notify_activity(&mut self) {
|
||||
if self.notified_activity_this_iteration {
|
||||
return;
|
||||
}
|
||||
|
||||
let _span = tracy_client::span!("Niri::notify_activity");
|
||||
|
||||
self.idle_notifier_state.notify_activity(&self.seat);
|
||||
|
||||
self.notified_activity_this_iteration = true;
|
||||
}
|
||||
}
|
||||
|
||||
pub struct NewClient {
|
||||
|
||||
Reference in New Issue
Block a user