mirror of
https://github.com/YaLTeR/niri.git
synced 2024-08-17 16:20:23 +03:00
Compare commits
3 Commits
e62f1fb3bf
...
30f835cec3
Author | SHA1 | Date | |
---|---|---|---|
|
30f835cec3 | ||
|
a283c34dbb | ||
|
6692d1e384 |
@ -995,6 +995,8 @@ pub enum Action {
|
||||
MoveColumnRight,
|
||||
MoveColumnToFirst,
|
||||
MoveColumnToLast,
|
||||
MoveColumnLeftOrToMonitorLeft,
|
||||
MoveColumnRightOrToMonitorRight,
|
||||
MoveWindowDown,
|
||||
MoveWindowUp,
|
||||
MoveWindowDownOrToWorkspaceDown,
|
||||
@ -1075,6 +1077,10 @@ 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::MoveColumnLeftOrToMonitorLeft => Self::MoveColumnLeftOrToMonitorLeft,
|
||||
niri_ipc::Action::MoveColumnRightOrToMonitorRight => {
|
||||
Self::MoveColumnRightOrToMonitorRight
|
||||
}
|
||||
niri_ipc::Action::MoveWindowDown => Self::MoveWindowDown,
|
||||
niri_ipc::Action::MoveWindowUp => Self::MoveWindowUp,
|
||||
niri_ipc::Action::MoveWindowDownOrToWorkspaceDown => {
|
||||
|
@ -152,6 +152,10 @@ pub enum Action {
|
||||
MoveColumnToFirst,
|
||||
/// Move the focused column to the end of the workspace.
|
||||
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.
|
||||
MoveWindowDown,
|
||||
/// Move the focused window up in a column.
|
||||
|
@ -20,17 +20,6 @@ fi
|
||||
# Reset failed state of all user units.
|
||||
systemctl --user reset-failed
|
||||
|
||||
# Import the login manager environment.
|
||||
systemctl --user import-environment
|
||||
|
||||
# DBus activation environment is independent from systemd. While most of
|
||||
# dbus-activated services are already using `SystemdService` directive, some
|
||||
# still don't and thus we should set the dbus environment with a separate
|
||||
# command.
|
||||
if hash dbus-update-activation-environment 2>/dev/null; then
|
||||
dbus-update-activation-environment --all
|
||||
fi
|
||||
|
||||
# Start niri and wait for it to terminate.
|
||||
systemctl --user --wait start niri.service
|
||||
|
||||
|
@ -571,6 +571,40 @@ impl State {
|
||||
// FIXME: granular
|
||||
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 => {
|
||||
self.niri.layout.move_down();
|
||||
self.maybe_warp_cursor_to_focus();
|
||||
|
@ -1196,6 +1196,36 @@ impl<W: LayoutElement> Layout<W> {
|
||||
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) {
|
||||
let Some(monitor) = self.active_monitor() else {
|
||||
return;
|
||||
@ -2797,6 +2827,8 @@ mod tests {
|
||||
MoveColumnRight,
|
||||
MoveColumnToFirst,
|
||||
MoveColumnToLast,
|
||||
MoveColumnLeftOrToMonitorLeft(#[proptest(strategy = "1..=2u8")] u8),
|
||||
MoveColumnRightOrToMonitorRight(#[proptest(strategy = "1..=2u8")] u8),
|
||||
MoveWindowDown,
|
||||
MoveWindowUp,
|
||||
MoveWindowDownOrToWorkspaceDown,
|
||||
@ -3154,6 +3186,22 @@ mod tests {
|
||||
Op::MoveColumnRight => layout.move_right(),
|
||||
Op::MoveColumnToFirst => layout.move_column_to_first(),
|
||||
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::MoveWindowUp => layout.move_up(),
|
||||
Op::MoveWindowDownOrToWorkspaceDown => layout.move_down_or_to_workspace_down(),
|
||||
@ -3384,6 +3432,8 @@ mod tests {
|
||||
Op::FocusWindowOrWorkspaceDown,
|
||||
Op::MoveColumnLeft,
|
||||
Op::MoveColumnRight,
|
||||
Op::MoveColumnLeftOrToMonitorLeft(0),
|
||||
Op::MoveColumnRightOrToMonitorRight(1),
|
||||
Op::ConsumeWindowIntoColumn,
|
||||
Op::ExpelWindowFromColumn,
|
||||
Op::CenterColumn,
|
||||
@ -3563,6 +3613,8 @@ mod tests {
|
||||
Op::FocusWindowOrWorkspaceDown,
|
||||
Op::MoveColumnLeft,
|
||||
Op::MoveColumnRight,
|
||||
Op::MoveColumnLeftOrToMonitorLeft(0),
|
||||
Op::MoveColumnRightOrToMonitorRight(1),
|
||||
Op::ConsumeWindowIntoColumn,
|
||||
Op::ExpelWindowFromColumn,
|
||||
Op::CenterColumn,
|
||||
|
Loading…
Reference in New Issue
Block a user