mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-01-11 22:12:53 +01:00
fix(wm): retry foreground calls on focus change
For the past few weeks since upgrading the windows-rs crate I've seen sporadic failures when calling SetForegroundWindow which require a full restart to get the wm working as expected again. Adding in a retry loop here seems to help when the issue comes up for me on Windows 11.
This commit is contained in:
@@ -257,15 +257,20 @@ impl Window {
|
||||
};
|
||||
|
||||
// Raise Window to foreground
|
||||
match WindowsApi::set_foreground_window(self.hwnd()) {
|
||||
Ok(_) => {}
|
||||
Err(error) => {
|
||||
tracing::error!(
|
||||
"could not set as foreground window, but continuing execution of focus(): {}",
|
||||
error
|
||||
);
|
||||
}
|
||||
};
|
||||
let mut foregrounded = false;
|
||||
while !foregrounded {
|
||||
match WindowsApi::set_foreground_window(self.hwnd()) {
|
||||
Ok(_) => {
|
||||
foregrounded = true;
|
||||
}
|
||||
Err(error) => {
|
||||
tracing::error!(
|
||||
"could not set as foreground window, but continuing execution of focus(): {}",
|
||||
error
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Center cursor in Window
|
||||
if mouse_follows_focus {
|
||||
|
||||
Reference in New Issue
Block a user