output-configuration: Add vrr state
This commit is contained in:
parent
4b71674e10
commit
98ec82db77
4 changed files with 68 additions and 2 deletions
|
|
@ -8,10 +8,16 @@ pub use crate::shell::{SeatExt, Shell, Workspace};
|
|||
pub use crate::state::{Common, State};
|
||||
pub use crate::wayland::handlers::xdg_shell::popup::update_reactive_popups;
|
||||
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
pub trait OutputExt {
|
||||
fn geometry(&self) -> Rectangle<i32, Global>;
|
||||
fn adaptive_sync(&self) -> bool;
|
||||
fn set_adaptive_sync(&self, vrr: bool);
|
||||
}
|
||||
|
||||
struct Vrr(AtomicBool);
|
||||
|
||||
impl OutputExt for Output {
|
||||
fn geometry(&self) -> Rectangle<i32, Global> {
|
||||
Rectangle::from_loc_and_size(self.current_location(), {
|
||||
|
|
@ -27,4 +33,20 @@ impl OutputExt for Output {
|
|||
})
|
||||
.as_global()
|
||||
}
|
||||
|
||||
fn adaptive_sync(&self) -> bool {
|
||||
self.user_data()
|
||||
.get::<Vrr>()
|
||||
.map(|vrr| vrr.0.load(Ordering::SeqCst))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
fn set_adaptive_sync(&self, vrr: bool) {
|
||||
let user_data = self.user_data();
|
||||
user_data.insert_if_missing_threadsafe(|| Vrr(AtomicBool::new(false)));
|
||||
user_data
|
||||
.get::<Vrr>()
|
||||
.unwrap()
|
||||
.0
|
||||
.store(vrr, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue