mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 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,
|
||||
FocusMonitorPrevious,
|
||||
FocusMonitorNext,
|
||||
FocusMonitor(#[knuffel(argument)] String),
|
||||
MoveWindowToMonitorLeft,
|
||||
MoveWindowToMonitorRight,
|
||||
MoveWindowToMonitorDown,
|
||||
@@ -1770,6 +1771,7 @@ impl From<niri_ipc::Action> for Action {
|
||||
niri_ipc::Action::FocusMonitorUp {} => Self::FocusMonitorUp,
|
||||
niri_ipc::Action::FocusMonitorPrevious {} => Self::FocusMonitorPrevious,
|
||||
niri_ipc::Action::FocusMonitorNext {} => Self::FocusMonitorNext,
|
||||
niri_ipc::Action::FocusMonitor { output } => Self::FocusMonitor(output),
|
||||
niri_ipc::Action::MoveWindowToMonitorLeft {} => Self::MoveWindowToMonitorLeft,
|
||||
niri_ipc::Action::MoveWindowToMonitorRight {} => Self::MoveWindowToMonitorRight,
|
||||
niri_ipc::Action::MoveWindowToMonitorDown {} => Self::MoveWindowToMonitorDown,
|
||||
@@ -3770,6 +3772,7 @@ mod tests {
|
||||
Mod+T allow-when-locked=true { spawn "alacritty"; }
|
||||
Mod+Q hotkey-overlay-title=null { close-window; }
|
||||
Mod+Shift+H { focus-monitor-left; }
|
||||
Mod+Shift+O { focus-monitor "eDP-1"; }
|
||||
Mod+Ctrl+Shift+L { move-window-to-monitor-right; }
|
||||
Mod+Comma { consume-window-into-column; }
|
||||
Mod+1 { focus-workspace 1; }
|
||||
@@ -4606,6 +4609,24 @@ mod tests {
|
||||
allow_inhibiting: true,
|
||||
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 {
|
||||
key: Key {
|
||||
trigger: Keysym(
|
||||
|
||||
@@ -457,6 +457,12 @@ pub enum Action {
|
||||
FocusMonitorPrevious {},
|
||||
/// Focus the next monitor.
|
||||
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.
|
||||
MoveWindowToMonitorLeft {},
|
||||
/// Move the focused window to the monitor to the right.
|
||||
|
||||
@@ -1386,6 +1386,15 @@ impl State {
|
||||
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 => {
|
||||
if let Some(output) = self.niri.output_left() {
|
||||
self.niri.layout.move_to_output(None, &output, None);
|
||||
|
||||
Reference in New Issue
Block a user