Fix refresh passed to presentation feedback

This commit is contained in:
Ivan Molodetskikh
2023-09-04 14:26:55 +04:00
parent 786e0fa4f0
commit 59a6119f46
2 changed files with 22 additions and 15 deletions
+18 -15
View File
@@ -320,12 +320,27 @@ impl Tty {
.unwrap()
.message(&message, 0);
let output = data
.state
.niri
.global_space
.outputs()
.find(|output| {
let tty_state: &TtyOutputState = output.user_data().get().unwrap();
tty_state.device_id == device.id && tty_state.crtc == crtc
})
.unwrap()
.clone();
let output_state = data.state.niri.output_state.get_mut(&output).unwrap();
// Mark the last frame as submitted.
match surface.compositor.frame_submitted() {
Ok(Some(mut feedback)) => {
let refresh =
feedback.output().unwrap().current_mode().unwrap().refresh
as u32;
let refresh = output_state
.frame_clock
.refresh_interval_ns()
.and_then(|r| u32::try_from(r.get()).ok())
.unwrap_or(0);
// FIXME: ideally should be monotonically increasing for a surface.
let seq = metadata.as_ref().unwrap().sequence as u64;
let flags = wp_presentation_feedback::Kind::Vsync
@@ -345,18 +360,6 @@ impl Tty {
}
}
let output = data
.state
.niri
.global_space
.outputs()
.find(|output| {
let tty_state: &TtyOutputState = output.user_data().get().unwrap();
tty_state.device_id == device.id && tty_state.crtc == crtc
})
.unwrap()
.clone();
let output_state = data.state.niri.output_state.get_mut(&output).unwrap();
output_state.waiting_for_vblank = false;
output_state.frame_clock.presented(presentation_time);
data.state.niri.queue_redraw(output);
+4
View File
@@ -24,6 +24,10 @@ impl FrameClock {
}
}
pub fn refresh_interval_ns(&self) -> Option<NonZeroU64> {
self.refresh_interval_ns
}
pub fn presented(&mut self, presentation_time: Duration) {
if presentation_time.is_zero() {
// Not interested in these.