From 1515410012842c419e8bc3de717b8a51b1a0b45c Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 6 Feb 2025 09:09:07 +0300 Subject: Add default-column-display window rule --- niri-config/src/lib.rs | 4 ++++ src/layout/scrolling.rs | 8 +++++++- src/window/mod.rs | 9 +++++++++ wiki/Configuration:-Window-Rules.md | 22 ++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index 39e42357..62678781 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -1113,6 +1113,8 @@ pub struct WindowRule { pub block_out_from: Option, #[knuffel(child, unwrap(argument))] pub variable_refresh_rate: Option, + #[knuffel(child, unwrap(argument, str))] + pub default_column_display: Option, #[knuffel(child)] pub default_floating_position: Option, #[knuffel(child, unwrap(argument))] @@ -3557,6 +3559,7 @@ mod tests { open-floating false open-focused true default-window-height { fixed 500; } + default-column-display "tabbed" default-floating-position x=100 y=-200 relative-to="bottom-left" focus-ring { @@ -3856,6 +3859,7 @@ mod tests { open_floating: Some(false), open_focused: Some(true), default_window_height: Some(DefaultPresetSize(Some(PresetSize::Fixed(500)))), + default_column_display: Some(ColumnDisplay::Tabbed), default_floating_position: Some(FloatingPosition { x: FloatOrInt(100.), y: FloatOrInt(-200.), diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs index 9be308e6..b9799ce4 100644 --- a/src/layout/scrolling.rs +++ b/src/layout/scrolling.rs @@ -3253,6 +3253,12 @@ impl Column { ) -> Self { let options = tile.options.clone(); + let display_mode = tile + .window() + .rules() + .default_column_display + .unwrap_or(options.default_column_display); + let mut rv = Self { tiles: vec![], data: vec![], @@ -3261,7 +3267,7 @@ impl Column { preset_width_idx: None, is_full_width, is_fullscreen: false, - display_mode: options.default_column_display, + display_mode, move_animation: None, view_size, working_area, diff --git a/src/window/mod.rs b/src/window/mod.rs index cc681010..ec0f7150 100644 --- a/src/window/mod.rs +++ b/src/window/mod.rs @@ -4,6 +4,7 @@ use niri_config::{ BlockOutFrom, BorderRule, CornerRadius, FloatingPosition, Match, PresetSize, ShadowRule, WindowRule, }; +use niri_ipc::ColumnDisplay; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; use smithay::utils::{Logical, Size}; use smithay::wayland::compositor::with_states; @@ -43,6 +44,9 @@ pub struct ResolvedWindowRules { /// - `Some(Some(height))`: set to a particular height. pub default_height: Option>, + /// Default column display for this window. + pub default_column_display: Option, + /// Default floating position for this window. pub default_floating_position: Option, @@ -147,6 +151,7 @@ impl ResolvedWindowRules { Self { default_width: None, default_height: None, + default_column_display: None, default_floating_position: None, open_on_output: None, open_on_workspace: None, @@ -237,6 +242,10 @@ impl ResolvedWindowRules { resolved.default_height = Some(x.0); } + if let Some(x) = rule.default_column_display { + resolved.default_column_display = Some(x); + } + if let Some(x) = rule.default_floating_position { resolved.default_floating_position = Some(x); } diff --git a/wiki/Configuration:-Window-Rules.md b/wiki/Configuration:-Window-Rules.md index d14f36d7..03fd2e1d 100644 --- a/wiki/Configuration:-Window-Rules.md +++ b/wiki/Configuration:-Window-Rules.md @@ -52,6 +52,7 @@ window-rule { block-out-from "screencast" // block-out-from "screen-capture" variable-refresh-rate true + default-column-display "tabbed" default-floating-position x=100 y=200 relative-to="bottom-left" scroll-factor 0.75 @@ -528,6 +529,27 @@ window-rule { } ``` +#### `default-column-display` + +Since: next release + +Set the default display mode for columns created from this window. + +This is used any time a window goes into its own column. +For example: +- Opening a new window. +- Expelling a window into its own column. +- Moving a window from the floating layout to the tiling layout. + +```kdl +// Make Evince windows open as tabbed columns. +window-rule { + match app-id="^evince$" + + default-column-display "tabbed" +} +``` + #### `default-floating-position` Since: 25.01 -- cgit