1
0
Fork 0
forked from wry/wry

metal: implement tearing

This commit is contained in:
Julian Orth 2024-07-18 15:04:02 +02:00
parent d355059ad9
commit 49f6304716
31 changed files with 726 additions and 51 deletions

View file

@ -262,6 +262,11 @@ impl Connector {
pub fn set_vrr_cursor_hz(self, hz: f64) {
get!().set_vrr_cursor_hz(Some(self), hz)
}
/// Sets the tearing mode.
pub fn set_tearing_mode(self, mode: TearingMode) {
get!().set_tearing_mode(Some(self), mode)
}
}
/// Returns all available DRM devices.
@ -580,3 +585,30 @@ pub fn set_vrr_mode(mode: VrrMode) {
pub fn set_vrr_cursor_hz(hz: f64) {
get!().set_vrr_cursor_hz(None, hz)
}
/// The tearing mode of a connector.
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
pub struct TearingMode(pub u32);
impl TearingMode {
/// Tearing is never enabled.
pub const NEVER: Self = Self(0);
/// Tearing is always enabled.
pub const ALWAYS: Self = Self(1);
/// Tearing is enabled when one or more applications are displayed fullscreen.
pub const VARIANT_1: Self = Self(2);
/// Tearing is enabled when a single application is displayed fullscreen.
pub const VARIANT_2: Self = Self(3);
/// Tearing is enabled when a single application is displayed fullscreen and the
/// application has requested tearing.
///
/// This is the default.
pub const VARIANT_3: Self = Self(4);
}
/// Sets the default tearing mode.
///
/// This setting can be overwritten on a per-connector basis with [Connector::set_tearing_mode].
pub fn set_tearing_mode(mode: TearingMode) {
get!().set_tearing_mode(None, mode)
}