summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-03-28 14:19:36 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-03-28 14:19:36 +0300
commit70493eb6f107a6b910705fd5666b9557a83471d1 (patch)
tree5abba0fe8a5472aae58f3eaa5314b4112cd6399b /src
parent12b8046c0f04c78944e3b0f77914455b8691ec8b (diff)
fix for detecting focused window
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/srmm_util.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp
index 43e90992eb..46726b478a 100644
--- a/src/mir_app/src/srmm_util.cpp
+++ b/src/mir_app/src/srmm_util.cpp
@@ -93,6 +93,17 @@ MIR_APP_DLL(CMsgDialog*) Srmm_FindDialog(MCONTACT hContact)
/////////////////////////////////////////////////////////////////////////////////////////
+static HWND GetContainer(HWND hwnd)
+{
+ while (true) {
+ HWND hwndParent = GetParent(hwnd);
+ if (hwndParent == nullptr)
+ return hwnd;
+
+ hwnd = hwndParent;
+ }
+}
+
MIR_APP_DLL(int) Srmm_GetWindowData(MCONTACT hContact, MessageWindowData &mwd)
{
if (hContact == 0)
@@ -107,7 +118,9 @@ MIR_APP_DLL(int) Srmm_GetWindowData(MCONTACT hContact, MessageWindowData &mwd)
mwd.uState = MSG_WINDOW_STATE_EXISTS;
if (IsWindowVisible(hwnd))
mwd.uState |= MSG_WINDOW_STATE_VISIBLE;
- if (GetForegroundWindow() == hwnd || GetForegroundWindow() == GetParent(hwnd))
+
+ HWND hwndFocused = GetForegroundWindow();
+ if (hwndFocused == hwnd || hwndFocused == GetContainer(hwnd))
mwd.uState |= MSG_WINDOW_STATE_FOCUS;
if (IsIconic(hwnd))
mwd.uState |= MSG_WINDOW_STATE_ICONIC;