diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-09-02 09:20:23 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-09-01 23:47:19 -0700 |
| commit | f7181fb066e6390d516dfb4ee39e5812efad6f59 (patch) | |
| tree | 782630e468dc2d8f2e4b3f9da17184e80d08d434 /src/niri.rs | |
| parent | 17ac52e1d4c28efa205d38b134bb1f32c43f9d50 (diff) | |
| download | niri-f7181fb066e6390d516dfb4ee39e5812efad6f59.tar.gz niri-f7181fb066e6390d516dfb4ee39e5812efad6f59.tar.bz2 niri-f7181fb066e6390d516dfb4ee39e5812efad6f59.zip | |
Implement by-id workspace action addressing
It's not added to clap because there's no convenient mutually-exclusive
argument enum derive yet (to have either the current <REFERENCE> or an
--id <ID>). It's not added to config parsing because I don't see how it
could be useful there. As such, it's only accessible through raw IPC.
Diffstat (limited to 'src/niri.rs')
| -rw-r--r-- | src/niri.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/niri.rs b/src/niri.rs index ab5049a8..edd56466 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -115,6 +115,7 @@ use crate::input::{ apply_libinput_settings, mods_with_finger_scroll_binds, mods_with_wheel_binds, TabletData, }; use crate::ipc::server::IpcServer; +use crate::layout::workspace::WorkspaceId; use crate::layout::{Layout, LayoutElement as _, MonitorRenderElement}; use crate::protocols::foreign_toplevel::{self, ForeignToplevelManagerState}; use crate::protocols::gamma_control::GammaControlManagerState; @@ -2422,16 +2423,17 @@ impl Niri { &self, workspace_reference: WorkspaceReference, ) -> Option<(Option<Output>, usize)> { - let workspace_name = match workspace_reference { + let (target_workspace_index, target_workspace) = match workspace_reference { WorkspaceReference::Index(index) => { return Some((None, index.saturating_sub(1) as usize)); } - WorkspaceReference::Name(name) => name, + WorkspaceReference::Name(name) => self.layout.find_workspace_by_name(&name)?, + WorkspaceReference::Id(id) => { + let id = WorkspaceId::specific(id); + self.layout.find_workspace_by_id(id)? + } }; - let (target_workspace_index, target_workspace) = - self.layout.find_workspace_by_name(&workspace_name)?; - // FIXME: when we do fixes for no connected outputs, this will need fixing too. let active_workspace = self.layout.active_workspace()?; |
