Skip to content

Commit

Permalink
anvil/udev: Send refresh rate based on vrr state
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Nov 25, 2024
1 parent a8a4453 commit fb5a899
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion anvil/src/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,13 @@ impl SurfaceComposition {
SurfaceComposition::Compositor(c) => c.set_debug_flags(flags),
}
}

fn vrr_enabled(&self) -> bool {
match self {
SurfaceComposition::Surface { surface, .. } => surface.vrr_enabled(),
SurfaceComposition::Compositor(c) => c.vrr_enabled(),
}
}
}

struct SurfaceData {
Expand Down Expand Up @@ -1294,7 +1301,12 @@ impl AnvilState<UdevData> {
output
.current_mode()
.map(|mode| {
Refresh::fixed(Duration::from_secs_f64(1_000f64 / mode.refresh as f64))
let rate = Duration::from_secs_f64(1_000f64 / mode.refresh as f64);
if surface.compositor.vrr_enabled() {
Refresh::variable(rate)
} else {
Refresh::fixed(rate)
}
})
.unwrap_or(Refresh::Unknown),
seq as u64,
Expand Down

0 comments on commit fb5a899

Please sign in to comment.