mirror of
https://github.com/YaLTeR/niri.git
synced 2025-10-06 00:23:14 +02:00
Add move-column-to-index action
This commit is contained in:
committed by
Ivan Molodetskikh
parent
a5d58d670b
commit
f6aa8c1793
@@ -1509,6 +1509,7 @@ pub enum Action {
|
||||
MoveColumnToLast,
|
||||
MoveColumnLeftOrToMonitorLeft,
|
||||
MoveColumnRightOrToMonitorRight,
|
||||
MoveColumnToIndex(#[knuffel(argument)] usize),
|
||||
MoveWindowDown,
|
||||
MoveWindowUp,
|
||||
MoveWindowDownOrToWorkspaceDown,
|
||||
@@ -1704,6 +1705,7 @@ impl From<niri_ipc::Action> for Action {
|
||||
niri_ipc::Action::MoveColumnRight {} => Self::MoveColumnRight,
|
||||
niri_ipc::Action::MoveColumnToFirst {} => Self::MoveColumnToFirst,
|
||||
niri_ipc::Action::MoveColumnToLast {} => Self::MoveColumnToLast,
|
||||
niri_ipc::Action::MoveColumnToIndex { index } => Self::MoveColumnToIndex(index),
|
||||
niri_ipc::Action::MoveColumnLeftOrToMonitorLeft {} => {
|
||||
Self::MoveColumnLeftOrToMonitorLeft
|
||||
}
|
||||
|
@@ -301,6 +301,14 @@ pub enum Action {
|
||||
MoveColumnLeftOrToMonitorLeft {},
|
||||
/// Move the focused column to the right or to the monitor to the right.
|
||||
MoveColumnRightOrToMonitorRight {},
|
||||
/// Move the focused column to a specific index on its workspace.
|
||||
MoveColumnToIndex {
|
||||
/// New index for the column.
|
||||
///
|
||||
/// The index starts from 1 for the first column.
|
||||
#[cfg_attr(feature = "clap", arg())]
|
||||
index: usize,
|
||||
},
|
||||
/// Move the focused window down in a column.
|
||||
MoveWindowDown {},
|
||||
/// Move the focused window up in a column.
|
||||
|
@@ -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