From 10a6d6ae45d246287b6d00231545ba8c5c1ba594 Mon Sep 17 00:00:00 2001 From: Illia Ostapyshyn Date: Wed, 11 Jun 2025 08:28:03 +0200 Subject: Expand screenshot UI to handle move-X-or-to-workspace/monitor-X (#1669) * Expand screenshot UI to handle more moving actions Currently, screenshot UI handles MoveColumn{Left,Right} and MoveWindow{Up,Down} which move the screenshot selection as if it were a floating window. Expand this to include MoveColumn*OrToMonitor* and MoveWindow*OrToWorkspace* and adjust their logic to move the screenshot selection. * Update src/input/mod.rs --------- Co-authored-by: Ivan Molodetskikh --- src/input/mod.rs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/input') diff --git a/src/input/mod.rs b/src/input/mod.rs index fc011b6a..6a7e8a71 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -774,7 +774,9 @@ impl State { self.niri.queue_redraw_all(); } Action::MoveColumnLeftOrToMonitorLeft => { - if let Some(output) = self.niri.output_left() { + if self.niri.screenshot_ui.is_open() { + self.niri.screenshot_ui.move_left(); + } else if let Some(output) = self.niri.output_left() { if self.niri.layout.move_column_left_or_to_output(&output) && !self.maybe_warp_cursor_to_focus_centered() { @@ -791,7 +793,9 @@ impl State { self.niri.queue_redraw_all(); } Action::MoveColumnRightOrToMonitorRight => { - if let Some(output) = self.niri.output_right() { + if self.niri.screenshot_ui.is_open() { + self.niri.screenshot_ui.move_right(); + } else if let Some(output) = self.niri.output_right() { if self.niri.layout.move_column_right_or_to_output(&output) && !self.maybe_warp_cursor_to_focus_centered() { @@ -830,14 +834,22 @@ impl State { self.niri.queue_redraw_all(); } Action::MoveWindowDownOrToWorkspaceDown => { - self.niri.layout.move_down_or_to_workspace_down(); - self.maybe_warp_cursor_to_focus(); + if self.niri.screenshot_ui.is_open() { + self.niri.screenshot_ui.move_down(); + } else { + self.niri.layout.move_down_or_to_workspace_down(); + self.maybe_warp_cursor_to_focus(); + } // FIXME: granular self.niri.queue_redraw_all(); } Action::MoveWindowUpOrToWorkspaceUp => { - self.niri.layout.move_up_or_to_workspace_up(); - self.maybe_warp_cursor_to_focus(); + if self.niri.screenshot_ui.is_open() { + self.niri.screenshot_ui.move_up(); + } else { + self.niri.layout.move_up_or_to_workspace_up(); + self.maybe_warp_cursor_to_focus(); + } // FIXME: granular self.niri.queue_redraw_all(); } @@ -4101,9 +4113,13 @@ fn allowed_during_screenshot(action: &Action) -> bool { | Action::PowerOnMonitors // The screenshot UI can handle these. | Action::MoveColumnLeft + | Action::MoveColumnLeftOrToMonitorLeft | Action::MoveColumnRight + | Action::MoveColumnRightOrToMonitorRight | Action::MoveWindowUp + | Action::MoveWindowUpOrToWorkspaceUp | Action::MoveWindowDown + | Action::MoveWindowDownOrToWorkspaceDown | Action::SetWindowWidth(_) | Action::SetWindowHeight(_) | Action::SetColumnWidth(_) -- cgit