From eb2dce1b530584496034bc6d7f14e9b29a487faf Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 23 Feb 2024 14:40:56 +0400 Subject: Fix default width fixed not being honored with borders --- src/layout/mod.rs | 27 ++++++++++++--------------- src/layout/workspace.rs | 6 +++++- 2 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 4fc8021a..61bdaa8d 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -534,13 +534,12 @@ impl Layout { width: Option, is_full_width: bool, ) -> Option<&Output> { - let width = width.unwrap_or_else(|| { - let mut width = window.size().w; + let mut width = width.unwrap_or_else(|| ColumnWidth::Fixed(window.size().w)); + if let ColumnWidth::Fixed(w) = &mut width { if !self.options.border.off { - width += self.options.border.width as i32 * 2; + *w += self.options.border.width as i32 * 2; } - ColumnWidth::Fixed(width) - }); + } match &mut self.monitor_set { MonitorSet::Normal { @@ -591,13 +590,12 @@ impl Layout { width: Option, is_full_width: bool, ) -> Option<&Output> { - let width = width.unwrap_or_else(|| { - let mut width = window.size().w; + let mut width = width.unwrap_or_else(|| ColumnWidth::Fixed(window.size().w)); + if let ColumnWidth::Fixed(w) = &mut width { if !self.options.border.off { - width += self.options.border.width as i32 * 2; + *w += self.options.border.width as i32 * 2; } - ColumnWidth::Fixed(width) - }); + } match &mut self.monitor_set { MonitorSet::Normal { monitors, .. } => { @@ -628,13 +626,12 @@ impl Layout { width: Option, is_full_width: bool, ) { - let width = width.unwrap_or_else(|| { - let mut width = window.size().w; + let mut width = width.unwrap_or_else(|| ColumnWidth::Fixed(window.size().w)); + if let ColumnWidth::Fixed(w) = &mut width { if !self.options.border.off { - width += self.options.border.width as i32 * 2; + *w += self.options.border.width as i32 * 2; } - ColumnWidth::Fixed(width) - }); + } let MonitorSet::Normal { monitors, diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 79889ef2..2f11cc4f 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -335,10 +335,14 @@ impl Workspace { pub fn new_window_size(&self, width: Option) -> Size { let width = if let Some(width) = width { + let is_fixed = matches!(width, ColumnWidth::Fixed(_)); + let mut width = width.resolve(&self.options, self.working_area.size.w); - if !self.options.border.off { + + if !is_fixed && !self.options.border.off { width -= self.options.border.width as i32 * 2; } + max(1, width) } else { 0 -- cgit