diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-09-26 17:16:53 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-10-02 09:33:08 +0300 |
| commit | 67ca2cb06cce62e75ea7077f0fdaf54b9f45ea82 (patch) | |
| tree | 04905e3ae42d7dbf574d50b2a3b356ec363ded1b /src/layout/workspace.rs | |
| parent | 9ff1c90fa6a4bb962e0a9c76e18552a245177c53 (diff) | |
| download | niri-67ca2cb06cce62e75ea7077f0fdaf54b9f45ea82.tar.gz niri-67ca2cb06cce62e75ea7077f0fdaf54b9f45ea82.tar.bz2 niri-67ca2cb06cce62e75ea7077f0fdaf54b9f45ea82.zip | |
layout: Move scrolling width resolution to workspace
This is required now with per-output and per-workspace options.
Diffstat (limited to 'src/layout/workspace.rs')
| -rw-r--r-- | src/layout/workspace.rs | 24 |
1 files changed, 24 insertions, 0 deletions
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<W: LayoutElement> Workspace<W> { }); } + pub(super) fn resolve_scrolling_width( + &self, + window: &W, + width: Option<PresetSize>, + ) -> 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() |
