From 4ba3125dde194cfb1ef15ce1a55f0246943683a5 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 13 Apr 2024 22:38:39 -0700 Subject: [PATCH] fix(wm): ensure window restore on stackbar click This commit ensures that a window is restored before a focus call is made on it when switching windows in a stack by using a window's tab in the stackbar. This handles the issue where two clicks are required to trigger a layout update the first time a window that is not currently at the top of the stack is brought to the front via a stackbar click. --- komorebi/src/stackbar.rs | 3 +-- komorebi/src/window.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/komorebi/src/stackbar.rs b/komorebi/src/stackbar.rs index 569eed25..de7facb7 100644 --- a/komorebi/src/stackbar.rs +++ b/komorebi/src/stackbar.rs @@ -55,8 +55,6 @@ use komorebi_core::Rect; use crate::window::Window; use crate::windows_api::WindowsApi; -use crate::winevent_listener::event_tx; -use crate::WindowManagerEvent; use crate::DEFAULT_CONTAINER_PADDING; use crate::STACKBAR_FOCUSED_TEXT_COLOUR; use crate::STACKBAR_TAB_BACKGROUND_COLOUR; @@ -115,6 +113,7 @@ impl Stackbar { if x >= left && x <= right && y >= top && y <= bottom { let window = Window { hwnd: *win_hwnd }; + window.restore(); if let Err(err) = window.focus(false) { tracing::error!("Stackbar focus error: HWND:{} {}", *win_hwnd, err); } diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index 5857ae89..11539b0e 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -323,7 +323,7 @@ impl Window { return Ok(false); } - let is_cloaked = self.is_cloaked()?; + let is_cloaked = self.is_cloaked().unwrap_or_default(); let mut allow_cloaked = false;