Extract update_pointer_focus()
Browse files at this commitfb866c63e5d61107efb9ced46f72ae562af74fceParent: bae95751 changed file +17 -4
- src/niri.rs +17 -4
src/niri.rsmodified+17 -4
| @@ -283,12 +283,26 @@ impl State { | ||
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | + if !self.update_pointer_focus() { | |
| 287 | + return; | |
| 288 | + } | |
| 289 | + | |
| 290 | + pointer.frame(self); | |
| 291 | + // FIXME: granular | |
| 292 | + self.niri.queue_redraw_all(); | |
| 293 | + } | |
| 294 | + | |
| 295 | + pub fn update_pointer_focus(&mut self) -> bool { | |
| 296 | + let _span = tracy_client::span!("Niri::update_pointer_focus"); | |
| 297 | + | |
| 298 | + let pointer = &self.niri.seat.get_pointer().unwrap(); | |
| 299 | + let location = pointer.current_location(); | |
| 286 | 300 | let under = self.niri.surface_under_and_global_space(location); |
| 287 | 301 | |
| 288 | 302 | // We're not changing the global cursor location here, so if the focus did not change, then |
| 289 | 303 | // nothing changed. |
| 290 | 304 | if self.niri.pointer_focus == under { |
| 291 | - return; | |
| 305 | + return false; | |
| 292 | 306 | } |
| 293 | 307 | |
| 294 | 308 | self.niri.pointer_focus = under.clone(); |
| @@ -303,9 +317,8 @@ impl State { | ||
| 303 | 317 | time: get_monotonic_time().as_millis() as u32, |
| 304 | 318 | }, |
| 305 | 319 | ); |
| 306 | - pointer.frame(self); | |
| 307 | - // FIXME: granular | |
| 308 | - self.niri.queue_redraw_all(); | |
| 320 | + | |
| 321 | + true | |
| 309 | 322 | } |
| 310 | 323 | |
| 311 | 324 | pub fn move_cursor_to_output(&mut self, output: &Output) { |