diff options
author | tcmal <me@aria.rip> | 2024-07-15 15:30:06 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-07-15 19:18:59 +0100 |
commit | 5d2a23a5d618725b75ba77d7185601e5439801c5 (patch) | |
tree | c0d37b1e3e3bd796deab0de904b31ef5cd21e048 /src/clients/client.rs | |
parent | 641d4db398357bd50e83dc77464558acf83d9b1d (diff) |
support fullscreen mode
Diffstat (limited to 'src/clients/client.rs')
-rw-r--r-- | src/clients/client.rs | 60 |
1 files changed, 49 insertions, 11 deletions
diff --git a/src/clients/client.rs b/src/clients/client.rs index 6845e4e..84f787a 100644 --- a/src/clients/client.rs +++ b/src/clients/client.rs @@ -8,7 +8,7 @@ use xcb::{ use crate::{config::BORDER_WIDTH, conn_info::Connection}; -use super::hints; +use super::{hints, MonitorGeometry}; /// Information about a single client / window #[derive(Debug)] @@ -26,7 +26,20 @@ pub struct Client { urgent: bool, never_focus: bool, - floating: bool, + layout_mode: LayoutMode, +} + +/// How this window's geometry is determined, +#[derive(Debug)] +pub enum LayoutMode { + /// By the tiling algorithm + Tiled, + + /// By the user + Floating, + + /// By the monitor its on + Fullscreen, } impl Client { @@ -41,7 +54,7 @@ impl Client { mapped: false, urgent: false, never_focus: false, - floating: false, + layout_mode: LayoutMode::Tiled, } } @@ -107,20 +120,45 @@ impl Client { }); } - /// Whether the client is floating - outside of current tiling rules and displaying over any tiled windows - pub const fn floating(&self) -> bool { - self.floating + /// Whether the client is tiled + pub const fn tiled(&self) -> bool { + matches!(self.layout_mode, LayoutMode::Tiled) + } + + /// Set the window as tiled + pub fn set_tiled(&mut self) { + self.layout_mode = LayoutMode::Tiled; + } + + /// Set the window as floating + pub fn set_floating(&mut self, conn: &Connection<'_>) { + if !matches!(self.layout_mode, LayoutMode::Floating) { + conn.send_request(&ConfigureWindow { + window: self.window, + value_list: &[ConfigWindow::StackMode(StackMode::Above)], + }); + } + self.layout_mode = LayoutMode::Floating; } - /// Set the floating status. - pub fn set_floating(&mut self, conn: &Connection<'_>, floating: bool) { - if floating && floating != self.floating { + /// Set the window as fullscreen + pub fn set_fullscreen(&mut self, conn: &Connection<'_>, mon_geom: &MonitorGeometry) { + if !matches!(self.layout_mode, LayoutMode::Fullscreen) { conn.send_request(&ConfigureWindow { window: self.window, value_list: &[ConfigWindow::StackMode(StackMode::Above)], }); + + self.set_geom( + conn, + mon_geom.x_org, + mon_geom.y_org, + mon_geom.width, + mon_geom.height, + self.border_width, + ); } - self.floating = floating; + self.layout_mode = LayoutMode::Fullscreen; } /// Ensure this client is currently mapped / visible @@ -180,7 +218,7 @@ impl Client { pub fn update_window_type(&mut self, conn: &Connection<'_>) { // TODO: Fullscreen from net_wm_state if hints::is_dialog(conn, self.window) { - self.set_floating(conn, true); + self.set_floating(conn); } } |