feature: add on-demand vrr (#586)

* feature: add on-demand vrr

* Don't require connector::Info in try_to_set_vrr

* Improve VRR help message

* Rename connector_handle => connector

* Fix tracy span name

* Move on demand vrr flag set higher

* wiki: Mention on-demand VRR

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
This commit is contained in:
Michael Yang
2024-08-22 18:58:07 +10:00
committed by GitHub
parent dfc2d452c5
commit f1894f6f9a
10 changed files with 201 additions and 66 deletions
+26 -4
View File
@@ -324,11 +324,25 @@ pub struct Output {
#[knuffel(child, unwrap(argument, str))]
pub mode: Option<ConfiguredMode>,
#[knuffel(child)]
pub variable_refresh_rate: bool,
pub variable_refresh_rate: Option<Vrr>,
#[knuffel(child, default = DEFAULT_BACKGROUND_COLOR)]
pub background_color: Color,
}
impl Output {
pub fn is_vrr_always_on(&self) -> bool {
self.variable_refresh_rate == Some(Vrr { on_demand: false })
}
pub fn is_vrr_on_demand(&self) -> bool {
self.variable_refresh_rate == Some(Vrr { on_demand: true })
}
pub fn is_vrr_always_off(&self) -> bool {
self.variable_refresh_rate.is_none()
}
}
impl Default for Output {
fn default() -> Self {
Self {
@@ -338,7 +352,7 @@ impl Default for Output {
transform: Transform::Normal,
position: None,
mode: None,
variable_refresh_rate: false,
variable_refresh_rate: None,
background_color: DEFAULT_BACKGROUND_COLOR,
}
}
@@ -352,6 +366,12 @@ pub struct Position {
pub y: i32,
}
#[derive(knuffel::Decode, Debug, Clone, PartialEq, Default)]
pub struct Vrr {
#[knuffel(property, default = false)]
pub on_demand: bool,
}
// MIN and MAX generics are only used during parsing to check the value.
#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub struct FloatOrInt<const MIN: i32, const MAX: i32>(pub f64);
@@ -896,6 +916,8 @@ pub struct WindowRule {
pub clip_to_geometry: Option<bool>,
#[knuffel(child, unwrap(argument))]
pub block_out_from: Option<BlockOutFrom>,
#[knuffel(child, unwrap(argument))]
pub variable_refresh_rate: Option<bool>,
}
// Remember to update the PartialEq impl when adding fields!
@@ -2705,7 +2727,7 @@ mod tests {
transform "flipped-90"
position x=10 y=20
mode "1920x1080@144"
variable-refresh-rate
variable-refresh-rate on-demand=true
background-color "rgba(25, 25, 102, 1.0)"
}
@@ -2889,7 +2911,7 @@ mod tests {
height: 1080,
refresh: Some(144.),
}),
variable_refresh_rate: true,
variable_refresh_rate: Some(Vrr { on_demand: true }),
background_color: Color::from_rgba8_unpremul(25, 25, 102, 255),
}]),
layout: Layout {