partition.rs (1344B)
1 use crate::identify::Ident; 2 use crate::identify::Identify; 3 use crate::identify::Index; 4 5 use winsys::geometry::Region; 6 use winsys::screen::Screen; 7 8 #[derive(Clone)] 9 pub struct Partition { 10 screen: Screen, 11 index: Index, 12 } 13 14 impl Partition { 15 pub fn new( 16 screen: Screen, 17 index: Index, 18 ) -> Self { 19 Self { 20 screen, 21 index, 22 } 23 } 24 25 #[inline] 26 pub fn screen(&self) -> &Screen { 27 &self.screen 28 } 29 30 #[inline] 31 pub fn index(&self) -> Index { 32 self.index 33 } 34 35 #[inline] 36 pub fn full_region(&self) -> Region { 37 self.screen.full_region() 38 } 39 40 #[inline] 41 pub fn placeable_region(&self) -> Region { 42 self.screen.placeable_region() 43 } 44 } 45 46 impl Identify for Partition { 47 #[inline(always)] 48 fn id(&self) -> Ident { 49 self.screen.number() as Ident 50 } 51 } 52 53 impl PartialEq for Partition { 54 fn eq( 55 &self, 56 other: &Self, 57 ) -> bool { 58 self.screen.number() == other.screen.number() 59 } 60 } 61 62 #[allow(unused)] 63 impl std::fmt::Debug for Partition { 64 fn fmt( 65 &self, 66 f: &mut std::fmt::Formatter<'_>, 67 ) -> std::fmt::Result { 68 f.debug_struct("Partition") 69 .field("screen", &self.screen) 70 .field("workspace", &self.index) 71 .finish() 72 } 73 }