From 67ca2cb06cce62e75ea7077f0fdaf54b9f45ea82 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 26 Sep 2025 17:16:53 +0300 Subject: layout: Move scrolling width resolution to workspace This is required now with per-output and per-workspace options. --- src/layout/workspace.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/layout/workspace.rs') diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 3831ffe3..5bdd2624 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -2,6 +2,7 @@ use std::cmp::max; use std::rc::Rc; use std::time::Duration; +use niri_config::utils::MergeWith as _; use niri_config::{ CenterFocusedColumn, CornerRadius, OutputName, PresetSize, Workspace as WorkspaceConfig, }; @@ -882,6 +883,29 @@ impl Workspace { }); } + pub(super) fn resolve_scrolling_width( + &self, + window: &W, + width: Option, + ) -> ColumnWidth { + let width = width.unwrap_or_else(|| PresetSize::Fixed(window.size().w)); + match width { + PresetSize::Fixed(fixed) => { + let mut fixed = f64::from(fixed); + + // Add border width since ColumnWidth includes borders. + let rules = window.rules(); + let border = self.options.layout.border.merged_with(&rules.border); + if !border.off { + fixed += border.width * 2.; + } + + ColumnWidth::Fixed(fixed) + } + PresetSize::Proportion(prop) => ColumnWidth::Proportion(prop), + } + } + pub fn focus_left(&mut self) -> bool { if self.floating_is_active.get() { self.floating.focus_left() -- cgit