diff --git a/komorebi-core/src/lib.rs b/komorebi-core/src/lib.rs index 34b72276..3f243139 100644 --- a/komorebi-core/src/lib.rs +++ b/komorebi-core/src/lib.rs @@ -67,6 +67,7 @@ pub enum SocketMessage { Minimize, Promote, PromoteFocus, + PromoteWindow(OperationDirection), ToggleFloat, ToggleMonocle, ToggleMaximize, diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index ad90e635..717a55e5 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -185,6 +185,10 @@ impl WindowManager { match message { SocketMessage::Promote => self.promote_container_to_front()?, SocketMessage::PromoteFocus => self.promote_focus_to_front()?, + SocketMessage::PromoteWindow(direction) => { + self.focus_container_in_direction(direction)?; + self.promote_container_to_front()? + } SocketMessage::FocusWindow(direction) => { self.focus_container_in_direction(direction)?; } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 14273550..1379721a 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -227,6 +227,11 @@ impl Window { // If the target window is already focused, do nothing. if let Ok(ihwnd) = WindowsApi::foreground_window() { if HWND(ihwnd) == self.hwnd() { + // Center cursor in Window + if mouse_follows_focus { + WindowsApi::center_cursor_in_rect(&WindowsApi::window_rect(self.hwnd())?)?; + } + return Ok(()); } } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 35979003..06284d13 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -172,6 +172,7 @@ gen_enum_subcommand_args! { WindowHidingBehaviour: HidingBehaviour, CrossMonitorMoveBehaviour: MoveBehaviour, UnmanagedWindowOperationBehaviour: OperationBehaviour, + PromoteWindow: OperationDirection, } macro_rules! gen_target_subcommand_args { @@ -1004,6 +1005,8 @@ enum SubCommand { Promote, /// Promote the user focus to the top of the tree PromoteFocus, + /// Promote the window in the specified direction + PromoteWindow(PromoteWindow), /// Force the retiling of all managed windows Retile, /// Set the monitor index preference for a monitor identified using its size @@ -1513,6 +1516,9 @@ fn main() -> Result<()> { SubCommand::PromoteFocus => { send_message(&SocketMessage::PromoteFocus.as_bytes()?)?; } + SubCommand::PromoteWindow(arg) => { + send_message(&SocketMessage::PromoteWindow(arg.operation_direction).as_bytes()?)?; + } SubCommand::TogglePause => { send_message(&SocketMessage::TogglePause.as_bytes()?)?; }