diff options
author | B. Stack <bgstack15@gmail.com> | 2024-05-10 11:21:56 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2024-05-10 11:21:56 -0400 |
commit | 7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7 (patch) | |
tree | 3ed84995318afbd82d5d98a2ba044f9ba58b57c6 /wx+/window_tools.h | |
parent | add upstream 13.5 (diff) | |
download | FreeFileSync-7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7.tar.gz FreeFileSync-7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7.tar.bz2 FreeFileSync-7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7.zip |
add upstream 13.613.6
Diffstat (limited to 'wx+/window_tools.h')
-rw-r--r-- | wx+/window_tools.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/wx+/window_tools.h b/wx+/window_tools.h index 19b89176..94cb2c32 100644 --- a/wx+/window_tools.h +++ b/wx+/window_tools.h @@ -54,6 +54,15 @@ wxTopLevelWindow* getTopLevelWindow(wxWindow* child) even if the user is currently busy using a different app! More curiosity: this foreground focus stealing happens only during the *first* SetFocus() after app start! It also can be avoided by changing focus back and forth with some other app after start => wxWidgets bug or Win32 feature??? */ +inline +void setFocusIfActive(wxWindow& win) //don't steal keyboard focus when currently using a different foreground application +{ + if (wxTopLevelWindow* topWin = getTopLevelWindow(&win)) + if (topWin->IsActive()) //Linux/macOS: already behaves just like ::GetForegroundWindow() on Windows! + win.SetFocus(); +} + + struct FocusPreserver { FocusPreserver() @@ -70,9 +79,7 @@ struct FocusPreserver if (oldFocusId_ != wxID_ANY) if (wxWindow* oldFocusWin = wxWindow::FindWindowById(oldFocusId_)) - if (wxTopLevelWindow* topWin = getTopLevelWindow(oldFocusWin)) - if (topWin->IsActive()) //Linux/macOS: already behaves just like ::GetForegroundWindow() on Windows! - oldFocusWin->SetFocus(); + setFocusIfActive(*oldFocusWin); } wxWindowID getFocusId() const { return oldFocusId_; } |