diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index f49c24962..c2a6ef3af 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -1225,14 +1225,17 @@ pub enum Action { FocusMonitorRight, FocusMonitorDown, FocusMonitorUp, + FocusMonitorNext, MoveWindowToMonitorLeft, MoveWindowToMonitorRight, MoveWindowToMonitorDown, MoveWindowToMonitorUp, + MoveWindowToMonitorNext, MoveColumnToMonitorLeft, MoveColumnToMonitorRight, MoveColumnToMonitorDown, MoveColumnToMonitorUp, + MoveColumnToMonitorNext, SetWindowHeight(#[knuffel(argument, str)] SizeChange), #[knuffel(skip)] SetWindowHeightById { @@ -1254,6 +1257,7 @@ pub enum Action { MoveWorkspaceToMonitorRight, MoveWorkspaceToMonitorDown, MoveWorkspaceToMonitorUp, + MoveWorkspaceToMonitorNext, } impl From for Action { @@ -1353,14 +1357,17 @@ impl From for Action { niri_ipc::Action::FocusMonitorRight {} => Self::FocusMonitorRight, niri_ipc::Action::FocusMonitorDown {} => Self::FocusMonitorDown, niri_ipc::Action::FocusMonitorUp {} => Self::FocusMonitorUp, + niri_ipc::Action::FocusMonitorNext {} => Self::FocusMonitorNext, niri_ipc::Action::MoveWindowToMonitorLeft {} => Self::MoveWindowToMonitorLeft, niri_ipc::Action::MoveWindowToMonitorRight {} => Self::MoveWindowToMonitorRight, niri_ipc::Action::MoveWindowToMonitorDown {} => Self::MoveWindowToMonitorDown, niri_ipc::Action::MoveWindowToMonitorUp {} => Self::MoveWindowToMonitorUp, + niri_ipc::Action::MoveWindowToMonitorNext {} => Self::MoveWindowToMonitorNext, niri_ipc::Action::MoveColumnToMonitorLeft {} => Self::MoveColumnToMonitorLeft, niri_ipc::Action::MoveColumnToMonitorRight {} => Self::MoveColumnToMonitorRight, niri_ipc::Action::MoveColumnToMonitorDown {} => Self::MoveColumnToMonitorDown, niri_ipc::Action::MoveColumnToMonitorUp {} => Self::MoveColumnToMonitorUp, + niri_ipc::Action::MoveColumnToMonitorNext {} => Self::MoveColumnToMonitorNext, niri_ipc::Action::SetWindowHeight { id: None, change } => Self::SetWindowHeight(change), niri_ipc::Action::SetWindowHeight { id: Some(id), @@ -1383,6 +1390,7 @@ impl From for Action { niri_ipc::Action::MoveWorkspaceToMonitorRight {} => Self::MoveWorkspaceToMonitorRight, niri_ipc::Action::MoveWorkspaceToMonitorDown {} => Self::MoveWorkspaceToMonitorDown, niri_ipc::Action::MoveWorkspaceToMonitorUp {} => Self::MoveWorkspaceToMonitorUp, + niri_ipc::Action::MoveWorkspaceToMonitorNext {} => Self::MoveWorkspaceToMonitorNext, niri_ipc::Action::ToggleDebugTint {} => Self::ToggleDebugTint, niri_ipc::Action::DebugToggleOpaqueRegions {} => Self::DebugToggleOpaqueRegions, niri_ipc::Action::DebugToggleDamage {} => Self::DebugToggleDamage, diff --git a/niri-ipc/src/lib.rs b/niri-ipc/src/lib.rs index 3df0eb4f1..967be83c8 100644 --- a/niri-ipc/src/lib.rs +++ b/niri-ipc/src/lib.rs @@ -346,6 +346,8 @@ pub enum Action { FocusMonitorDown {}, /// Focus the monitor above. FocusMonitorUp {}, + /// Focus the next monitor. + FocusMonitorNext {}, /// Move the focused window to the monitor to the left. MoveWindowToMonitorLeft {}, /// Move the focused window to the monitor to the right. @@ -354,6 +356,8 @@ pub enum Action { MoveWindowToMonitorDown {}, /// Move the focused window to the monitor above. MoveWindowToMonitorUp {}, + /// Move the focused window to the next monitor. + MoveWindowToMonitorNext {}, /// Move the focused column to the monitor to the left. MoveColumnToMonitorLeft {}, /// Move the focused column to the monitor to the right. @@ -362,6 +366,8 @@ pub enum Action { MoveColumnToMonitorDown {}, /// Move the focused column to the monitor above. MoveColumnToMonitorUp {}, + /// Move the focused column to the next monitor. + MoveColumnToMonitorNext {}, /// Change the height of a window. #[cfg_attr( feature = "clap", @@ -424,6 +430,8 @@ pub enum Action { MoveWorkspaceToMonitorDown {}, /// Move the focused workspace to the monitor above. MoveWorkspaceToMonitorUp {}, + /// Move the focused workspace to the next monitor. + MoveWorkspaceToMonitorNext {}, /// Toggle a debug tint on windows. ToggleDebugTint {}, /// Toggle visualization of render element opaque regions. diff --git a/src/input/mod.rs b/src/input/mod.rs index 13ed6d7f4..c826ccb08 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -1162,6 +1162,14 @@ impl State { } } } + Action::FocusMonitorNext => { + if let Some(output) = self.niri.output_next() { + self.niri.layout.focus_output(&output); + if !self.maybe_warp_cursor_to_focus_centered() { + self.move_cursor_to_output(&output); + } + } + } Action::MoveWindowToMonitorLeft => { if let Some(output) = self.niri.output_left() { self.niri.layout.move_to_output(None, &output, None); @@ -1198,6 +1206,15 @@ impl State { } } } + Action::MoveWindowToMonitorNext => { + if let Some(output) = self.niri.output_next() { + self.niri.layout.move_to_output(None, &output, None); + self.niri.layout.focus_output(&output); + if !self.maybe_warp_cursor_to_focus_centered() { + self.move_cursor_to_output(&output); + } + } + } Action::MoveColumnToMonitorLeft => { if let Some(output) = self.niri.output_left() { self.niri.layout.move_column_to_output(&output); @@ -1234,6 +1251,15 @@ impl State { } } } + Action::MoveColumnToMonitorNext => { + if let Some(output) = self.niri.output_next() { + self.niri.layout.move_column_to_output(&output); + self.niri.layout.focus_output(&output); + if !self.maybe_warp_cursor_to_focus_centered() { + self.move_cursor_to_output(&output); + } + } + } Action::SetColumnWidth(change) => { self.niri.layout.set_column_width(change); } @@ -1294,6 +1320,14 @@ impl State { } } } + Action::MoveWorkspaceToMonitorNext => { + if let Some(output) = self.niri.output_next() { + self.niri.layout.move_workspace_to_output(&output); + if !self.maybe_warp_cursor_to_focus_centered() { + self.move_cursor_to_output(&output); + } + } + } } } diff --git a/src/niri.rs b/src/niri.rs index b2e17d5dc..0d64cba55 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -2601,6 +2601,17 @@ impl Niri { .cloned() } + pub fn output_next(&self) -> Option { + let active = self.layout.active_output()?; + + self.global_space + .outputs() + .skip_while(|&output| output != active) + .nth(1) + .or(self.global_space.outputs().next()) + .cloned() + } + pub fn find_output_and_workspace_index( &self, workspace_reference: WorkspaceReference,