mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Implement focus-monitor to focus a specific monitor by output.
This commit is contained in:
committed by
Ivan Molodetskikh
parent
47dd338340
commit
993c5ce8af
@@ -1568,6 +1568,7 @@ pub enum Action {
|
|||||||
FocusMonitorUp,
|
FocusMonitorUp,
|
||||||
FocusMonitorPrevious,
|
FocusMonitorPrevious,
|
||||||
FocusMonitorNext,
|
FocusMonitorNext,
|
||||||
|
FocusMonitor(#[knuffel(argument)] String),
|
||||||
MoveWindowToMonitorLeft,
|
MoveWindowToMonitorLeft,
|
||||||
MoveWindowToMonitorRight,
|
MoveWindowToMonitorRight,
|
||||||
MoveWindowToMonitorDown,
|
MoveWindowToMonitorDown,
|
||||||
@@ -1770,6 +1771,7 @@ impl From<niri_ipc::Action> for Action {
|
|||||||
niri_ipc::Action::FocusMonitorUp {} => Self::FocusMonitorUp,
|
niri_ipc::Action::FocusMonitorUp {} => Self::FocusMonitorUp,
|
||||||
niri_ipc::Action::FocusMonitorPrevious {} => Self::FocusMonitorPrevious,
|
niri_ipc::Action::FocusMonitorPrevious {} => Self::FocusMonitorPrevious,
|
||||||
niri_ipc::Action::FocusMonitorNext {} => Self::FocusMonitorNext,
|
niri_ipc::Action::FocusMonitorNext {} => Self::FocusMonitorNext,
|
||||||
|
niri_ipc::Action::FocusMonitor { output } => Self::FocusMonitor(output),
|
||||||
niri_ipc::Action::MoveWindowToMonitorLeft {} => Self::MoveWindowToMonitorLeft,
|
niri_ipc::Action::MoveWindowToMonitorLeft {} => Self::MoveWindowToMonitorLeft,
|
||||||
niri_ipc::Action::MoveWindowToMonitorRight {} => Self::MoveWindowToMonitorRight,
|
niri_ipc::Action::MoveWindowToMonitorRight {} => Self::MoveWindowToMonitorRight,
|
||||||
niri_ipc::Action::MoveWindowToMonitorDown {} => Self::MoveWindowToMonitorDown,
|
niri_ipc::Action::MoveWindowToMonitorDown {} => Self::MoveWindowToMonitorDown,
|
||||||
@@ -3770,6 +3772,7 @@ mod tests {
|
|||||||
Mod+T allow-when-locked=true { spawn "alacritty"; }
|
Mod+T allow-when-locked=true { spawn "alacritty"; }
|
||||||
Mod+Q hotkey-overlay-title=null { close-window; }
|
Mod+Q hotkey-overlay-title=null { close-window; }
|
||||||
Mod+Shift+H { focus-monitor-left; }
|
Mod+Shift+H { focus-monitor-left; }
|
||||||
|
Mod+Shift+O { focus-monitor "eDP-1"; }
|
||||||
Mod+Ctrl+Shift+L { move-window-to-monitor-right; }
|
Mod+Ctrl+Shift+L { move-window-to-monitor-right; }
|
||||||
Mod+Comma { consume-window-into-column; }
|
Mod+Comma { consume-window-into-column; }
|
||||||
Mod+1 { focus-workspace 1; }
|
Mod+1 { focus-workspace 1; }
|
||||||
@@ -4606,6 +4609,24 @@ mod tests {
|
|||||||
allow_inhibiting: true,
|
allow_inhibiting: true,
|
||||||
hotkey_overlay_title: None,
|
hotkey_overlay_title: None,
|
||||||
},
|
},
|
||||||
|
Bind {
|
||||||
|
key: Key {
|
||||||
|
trigger: Keysym(
|
||||||
|
XK_o,
|
||||||
|
),
|
||||||
|
modifiers: Modifiers(
|
||||||
|
SHIFT | COMPOSITOR,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
action: FocusMonitor(
|
||||||
|
"eDP-1",
|
||||||
|
),
|
||||||
|
repeat: true,
|
||||||
|
cooldown: None,
|
||||||
|
allow_when_locked: false,
|
||||||
|
allow_inhibiting: true,
|
||||||
|
hotkey_overlay_title: None,
|
||||||
|
},
|
||||||
Bind {
|
Bind {
|
||||||
key: Key {
|
key: Key {
|
||||||
trigger: Keysym(
|
trigger: Keysym(
|
||||||
|
|||||||
@@ -457,6 +457,12 @@ pub enum Action {
|
|||||||
FocusMonitorPrevious {},
|
FocusMonitorPrevious {},
|
||||||
/// Focus the next monitor.
|
/// Focus the next monitor.
|
||||||
FocusMonitorNext {},
|
FocusMonitorNext {},
|
||||||
|
/// Focus a monitor by name.
|
||||||
|
FocusMonitor {
|
||||||
|
/// Name of the output to focus.
|
||||||
|
#[cfg_attr(feature = "clap", arg())]
|
||||||
|
output: String,
|
||||||
|
},
|
||||||
/// Move the focused window to the monitor to the left.
|
/// Move the focused window to the monitor to the left.
|
||||||
MoveWindowToMonitorLeft {},
|
MoveWindowToMonitorLeft {},
|
||||||
/// Move the focused window to the monitor to the right.
|
/// Move the focused window to the monitor to the right.
|
||||||
|
|||||||
@@ -1386,6 +1386,15 @@ impl State {
|
|||||||
self.niri.layer_shell_on_demand_focus = None;
|
self.niri.layer_shell_on_demand_focus = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Action::FocusMonitor(output) => {
|
||||||
|
if let Some(output) = self.niri.output_by_name_match(&output).cloned() {
|
||||||
|
self.niri.layout.focus_output(&output);
|
||||||
|
if !self.maybe_warp_cursor_to_focus_centered() {
|
||||||
|
self.move_cursor_to_output(&output);
|
||||||
|
}
|
||||||
|
self.niri.layer_shell_on_demand_focus = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
Action::MoveWindowToMonitorLeft => {
|
Action::MoveWindowToMonitorLeft => {
|
||||||
if let Some(output) = self.niri.output_left() {
|
if let Some(output) = self.niri.output_left() {
|
||||||
self.niri.layout.move_to_output(None, &output, None);
|
self.niri.layout.move_to_output(None, &output, None);
|
||||||
|
|||||||
Reference in New Issue
Block a user