mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
Add move-column-to-index action
This commit is contained in:
committed by
Ivan Molodetskikh
parent
a5d58d670b
commit
f6aa8c1793
@@ -1167,6 +1167,12 @@ impl State {
|
||||
self.niri.queue_redraw_all();
|
||||
}
|
||||
}
|
||||
Action::MoveColumnToIndex(idx) => {
|
||||
self.niri.layout.move_column_to_index(idx);
|
||||
self.maybe_warp_cursor_to_focus();
|
||||
// FIXME: granular
|
||||
self.niri.queue_redraw_all();
|
||||
}
|
||||
Action::FocusWorkspaceDown => {
|
||||
self.niri.layout.switch_workspace_down();
|
||||
self.maybe_warp_cursor_to_focus();
|
||||
|
||||
@@ -1830,6 +1830,13 @@ impl<W: LayoutElement> Layout<W> {
|
||||
true
|
||||
}
|
||||
|
||||
pub fn move_column_to_index(&mut self, index: usize) {
|
||||
let Some(workspace) = self.active_workspace_mut() else {
|
||||
return;
|
||||
};
|
||||
workspace.move_column_to_index(index);
|
||||
}
|
||||
|
||||
pub fn move_down(&mut self) {
|
||||
let Some(workspace) = self.active_workspace_mut() else {
|
||||
return;
|
||||
|
||||
@@ -1583,6 +1583,14 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
self.columns[self.active_column_idx].focus_bottom()
|
||||
}
|
||||
|
||||
pub fn move_column_to_index(&mut self, index: usize) {
|
||||
if self.columns.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
self.move_column_to(index.saturating_sub(1).min(self.columns.len() - 1));
|
||||
}
|
||||
|
||||
fn move_column_to(&mut self, new_idx: usize) {
|
||||
if self.active_column_idx == new_idx {
|
||||
return;
|
||||
|
||||
@@ -399,6 +399,7 @@ enum Op {
|
||||
MoveColumnToLast,
|
||||
MoveColumnLeftOrToMonitorLeft(#[proptest(strategy = "1..=2u8")] u8),
|
||||
MoveColumnRightOrToMonitorRight(#[proptest(strategy = "1..=2u8")] u8),
|
||||
MoveColumnToIndex(#[proptest(strategy = "1..=5usize")] usize),
|
||||
MoveWindowDown,
|
||||
MoveWindowUp,
|
||||
MoveWindowDownOrToWorkspaceDown,
|
||||
@@ -975,6 +976,7 @@ impl Op {
|
||||
|
||||
layout.move_column_right_or_to_output(&output);
|
||||
}
|
||||
Op::MoveColumnToIndex(index) => layout.move_column_to_index(index),
|
||||
Op::MoveWindowDown => layout.move_down(),
|
||||
Op::MoveWindowUp => layout.move_up(),
|
||||
Op::MoveWindowDownOrToWorkspaceDown => layout.move_down_or_to_workspace_down(),
|
||||
|
||||
@@ -972,6 +972,13 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
self.scrolling.move_column_to_last();
|
||||
}
|
||||
|
||||
pub fn move_column_to_index(&mut self, index: usize) {
|
||||
if self.floating_is_active.get() {
|
||||
return;
|
||||
}
|
||||
self.scrolling.move_column_to_index(index);
|
||||
}
|
||||
|
||||
pub fn move_down(&mut self) -> bool {
|
||||
if self.floating_is_active.get() {
|
||||
self.floating.move_down();
|
||||
|
||||
Reference in New Issue
Block a user