mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-05-17 09:17:02 +02:00
fix(wm): reset foreground access when calls fail
This commit is contained in:
@@ -266,7 +266,8 @@ impl Window {
|
|||||||
|
|
||||||
// Raise Window to foreground
|
// Raise Window to foreground
|
||||||
let mut foregrounded = false;
|
let mut foregrounded = false;
|
||||||
let mut max_attempts = 5;
|
let mut tried_resetting_foreground_access = false;
|
||||||
|
let mut max_attempts = 10;
|
||||||
while !foregrounded && max_attempts > 0 {
|
while !foregrounded && max_attempts > 0 {
|
||||||
match WindowsApi::set_foreground_window(self.hwnd()) {
|
match WindowsApi::set_foreground_window(self.hwnd()) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@@ -278,6 +279,13 @@ impl Window {
|
|||||||
"could not set as foreground window, but continuing execution of focus(): {}",
|
"could not set as foreground window, but continuing execution of focus(): {}",
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// If this still doesn't work then maybe try https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-locksetforegroundwindow
|
||||||
|
if !tried_resetting_foreground_access {
|
||||||
|
let process_id = WindowsApi::current_process_id();
|
||||||
|
WindowsApi::allow_set_foreground_window(process_id)?;
|
||||||
|
tried_resetting_foreground_access = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user