From 62770033f260a70037637ea3cef075b1fc2437bd Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 22 May 2024 15:33:01 -0700 Subject: [PATCH] fix(wm): make close + min op on foreground hwnd This commit changes the handlers for the Close and Minimize SocketMessages to operate on the output of WindowsApi::foreground_window, without checking the window manager state as it was doing previously. This will allow the commands to operate on any kind of managed or unmanaged window, and the appropriate WinEvent will be emitted by the closed window for the window manager state to be updated when the WinEvent goes through process_event. fix #839 --- komorebi/src/process_command.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 47d93628..ad492cf6 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -215,8 +215,18 @@ impl WindowManager { WindowsApi::center_cursor_in_rect(&focused_window_rect)?; WindowsApi::left_click(); } - SocketMessage::Close => self.focused_window()?.close()?, - SocketMessage::Minimize => self.focused_window()?.minimize(), + SocketMessage::Close => { + Window { + hwnd: WindowsApi::foreground_window()?, + } + .close()?; + } + SocketMessage::Minimize => { + Window { + hwnd: WindowsApi::foreground_window()?, + } + .minimize(); + } SocketMessage::ToggleFloat => self.toggle_float()?, SocketMessage::ToggleMonocle => self.toggle_monocle()?, SocketMessage::ToggleMaximize => self.toggle_maximize()?,