Skip to content

Commit afdbce3

Browse files
committed
fix(borders): respond to sys foreground winevent w/ border manager event
This commit ensures that we emit a dedicated border manager event when WinEvent::SystemForeground is received. The OS can actually be slower than komorebi when it comes to processing changed focus state, and in the border manager we rely on GetForegroundWindow when calculating which the border focus state and color should be. This has previously resulted in a situation where there may be no border with the "focused" color. This should no longer be a problem because even in the situations where the OS is slower than komorebi and is still returning an old HWND from GetForegroundWindow, the new event that we emit to border manager in response to WinEvent::SystemForeground will ensure that the border focus colors get updated.
1 parent be8af2b commit afdbce3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

komorebi/src/windows_callbacks.rs

+10
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ pub extern "system" fn win_event_hook(
115115
}
116116
}
117117

118+
// sometimes the border focus state and colors don't get updated because this event comes too
119+
// slow for the value of GetForegroundWindow to be up to date by the time it is inspected in
120+
// the border manager to determine if a window show have its border show as "focused"
121+
//
122+
// so here we can just fire another event at the border manager when the system has finally
123+
// registered the new foreground window and this time the correct border colors will be applied
124+
if matches!(winevent, WinEvent::SystemForeground) && !has_filtered_style(hwnd) {
125+
border_manager::send_notification(Some(hwnd.0 as isize));
126+
}
127+
118128
let event_type = match WindowManagerEvent::from_win_event(winevent, window) {
119129
None => {
120130
tracing::trace!(

0 commit comments

Comments
 (0)