From 635272fc1036483c98fc52de4eaaae0b534d3c42 Mon Sep 17 00:00:00 2001 From: Yusuf007R Date: Wed, 12 Oct 2022 15:50:01 -0500 Subject: [PATCH] feat(wm): add max number of attempts to set foreground this commits adds a max number of attempts (5) to the call of set_foreground_window inside Window:Focus --- komorebi/src/window.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/komorebi/src/window.rs b/komorebi/src/window.rs index d45db1f0..9ef1be7c 100644 --- a/komorebi/src/window.rs +++ b/komorebi/src/window.rs @@ -258,12 +258,14 @@ impl Window { // Raise Window to foreground let mut foregrounded = false; - while !foregrounded { + let mut max_attempts = 5; + while !foregrounded && max_attempts > 0 { match WindowsApi::set_foreground_window(self.hwnd()) { Ok(_) => { foregrounded = true; } Err(error) => { + max_attempts -= 1; tracing::error!( "could not set as foreground window, but continuing execution of focus(): {}", error