From 2317021a7c4a7296606533d38f1fdce96826f7dc Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 23 Feb 2024 13:57:56 +0400 Subject: Implement explicit unmapped window state tracking --- src/layout/mod.rs | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'src/layout/mod.rs') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index edc0d9de..c7239a2b 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -531,15 +531,10 @@ impl Layout { pub fn add_window( &mut self, window: W, - width: Option>, + width: Option, is_full_width: bool, ) -> Option<&Output> { - let width = match width { - Some(Some(width)) => Some(width), - Some(None) => None, - None => self.options.default_width, - } - .unwrap_or_else(|| ColumnWidth::Fixed(window.size().w)); + let width = width.unwrap_or_else(|| ColumnWidth::Fixed(window.size().w)); match &mut self.monitor_set { MonitorSet::Normal { @@ -587,15 +582,10 @@ impl Layout { &mut self, right_of: &W, window: W, - width: Option>, + width: Option, is_full_width: bool, ) -> Option<&Output> { - let width = match width { - Some(Some(width)) => Some(width), - Some(None) => None, - None => self.options.default_width, - } - .unwrap_or_else(|| ColumnWidth::Fixed(window.size().w)); + let width = width.unwrap_or_else(|| ColumnWidth::Fixed(window.size().w)); match &mut self.monitor_set { MonitorSet::Normal { monitors, .. } => { @@ -623,15 +613,10 @@ impl Layout { &mut self, output: &Output, window: W, - width: Option>, + width: Option, is_full_width: bool, ) { - let width = match width { - Some(Some(width)) => Some(width), - Some(None) => None, - None => self.options.default_width, - } - .unwrap_or_else(|| ColumnWidth::Fixed(window.size().w)); + let width = width.unwrap_or_else(|| ColumnWidth::Fixed(window.size().w)); let MonitorSet::Normal { monitors, @@ -931,6 +916,19 @@ impl Layout { Some(&mut monitors[*active_monitor_idx]) } + pub fn active_monitor_ref(&self) -> Option<&Monitor> { + let MonitorSet::Normal { + monitors, + active_monitor_idx, + .. + } = &self.monitor_set + else { + return None; + }; + + Some(&monitors[*active_monitor_idx]) + } + pub fn monitor_for_output(&self, output: &Output) -> Option<&Monitor> { let MonitorSet::Normal { monitors, .. } = &self.monitor_set else { return None; -- cgit