Make pointer inactivity timer reset lazy
Browse files at this commitec5144feca1fce94329b51796979c5c2e3eead24Parent: 05e0e441 changed file +15 -0
- src/niri.rs +15 -0
src/niri.rsmodified+15 -0
| @@ -329,6 +329,11 @@ pub struct Niri { | |||
| 329 | /// various tooltips from sticking around. | 329 | /// various tooltips from sticking around. |
| 330 | pub pointer_hidden: bool, | 330 | pub pointer_hidden: bool, |
| 331 | pub pointer_inactivity_timer: Option<RegistrationToken>, | 331 | pub pointer_inactivity_timer: Option<RegistrationToken>, |
| 332 | + /// Whether the pointer inactivity timer got reset this event loop iteration. | ||
| 333 | + /// | ||
| 334 | + /// Used for limiting the reset to once per iteration, so that it's not spammed with high | ||
| 335 | + /// resolution mice. | ||
| 336 | + pub pointer_inactivity_timer_got_reset: bool, | ||
| 332 | pub tablet_cursor_location: Option<Point<f64, Logical>>, | 337 | pub tablet_cursor_location: Option<Point<f64, Logical>>, |
| 333 | pub gesture_swipe_3f_cumulative: Option<(f64, f64)>, | 338 | pub gesture_swipe_3f_cumulative: Option<(f64, f64)>, |
| 334 | pub vertical_wheel_tracker: ScrollTracker, | 339 | pub vertical_wheel_tracker: ScrollTracker, |
| @@ -621,6 +626,7 @@ impl State { | |||
| 621 | 626 | ||
| 622 | // Clear the time so it's fetched afresh next iteration. | 627 | // Clear the time so it's fetched afresh next iteration. |
| 623 | self.niri.clock.clear(); | 628 | self.niri.clock.clear(); |
| 629 | + self.niri.pointer_inactivity_timer_got_reset = false; | ||
| 624 | } | 630 | } |
| 625 | 631 | ||
| 626 | fn refresh(&mut self) { | 632 | fn refresh(&mut self) { |
| @@ -1331,6 +1337,8 @@ impl State { | |||
| 1331 | } | 1337 | } |
| 1332 | 1338 | ||
| 1333 | if cursor_inactivity_timeout_changed { | 1339 | if cursor_inactivity_timeout_changed { |
| 1340 | + // Force reset due to timeout change. | ||
| 1341 | + self.niri.pointer_inactivity_timer_got_reset = false; | ||
| 1334 | self.niri.reset_pointer_inactivity_timer(); | 1342 | self.niri.reset_pointer_inactivity_timer(); |
| 1335 | } | 1343 | } |
| 1336 | 1344 | ||
| @@ -2137,6 +2145,7 @@ impl Niri { | |||
| 2137 | pointer_contents: PointContents::default(), | 2145 | pointer_contents: PointContents::default(), |
| 2138 | pointer_hidden: false, | 2146 | pointer_hidden: false, |
| 2139 | pointer_inactivity_timer: None, | 2147 | pointer_inactivity_timer: None, |
| 2148 | + pointer_inactivity_timer_got_reset: false, | ||
| 2140 | tablet_cursor_location: None, | 2149 | tablet_cursor_location: None, |
| 2141 | gesture_swipe_3f_cumulative: None, | 2150 | gesture_swipe_3f_cumulative: None, |
| 2142 | vertical_wheel_tracker: ScrollTracker::new(120), | 2151 | vertical_wheel_tracker: ScrollTracker::new(120), |
| @@ -5254,6 +5263,10 @@ impl Niri { | |||
| 5254 | } | 5263 | } |
| 5255 | 5264 | ||
| 5256 | pub fn reset_pointer_inactivity_timer(&mut self) { | 5265 | pub fn reset_pointer_inactivity_timer(&mut self) { |
| 5266 | + if self.pointer_inactivity_timer_got_reset { | ||
| 5267 | + return; | ||
| 5268 | + } | ||
| 5269 | + | ||
| 5257 | let _span = tracy_client::span!("Niri::reset_pointer_inactivity_timer"); | 5270 | let _span = tracy_client::span!("Niri::reset_pointer_inactivity_timer"); |
| 5258 | 5271 | ||
| 5259 | if let Some(token) = self.pointer_inactivity_timer.take() { | 5272 | if let Some(token) = self.pointer_inactivity_timer.take() { |
| @@ -5277,6 +5290,8 @@ impl Niri { | |||
| 5277 | }) | 5290 | }) |
| 5278 | .unwrap(); | 5291 | .unwrap(); |
| 5279 | self.pointer_inactivity_timer = Some(token); | 5292 | self.pointer_inactivity_timer = Some(token); |
| 5293 | + | ||
| 5294 | + self.pointer_inactivity_timer_got_reset = true; | ||
| 5280 | } | 5295 | } |
| 5281 | } | 5296 | } |
| 5282 | 5297 | ||