mirror of
https://github.com/YaLTeR/niri.git
synced 2024-09-11 20:37:25 +03:00
Add move-column-{left/right}-or-to-monitor-{left/right} (#528)
* feature added, move-column-left-or-monitor-left and move-column-right-or-monitor-right * fixed stupid mistake * yalter's fixes * fixed names * fixed a stupid mistake --------- Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
This commit is contained in:
parent
f9fe86ee3e
commit
a283c34dbb
@ -995,6 +995,8 @@ pub enum Action {
|
|||||||
MoveColumnRight,
|
MoveColumnRight,
|
||||||
MoveColumnToFirst,
|
MoveColumnToFirst,
|
||||||
MoveColumnToLast,
|
MoveColumnToLast,
|
||||||
|
MoveColumnLeftOrToMonitorLeft,
|
||||||
|
MoveColumnRightOrToMonitorRight,
|
||||||
MoveWindowDown,
|
MoveWindowDown,
|
||||||
MoveWindowUp,
|
MoveWindowUp,
|
||||||
MoveWindowDownOrToWorkspaceDown,
|
MoveWindowDownOrToWorkspaceDown,
|
||||||
@ -1075,6 +1077,10 @@ impl From<niri_ipc::Action> for Action {
|
|||||||
niri_ipc::Action::MoveColumnRight => Self::MoveColumnRight,
|
niri_ipc::Action::MoveColumnRight => Self::MoveColumnRight,
|
||||||
niri_ipc::Action::MoveColumnToFirst => Self::MoveColumnToFirst,
|
niri_ipc::Action::MoveColumnToFirst => Self::MoveColumnToFirst,
|
||||||
niri_ipc::Action::MoveColumnToLast => Self::MoveColumnToLast,
|
niri_ipc::Action::MoveColumnToLast => Self::MoveColumnToLast,
|
||||||
|
niri_ipc::Action::MoveColumnLeftOrToMonitorLeft => Self::MoveColumnLeftOrToMonitorLeft,
|
||||||
|
niri_ipc::Action::MoveColumnRightOrToMonitorRight => {
|
||||||
|
Self::MoveColumnRightOrToMonitorRight
|
||||||
|
}
|
||||||
niri_ipc::Action::MoveWindowDown => Self::MoveWindowDown,
|
niri_ipc::Action::MoveWindowDown => Self::MoveWindowDown,
|
||||||
niri_ipc::Action::MoveWindowUp => Self::MoveWindowUp,
|
niri_ipc::Action::MoveWindowUp => Self::MoveWindowUp,
|
||||||
niri_ipc::Action::MoveWindowDownOrToWorkspaceDown => {
|
niri_ipc::Action::MoveWindowDownOrToWorkspaceDown => {
|
||||||
|
@ -152,6 +152,10 @@ pub enum Action {
|
|||||||
MoveColumnToFirst,
|
MoveColumnToFirst,
|
||||||
/// Move the focused column to the end of the workspace.
|
/// Move the focused column to the end of the workspace.
|
||||||
MoveColumnToLast,
|
MoveColumnToLast,
|
||||||
|
/// Move the focused column to the left or to the monitor to the left.
|
||||||
|
MoveColumnLeftOrToMonitorLeft,
|
||||||
|
/// Move the focused column to the right or to the monitor to the right.
|
||||||
|
MoveColumnRightOrToMonitorRight,
|
||||||
/// Move the focused window down in a column.
|
/// Move the focused window down in a column.
|
||||||
MoveWindowDown,
|
MoveWindowDown,
|
||||||
/// Move the focused window up in a column.
|
/// Move the focused window up in a column.
|
||||||
|
@ -571,6 +571,40 @@ impl State {
|
|||||||
// FIXME: granular
|
// FIXME: granular
|
||||||
self.niri.queue_redraw_all();
|
self.niri.queue_redraw_all();
|
||||||
}
|
}
|
||||||
|
Action::MoveColumnLeftOrToMonitorLeft => {
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
self.move_cursor_to_output(&output);
|
||||||
|
} else {
|
||||||
|
self.maybe_warp_cursor_to_focus();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.niri.layout.move_left();
|
||||||
|
self.maybe_warp_cursor_to_focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: granular
|
||||||
|
self.niri.queue_redraw_all();
|
||||||
|
}
|
||||||
|
Action::MoveColumnRightOrToMonitorRight => {
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
self.move_cursor_to_output(&output);
|
||||||
|
} else {
|
||||||
|
self.maybe_warp_cursor_to_focus();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.niri.layout.move_right();
|
||||||
|
self.maybe_warp_cursor_to_focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: granular
|
||||||
|
self.niri.queue_redraw_all();
|
||||||
|
}
|
||||||
Action::MoveWindowDown => {
|
Action::MoveWindowDown => {
|
||||||
self.niri.layout.move_down();
|
self.niri.layout.move_down();
|
||||||
self.maybe_warp_cursor_to_focus();
|
self.maybe_warp_cursor_to_focus();
|
||||||
|
@ -1196,6 +1196,36 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
monitor.move_column_to_last();
|
monitor.move_column_to_last();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn move_column_left_or_to_output(&mut self, output: &Output) -> bool {
|
||||||
|
if let Some(monitor) = self.active_monitor() {
|
||||||
|
let workspace = monitor.active_workspace();
|
||||||
|
let curr_idx = workspace.active_column_idx;
|
||||||
|
|
||||||
|
if !workspace.columns.is_empty() && curr_idx != 0 {
|
||||||
|
monitor.move_left();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.move_column_to_output(output);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn move_column_right_or_to_output(&mut self, output: &Output) -> bool {
|
||||||
|
if let Some(monitor) = self.active_monitor() {
|
||||||
|
let workspace = monitor.active_workspace();
|
||||||
|
let curr_idx = workspace.active_column_idx;
|
||||||
|
|
||||||
|
if !workspace.columns.is_empty() && curr_idx != workspace.columns.len() - 1 {
|
||||||
|
monitor.move_right();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.move_column_to_output(output);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
pub fn move_down(&mut self) {
|
pub fn move_down(&mut self) {
|
||||||
let Some(monitor) = self.active_monitor() else {
|
let Some(monitor) = self.active_monitor() else {
|
||||||
return;
|
return;
|
||||||
@ -2797,6 +2827,8 @@ mod tests {
|
|||||||
MoveColumnRight,
|
MoveColumnRight,
|
||||||
MoveColumnToFirst,
|
MoveColumnToFirst,
|
||||||
MoveColumnToLast,
|
MoveColumnToLast,
|
||||||
|
MoveColumnLeftOrToMonitorLeft(#[proptest(strategy = "1..=2u8")] u8),
|
||||||
|
MoveColumnRightOrToMonitorRight(#[proptest(strategy = "1..=2u8")] u8),
|
||||||
MoveWindowDown,
|
MoveWindowDown,
|
||||||
MoveWindowUp,
|
MoveWindowUp,
|
||||||
MoveWindowDownOrToWorkspaceDown,
|
MoveWindowDownOrToWorkspaceDown,
|
||||||
@ -3154,6 +3186,22 @@ mod tests {
|
|||||||
Op::MoveColumnRight => layout.move_right(),
|
Op::MoveColumnRight => layout.move_right(),
|
||||||
Op::MoveColumnToFirst => layout.move_column_to_first(),
|
Op::MoveColumnToFirst => layout.move_column_to_first(),
|
||||||
Op::MoveColumnToLast => layout.move_column_to_last(),
|
Op::MoveColumnToLast => layout.move_column_to_last(),
|
||||||
|
Op::MoveColumnLeftOrToMonitorLeft(id) => {
|
||||||
|
let name = format!("output{id}");
|
||||||
|
let Some(output) = layout.outputs().find(|o| o.name() == name).cloned() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout.move_column_left_or_to_output(&output);
|
||||||
|
}
|
||||||
|
Op::MoveColumnRightOrToMonitorRight(id) => {
|
||||||
|
let name = format!("output{id}");
|
||||||
|
let Some(output) = layout.outputs().find(|o| o.name() == name).cloned() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout.move_column_right_or_to_output(&output);
|
||||||
|
}
|
||||||
Op::MoveWindowDown => layout.move_down(),
|
Op::MoveWindowDown => layout.move_down(),
|
||||||
Op::MoveWindowUp => layout.move_up(),
|
Op::MoveWindowUp => layout.move_up(),
|
||||||
Op::MoveWindowDownOrToWorkspaceDown => layout.move_down_or_to_workspace_down(),
|
Op::MoveWindowDownOrToWorkspaceDown => layout.move_down_or_to_workspace_down(),
|
||||||
@ -3384,6 +3432,8 @@ mod tests {
|
|||||||
Op::FocusWindowOrWorkspaceDown,
|
Op::FocusWindowOrWorkspaceDown,
|
||||||
Op::MoveColumnLeft,
|
Op::MoveColumnLeft,
|
||||||
Op::MoveColumnRight,
|
Op::MoveColumnRight,
|
||||||
|
Op::MoveColumnLeftOrToMonitorLeft(0),
|
||||||
|
Op::MoveColumnRightOrToMonitorRight(1),
|
||||||
Op::ConsumeWindowIntoColumn,
|
Op::ConsumeWindowIntoColumn,
|
||||||
Op::ExpelWindowFromColumn,
|
Op::ExpelWindowFromColumn,
|
||||||
Op::CenterColumn,
|
Op::CenterColumn,
|
||||||
@ -3563,6 +3613,8 @@ mod tests {
|
|||||||
Op::FocusWindowOrWorkspaceDown,
|
Op::FocusWindowOrWorkspaceDown,
|
||||||
Op::MoveColumnLeft,
|
Op::MoveColumnLeft,
|
||||||
Op::MoveColumnRight,
|
Op::MoveColumnRight,
|
||||||
|
Op::MoveColumnLeftOrToMonitorLeft(0),
|
||||||
|
Op::MoveColumnRightOrToMonitorRight(1),
|
||||||
Op::ConsumeWindowIntoColumn,
|
Op::ConsumeWindowIntoColumn,
|
||||||
Op::ExpelWindowFromColumn,
|
Op::ExpelWindowFromColumn,
|
||||||
Op::CenterColumn,
|
Op::CenterColumn,
|
||||||
|
Loading…
Reference in New Issue
Block a user