diff --git a/wayrs-core/src/lib.rs b/wayrs-core/src/lib.rs index 63a38f9..7bcc7ee 100644 --- a/wayrs-core/src/lib.rs +++ b/wayrs-core/src/lib.rs @@ -139,7 +139,7 @@ impl ArgValue { } /// Signed 24.8 decimal number -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Fixed(pub i32); impl From for Fixed { @@ -167,6 +167,10 @@ impl From for Fixed { } impl Fixed { + pub const ZERO: Self = Self(0); + pub const ONE: Self = Self(256); + pub const MINUS_ONE: Self = Self(-256); + pub fn as_f64(self) -> f64 { self.0 as f64 / 256.0 } @@ -178,6 +182,10 @@ impl Fixed { pub fn as_int(self) -> i32 { self.0 / 256 } + + pub fn is_int(self) -> bool { + self.0 & 255 == 0 + } } impl fmt::Debug for Fixed {