diff options
| author | Gergely Nagy <niri@gergo.csillger.hu> | 2024-05-11 22:40:30 +0200 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-05-16 01:24:34 -0700 |
| commit | eb9bbe3352820754a4ee3c19f15cff690d1c193d (patch) | |
| tree | 65264aa9d03cc1ed63b4a540d0bca438ba75624b /src/window | |
| parent | 229ca905071d837dbe6cfd9383e51cbb3c4634d7 (diff) | |
| download | niri-eb9bbe3352820754a4ee3c19f15cff690d1c193d.tar.gz niri-eb9bbe3352820754a4ee3c19f15cff690d1c193d.tar.bz2 niri-eb9bbe3352820754a4ee3c19f15cff690d1c193d.zip | |
Implement named workspaces
This is an implementation of named, pre-declared workspaces. With this
implementation, workspaces can be declared in the configuration file by
name:
```
workspace "name" {
open-on-output "winit"
}
```
The `open-on-output` property is optional, and can be skipped, in which
case the workspace will open on the primary output.
All actions that were able to target a workspace by index can now target
them by either an index, or a name. In case of the command line, where
we do not have types available, this means that workspace names that
also pass as `u8` cannot be switched to by name, only by index.
Unlike dynamic workspaces, named workspaces do not close when they are
empty, they remain static. Like dynamic workspaces, named workspaces are
bound to a particular output. Switching to a named workspace, or moving
a window or column to one will also switch to, or move the thing in
question to the output of the workspace.
When reloading the configuration, newly added named workspaces will be
created, and removed ones will lose their name. If any such orphaned
workspace was empty, they will be removed. If they weren't, they'll
remain as a dynamic workspace, without a name. Re-declaring a workspace
with the same name later will create a new one.
Additionally, this also implements a `open-on-workspace "<name>"` window
rule. Matching windows will open on the given workspace (or the current
one, if the named workspace does not exist).
Signed-off-by: Gergely Nagy <niri@gergo.csillger.hu>
Diffstat (limited to 'src/window')
| -rw-r--r-- | src/window/mod.rs | 10 | ||||
| -rw-r--r-- | src/window/unmapped.rs | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/window/mod.rs b/src/window/mod.rs index 4ccbb111..92b4f793 100644 --- a/src/window/mod.rs +++ b/src/window/mod.rs @@ -33,6 +33,9 @@ pub struct ResolvedWindowRules { /// Output to open this window on. pub open_on_output: Option<String>, + /// Workspace to open this window on. + pub open_on_workspace: Option<String>, + /// Whether the window should open full-width. pub open_maximized: Option<bool>, @@ -99,6 +102,7 @@ impl ResolvedWindowRules { Self { default_width: None, open_on_output: None, + open_on_workspace: None, open_maximized: None, open_fullscreen: None, min_width: None, @@ -151,6 +155,7 @@ impl ResolvedWindowRules { } let mut open_on_output = None; + let mut open_on_workspace = None; for rule in rules { let matches = |m| window_matches(window, &role, m); @@ -175,6 +180,10 @@ impl ResolvedWindowRules { open_on_output = Some(x); } + if let Some(x) = rule.open_on_workspace.as_deref() { + open_on_workspace = Some(x); + } + if let Some(x) = rule.open_maximized { resolved.open_maximized = Some(x); } @@ -217,6 +226,7 @@ impl ResolvedWindowRules { } resolved.open_on_output = open_on_output.map(|x| x.to_owned()); + resolved.open_on_workspace = open_on_workspace.map(|x| x.to_owned()); }); resolved diff --git a/src/window/unmapped.rs b/src/window/unmapped.rs index 9cde4ca7..a74c4e24 100644 --- a/src/window/unmapped.rs +++ b/src/window/unmapped.rs @@ -11,6 +11,7 @@ pub struct Unmapped { pub state: InitialConfigureState, } +#[allow(clippy::large_enum_variant)] #[derive(Debug)] pub enum InitialConfigureState { /// The window has not been initially configured yet. @@ -42,6 +43,9 @@ pub enum InitialConfigureState { /// - This is a dialog with a parent, and there was no explicit output set, so this dialog /// should fetch the parent's current output again upon mapping. output: Option<Output>, + + /// Workspace to open this window on. + workspace_name: Option<String>, }, } |
