Fix refresh passed to presentation feedback
Browse files at this commit59a6119f46e40bf5a87cd4d533a8a223569e8e84Parent: 786e0fa2 changed files +22 -15
- src/backend/tty.rs +18 -15
- src/frame_clock.rs +4 -0
src/backend/tty.rsmodified+18 -15
| @@ -320,12 +320,27 @@ impl Tty { | |||
| 320 | .unwrap() | 320 | .unwrap() |
| 321 | .message(&message, 0); | 321 | .message(&message, 0); |
| 322 | 322 | ||
| 323 | + let output = data | ||
| 324 | + .state | ||
| 325 | + .niri | ||
| 326 | + .global_space | ||
| 327 | + .outputs() | ||
| 328 | + .find(|output| { | ||
| 329 | + let tty_state: &TtyOutputState = output.user_data().get().unwrap(); | ||
| 330 | + tty_state.device_id == device.id && tty_state.crtc == crtc | ||
| 331 | + }) | ||
| 332 | + .unwrap() | ||
| 333 | + .clone(); | ||
| 334 | + let output_state = data.state.niri.output_state.get_mut(&output).unwrap(); | ||
| 335 | + | ||
| 323 | // Mark the last frame as submitted. | 336 | // Mark the last frame as submitted. |
| 324 | match surface.compositor.frame_submitted() { | 337 | match surface.compositor.frame_submitted() { |
| 325 | Ok(Some(mut feedback)) => { | 338 | Ok(Some(mut feedback)) => { |
| 326 | - let refresh = | 339 | + let refresh = output_state |
| 327 | - feedback.output().unwrap().current_mode().unwrap().refresh | 340 | + .frame_clock |
| 328 | - as u32; | 341 | + .refresh_interval_ns() |
| 342 | + .and_then(|r| u32::try_from(r.get()).ok()) | ||
| 343 | + .unwrap_or(0); | ||
| 329 | // FIXME: ideally should be monotonically increasing for a surface. | 344 | // FIXME: ideally should be monotonically increasing for a surface. |
| 330 | let seq = metadata.as_ref().unwrap().sequence as u64; | 345 | let seq = metadata.as_ref().unwrap().sequence as u64; |
| 331 | let flags = wp_presentation_feedback::Kind::Vsync | 346 | let flags = wp_presentation_feedback::Kind::Vsync |
| @@ -345,18 +360,6 @@ impl Tty { | |||
| 345 | } | 360 | } |
| 346 | } | 361 | } |
| 347 | 362 | ||
| 348 | - let output = data | ||
| 349 | - .state | ||
| 350 | - .niri | ||
| 351 | - .global_space | ||
| 352 | - .outputs() | ||
| 353 | - .find(|output| { | ||
| 354 | - let tty_state: &TtyOutputState = output.user_data().get().unwrap(); | ||
| 355 | - tty_state.device_id == device.id && tty_state.crtc == crtc | ||
| 356 | - }) | ||
| 357 | - .unwrap() | ||
| 358 | - .clone(); | ||
| 359 | - let output_state = data.state.niri.output_state.get_mut(&output).unwrap(); | ||
| 360 | output_state.waiting_for_vblank = false; | 363 | output_state.waiting_for_vblank = false; |
| 361 | output_state.frame_clock.presented(presentation_time); | 364 | output_state.frame_clock.presented(presentation_time); |
| 362 | data.state.niri.queue_redraw(output); | 365 | data.state.niri.queue_redraw(output); |
src/frame_clock.rsmodified+4 -0
| @@ -24,6 +24,10 @@ impl FrameClock { | |||
| 24 | } | 24 | } |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | + pub fn refresh_interval_ns(&self) -> Option<NonZeroU64> { | ||
| 28 | + self.refresh_interval_ns | ||
| 29 | + } | ||
| 30 | + | ||
| 27 | pub fn presented(&mut self, presentation_time: Duration) { | 31 | pub fn presented(&mut self, presentation_time: Duration) { |
| 28 | if presentation_time.is_zero() { | 32 | if presentation_time.is_zero() { |
| 29 | // Not interested in these. | 33 | // Not interested in these. |