diff options
| author | nyx <nnyyxxxx@protonmail.com> | 2025-03-29 02:40:08 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-29 06:40:08 +0000 |
| commit | 0db48e2f1bf001bfd05c686002ff1998d0f1205b (patch) | |
| tree | afc86c3f1652675750f3c6d0db0c6e0d932d4438 /src/input/mod.rs | |
| parent | 7cfecf4b1b9b8c11c80061fb31926f888228499d (diff) | |
| download | niri-0db48e2f1bf001bfd05c686002ff1998d0f1205b.tar.gz niri-0db48e2f1bf001bfd05c686002ff1998d0f1205b.tar.bz2 niri-0db48e2f1bf001bfd05c686002ff1998d0f1205b.zip | |
Add focus argument to move-window-to-workspace (#1332)
* layout: add focus flag to move-window-to-workspace
* lib: update comment
* misc: minor dup refactor
* input: format code
* layout: minor nit
* layout: update comment
* input: remove unnecessary conditionals
* misc: replace boolean
* tests: fix the failing one
* layout: change to smart
* ipc: Option<bool> -> bool
* lib: format code
* Rewrite focus doc comment
---------
Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'src/input/mod.rs')
| -rw-r--r-- | src/input/mod.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/input/mod.rs b/src/input/mod.rs index 2744561c..961df54a 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -40,7 +40,7 @@ use self::move_grab::MoveGrab; use self::resize_grab::ResizeGrab; use self::spatial_movement_grab::SpatialMovementGrab; use crate::layout::scrolling::ScrollDirection; -use crate::layout::LayoutElement as _; +use crate::layout::{ActivateWindow, LayoutElement as _}; use crate::niri::{CastTarget, State}; use crate::ui::screenshot_ui::ScreenshotUi; use crate::utils::spawning::spawn; @@ -1072,7 +1072,7 @@ impl State { // FIXME: granular self.niri.queue_redraw_all(); } - Action::MoveWindowToWorkspace(reference) => { + Action::MoveWindowToWorkspace(reference, focus) => { if let Some((mut output, index)) = self.niri.find_output_and_workspace_index(reference) { @@ -1091,7 +1091,12 @@ impl State { self.move_cursor_to_output(&output); } } else { - self.niri.layout.move_to_workspace(None, index); + let activate = if focus { + ActivateWindow::Smart + } else { + ActivateWindow::No + }; + self.niri.layout.move_to_workspace(None, index, activate); self.maybe_warp_cursor_to_focus(); } @@ -1102,6 +1107,7 @@ impl State { Action::MoveWindowToWorkspaceById { window_id: id, reference, + focus, } => { let window = self.niri.layout.windows().find(|(_, m)| m.id().get() == id); let window = window.map(|(_, m)| m.window.clone()); @@ -1130,7 +1136,14 @@ impl State { } } } else { - self.niri.layout.move_to_workspace(Some(&window), index); + let activate = if focus { + ActivateWindow::Smart + } else { + ActivateWindow::No + }; + self.niri + .layout + .move_to_workspace(Some(&window), index, activate); // If we focused the target window. let new_focus = self.niri.layout.focus(); |
