mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Add default-column-display window rule
This commit is contained in:
@@ -1113,6 +1113,8 @@ pub struct WindowRule {
|
|||||||
pub block_out_from: Option<BlockOutFrom>,
|
pub block_out_from: Option<BlockOutFrom>,
|
||||||
#[knuffel(child, unwrap(argument))]
|
#[knuffel(child, unwrap(argument))]
|
||||||
pub variable_refresh_rate: Option<bool>,
|
pub variable_refresh_rate: Option<bool>,
|
||||||
|
#[knuffel(child, unwrap(argument, str))]
|
||||||
|
pub default_column_display: Option<ColumnDisplay>,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
pub default_floating_position: Option<FloatingPosition>,
|
pub default_floating_position: Option<FloatingPosition>,
|
||||||
#[knuffel(child, unwrap(argument))]
|
#[knuffel(child, unwrap(argument))]
|
||||||
@@ -3557,6 +3559,7 @@ mod tests {
|
|||||||
open-floating false
|
open-floating false
|
||||||
open-focused true
|
open-focused true
|
||||||
default-window-height { fixed 500; }
|
default-window-height { fixed 500; }
|
||||||
|
default-column-display "tabbed"
|
||||||
default-floating-position x=100 y=-200 relative-to="bottom-left"
|
default-floating-position x=100 y=-200 relative-to="bottom-left"
|
||||||
|
|
||||||
focus-ring {
|
focus-ring {
|
||||||
@@ -3856,6 +3859,7 @@ mod tests {
|
|||||||
open_floating: Some(false),
|
open_floating: Some(false),
|
||||||
open_focused: Some(true),
|
open_focused: Some(true),
|
||||||
default_window_height: Some(DefaultPresetSize(Some(PresetSize::Fixed(500)))),
|
default_window_height: Some(DefaultPresetSize(Some(PresetSize::Fixed(500)))),
|
||||||
|
default_column_display: Some(ColumnDisplay::Tabbed),
|
||||||
default_floating_position: Some(FloatingPosition {
|
default_floating_position: Some(FloatingPosition {
|
||||||
x: FloatOrInt(100.),
|
x: FloatOrInt(100.),
|
||||||
y: FloatOrInt(-200.),
|
y: FloatOrInt(-200.),
|
||||||
|
|||||||
@@ -3253,6 +3253,12 @@ impl<W: LayoutElement> Column<W> {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
let options = tile.options.clone();
|
let options = tile.options.clone();
|
||||||
|
|
||||||
|
let display_mode = tile
|
||||||
|
.window()
|
||||||
|
.rules()
|
||||||
|
.default_column_display
|
||||||
|
.unwrap_or(options.default_column_display);
|
||||||
|
|
||||||
let mut rv = Self {
|
let mut rv = Self {
|
||||||
tiles: vec![],
|
tiles: vec![],
|
||||||
data: vec![],
|
data: vec![],
|
||||||
@@ -3261,7 +3267,7 @@ impl<W: LayoutElement> Column<W> {
|
|||||||
preset_width_idx: None,
|
preset_width_idx: None,
|
||||||
is_full_width,
|
is_full_width,
|
||||||
is_fullscreen: false,
|
is_fullscreen: false,
|
||||||
display_mode: options.default_column_display,
|
display_mode,
|
||||||
move_animation: None,
|
move_animation: None,
|
||||||
view_size,
|
view_size,
|
||||||
working_area,
|
working_area,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use niri_config::{
|
|||||||
BlockOutFrom, BorderRule, CornerRadius, FloatingPosition, Match, PresetSize, ShadowRule,
|
BlockOutFrom, BorderRule, CornerRadius, FloatingPosition, Match, PresetSize, ShadowRule,
|
||||||
WindowRule,
|
WindowRule,
|
||||||
};
|
};
|
||||||
|
use niri_ipc::ColumnDisplay;
|
||||||
use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
|
use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
|
||||||
use smithay::utils::{Logical, Size};
|
use smithay::utils::{Logical, Size};
|
||||||
use smithay::wayland::compositor::with_states;
|
use smithay::wayland::compositor::with_states;
|
||||||
@@ -43,6 +44,9 @@ pub struct ResolvedWindowRules {
|
|||||||
/// - `Some(Some(height))`: set to a particular height.
|
/// - `Some(Some(height))`: set to a particular height.
|
||||||
pub default_height: Option<Option<PresetSize>>,
|
pub default_height: Option<Option<PresetSize>>,
|
||||||
|
|
||||||
|
/// Default column display for this window.
|
||||||
|
pub default_column_display: Option<ColumnDisplay>,
|
||||||
|
|
||||||
/// Default floating position for this window.
|
/// Default floating position for this window.
|
||||||
pub default_floating_position: Option<FloatingPosition>,
|
pub default_floating_position: Option<FloatingPosition>,
|
||||||
|
|
||||||
@@ -147,6 +151,7 @@ impl ResolvedWindowRules {
|
|||||||
Self {
|
Self {
|
||||||
default_width: None,
|
default_width: None,
|
||||||
default_height: None,
|
default_height: None,
|
||||||
|
default_column_display: None,
|
||||||
default_floating_position: None,
|
default_floating_position: None,
|
||||||
open_on_output: None,
|
open_on_output: None,
|
||||||
open_on_workspace: None,
|
open_on_workspace: None,
|
||||||
@@ -237,6 +242,10 @@ impl ResolvedWindowRules {
|
|||||||
resolved.default_height = Some(x.0);
|
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 {
|
if let Some(x) = rule.default_floating_position {
|
||||||
resolved.default_floating_position = Some(x);
|
resolved.default_floating_position = Some(x);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ window-rule {
|
|||||||
block-out-from "screencast"
|
block-out-from "screencast"
|
||||||
// block-out-from "screen-capture"
|
// block-out-from "screen-capture"
|
||||||
variable-refresh-rate true
|
variable-refresh-rate true
|
||||||
|
default-column-display "tabbed"
|
||||||
default-floating-position x=100 y=200 relative-to="bottom-left"
|
default-floating-position x=100 y=200 relative-to="bottom-left"
|
||||||
scroll-factor 0.75
|
scroll-factor 0.75
|
||||||
|
|
||||||
@@ -528,6 +529,27 @@ window-rule {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### `default-column-display`
|
||||||
|
|
||||||
|
<sup>Since: next release</sup>
|
||||||
|
|
||||||
|
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`
|
#### `default-floating-position`
|
||||||
|
|
||||||
<sup>Since: 25.01</sup>
|
<sup>Since: 25.01</sup>
|
||||||
|
|||||||
Reference in New Issue
Block a user