feat(cli): add focus-monitor-at-cursor cmd

This commit adds a new komorebic command, focus-monitor-at-cursor, which
can optionally be chained with the focus-workspace command in
keybindings to reproduce the previous default behaviour of auto-focusing
whichever monitor the cursor was on before attempting to change the
focused workspace.
This commit is contained in:
LGUG2Z
2025-01-27 16:59:35 -08:00
parent 241f8a1375
commit be8af2b314
3 changed files with 11 additions and 0 deletions

View File

@@ -119,6 +119,7 @@ pub enum SocketMessage {
CycleFocusMonitor(CycleDirection), CycleFocusMonitor(CycleDirection),
CycleFocusWorkspace(CycleDirection), CycleFocusWorkspace(CycleDirection),
FocusMonitorNumber(usize), FocusMonitorNumber(usize),
FocusMonitorAtCursor,
FocusLastWorkspace, FocusLastWorkspace,
CloseWorkspace, CloseWorkspace,
FocusWorkspaceNumber(usize), FocusWorkspaceNumber(usize),

View File

@@ -735,6 +735,11 @@ impl WindowManager {
self.focus_monitor(monitor_idx)?; self.focus_monitor(monitor_idx)?;
self.update_focused_workspace(self.mouse_follows_focus, true)?; self.update_focused_workspace(self.mouse_follows_focus, true)?;
} }
SocketMessage::FocusMonitorAtCursor => {
if let Some(monitor_idx) = self.monitor_idx_from_current_pos() {
self.focus_monitor(monitor_idx)?;
}
}
SocketMessage::Retile => { SocketMessage::Retile => {
border_manager::destroy_all_borders()?; border_manager::destroy_all_borders()?;
self.retile_all(false)? self.retile_all(false)?

View File

@@ -1108,6 +1108,8 @@ enum SubCommand {
/// Focus the specified monitor /// Focus the specified monitor
#[clap(arg_required_else_help = true)] #[clap(arg_required_else_help = true)]
FocusMonitor(FocusMonitor), FocusMonitor(FocusMonitor),
/// Focus the monitor at the current cursor location
FocusMonitorAtCursor,
/// Focus the last focused workspace on the focused monitor /// Focus the last focused workspace on the focused monitor
FocusLastWorkspace, FocusLastWorkspace,
/// Focus the specified workspace on the focused monitor /// Focus the specified workspace on the focused monitor
@@ -2588,6 +2590,9 @@ if (Get-Command Get-CimInstance -ErrorAction SilentlyContinue) {
SubCommand::FocusMonitor(arg) => { SubCommand::FocusMonitor(arg) => {
send_message(&SocketMessage::FocusMonitorNumber(arg.target))?; send_message(&SocketMessage::FocusMonitorNumber(arg.target))?;
} }
SubCommand::FocusMonitorAtCursor => {
send_message(&SocketMessage::FocusMonitorAtCursor)?;
}
SubCommand::FocusLastWorkspace => { SubCommand::FocusLastWorkspace => {
send_message(&SocketMessage::FocusLastWorkspace)?; send_message(&SocketMessage::FocusLastWorkspace)?;
} }