mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-05-08 20:03:37 +02: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
|
// Raise Window to foreground
|
||||||
match WindowsApi::set_foreground_window(self.hwnd()) {
|
let mut foregrounded = false;
|
||||||
Ok(_) => {}
|
while !foregrounded {
|
||||||
Err(error) => {
|
match WindowsApi::set_foreground_window(self.hwnd()) {
|
||||||
tracing::error!(
|
Ok(_) => {
|
||||||
"could not set as foreground window, but continuing execution of focus(): {}",
|
foregrounded = true;
|
||||||
error
|
}
|
||||||
);
|
Err(error) => {
|
||||||
}
|
tracing::error!(
|
||||||
};
|
"could not set as foreground window, but continuing execution of focus(): {}",
|
||||||
|
error
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Center cursor in Window
|
// Center cursor in Window
|
||||||
if mouse_follows_focus {
|
if mouse_follows_focus {
|
||||||
|
|||||||
Reference in New Issue
Block a user