| 1 | use x11rb::protocol::xproto::Window as XWindow; |
| 2 | |
| 3 | use super::tree::Rect; |
| 4 | |
| 5 | #[derive(Debug, Clone)] |
| 6 | pub struct Window { |
| 7 | pub id: XWindow, |
| 8 | /// Geometry for floating mode (position and size when floating) |
| 9 | pub floating_geometry: Rect, |
| 10 | /// Current actual geometry (updated by apply_layout, used for pointer warping) |
| 11 | pub current_geometry: Rect, |
| 12 | pub mapped: bool, |
| 13 | pub focused: bool, |
| 14 | pub floating: bool, |
| 15 | pub fullscreen: bool, |
| 16 | /// Saved geometry before entering fullscreen (for restore) |
| 17 | pub pre_fullscreen_geometry: Option<Rect>, |
| 18 | /// Was the window floating before entering fullscreen? |
| 19 | pub pre_fullscreen_floating: bool, |
| 20 | pub urgent: bool, |
| 21 | pub workspace: usize, |
| 22 | /// Frame window ID (if title bars are enabled, client is reparented into this) |
| 23 | pub frame: Option<XWindow>, |
| 24 | /// Window title (cached from _NET_WM_NAME or WM_NAME) |
| 25 | pub title: String, |
| 26 | /// Count of UnmapNotify events to ignore (for intentional unmaps during workspace switch) |
| 27 | pub ignore_unmap_count: u32, |
| 28 | } |
| 29 | |
| 30 | impl Window { |
| 31 | pub fn new(id: XWindow, workspace: usize) -> Self { |
| 32 | Self { |
| 33 | id, |
| 34 | floating_geometry: Rect::new(0, 0, 640, 480), |
| 35 | current_geometry: Rect::new(0, 0, 640, 480), |
| 36 | mapped: false, |
| 37 | focused: false, |
| 38 | floating: false, |
| 39 | fullscreen: false, |
| 40 | pre_fullscreen_geometry: None, |
| 41 | pre_fullscreen_floating: false, |
| 42 | urgent: false, |
| 43 | workspace, |
| 44 | frame: None, |
| 45 | title: String::new(), |
| 46 | ignore_unmap_count: 0, |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /// Get the window to configure (frame if present, otherwise client). |
| 51 | pub fn outer_window(&self) -> XWindow { |
| 52 | self.frame.unwrap_or(self.id) |
| 53 | } |
| 54 | } |
| 55 |