diff options
| author | Kirottu <56396750+Kirottu@users.noreply.github.com> | 2025-01-25 10:49:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-25 08:49:51 +0000 |
| commit | 852da5714affd067de731599136ed619dc3bba40 (patch) | |
| tree | e42514f81d8a7f74f5437746503367082917777a /src/input | |
| parent | 4f793038117b4fef38f491e665a66589eb896e0a (diff) | |
| download | niri-852da5714affd067de731599136ed619dc3bba40.tar.gz niri-852da5714affd067de731599136ed619dc3bba40.tar.bz2 niri-852da5714affd067de731599136ed619dc3bba40.zip | |
Add move-workspace-to-index and move-workspace-to-monitor actions (#1007)
* Added move-workspace-to-index and move-workspace-to-monitor IPC actions
* Added redraws to the workspace handling actions, fixed tests that panicked, fixed other mentioned problems.
* Fixed workspace focusing and handling numbered workspaces with `move-workspace-to-index`
* Fixed more inconsistencies with move-workspace-to-monitor
* Added back `self.workspace_switch = None`
* Reordered some workspace cleanup logic
* Fix formatting
* Add missing blank lines
* Fix moving workspace to same monitor and wrong current index updating
* Move function up and add fixme comment
---------
Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'src/input')
| -rw-r--r-- | src/input/mod.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/input/mod.rs b/src/input/mod.rs index 12746376..c2691739 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -1163,6 +1163,18 @@ impl State { // FIXME: granular self.niri.queue_redraw_all(); } + Action::MoveWorkspaceToIndex(new_idx) => { + self.niri.layout.move_workspace_to_idx(None, new_idx); + // FIXME: granular + self.niri.queue_redraw_all(); + } + Action::MoveWorkspaceToIndexByRef { new_idx, reference } => { + if let Some(res) = self.niri.find_output_and_workspace_index(reference) { + self.niri.layout.move_workspace_to_idx(Some(res), new_idx); + // FIXME: granular + self.niri.queue_redraw_all(); + } + } Action::SetWorkspaceName(name) => { self.niri.layout.set_workspace_name(name, None); } @@ -1497,6 +1509,37 @@ impl State { } } } + Action::MoveWorkspaceToMonitor(new_output) => { + if let Some(new_output) = self.niri.output_by_name_match(&new_output).cloned() { + if self.niri.layout.move_workspace_to_output(&new_output) + && !self.maybe_warp_cursor_to_focus_centered() + { + self.move_cursor_to_output(&new_output); + } + } + } + Action::MoveWorkspaceToMonitorByRef { + output_name, + reference, + } => { + if let Some((output, old_idx)) = + self.niri.find_output_and_workspace_index(reference) + { + if let Some(new_output) = self.niri.output_by_name_match(&output_name).cloned() + { + if self.niri.layout.move_workspace_to_output_by_id( + old_idx, + output, + new_output.clone(), + ) { + // Cursor warp already calls `queue_redraw_all` + if !self.maybe_warp_cursor_to_focus_centered() { + self.move_cursor_to_output(&new_output); + } + } + } + } + } Action::ToggleWindowFloating => { self.niri.layout.toggle_window_floating(None); // FIXME: granular |
