diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-20 16:43:28 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-20 16:43:28 +0300 |
commit | 12ddedba78c4b28914271e9ccb64ddf4d46c1aaf (patch) | |
tree | bf7c54b3038e9dc7b9f66afe8c4579ab7a4471ae /src/mir_app | |
parent | 9e95602f74f3118eb317bd3595fa5f51708fe8a8 (diff) |
fixes #1288
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/chat_tools.cpp | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index efc9a6a1f4..d137c6d8f3 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -268,12 +268,23 @@ BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) return TRUE;
}
+static bool ContainsWindow(HWND hwndOwner, HWND hwndChild)
+{
+ while (hwndChild != nullptr) {
+ if (hwndChild == hwndOwner)
+ return true;
+
+ hwndChild = GetParent(hwndChild);
+ }
+ return false;
+}
+
BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix)
{
if (!gce || !si || gce->bIsMe || si->iType == GCW_SERVER)
return FALSE;
- BOOL bInactive = si->pDlg == nullptr || GetForegroundWindow() != si->pDlg->GetHwnd();
+ BOOL bInactive = si->pDlg == nullptr || ContainsWindow(GetForegroundWindow(), si->pDlg->GetHwnd());
int iEvent = gce->iType;
@@ -303,31 +314,20 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight chatApi.DoPopup(si, gce);
// do sounds and flashing
+ const char *szSound = nullptr;
switch (iEvent) {
- case GC_EVENT_JOIN:
- if (bInactive || !g_Settings->bSoundsFocus)
- Skin_PlaySound("ChatJoin");
- break;
- case GC_EVENT_PART:
- if (bInactive || !g_Settings->bSoundsFocus)
- Skin_PlaySound("ChatPart");
- break;
- case GC_EVENT_QUIT:
- if (bInactive || !g_Settings->bSoundsFocus)
- Skin_PlaySound("ChatQuit");
- break;
+ case GC_EVENT_JOIN: szSound = "ChatJoin"; break;
+ case GC_EVENT_PART: szSound = "ChatPart"; break;
+ case GC_EVENT_QUIT: szSound = "ChatQuit"; break;
case GC_EVENT_ADDSTATUS:
- case GC_EVENT_REMOVESTATUS:
- if (bInactive || !g_Settings->bSoundsFocus)
- Skin_PlaySound("ChatMode");
- break;
- case GC_EVENT_KICK:
- if (bInactive || !g_Settings->bSoundsFocus)
- Skin_PlaySound("ChatKick");
- break;
+ case GC_EVENT_REMOVESTATUS: szSound = "ChatMode"; break;
+ case GC_EVENT_KICK: szSound = "ChatKick"; break;
+ case GC_EVENT_ACTION: szSound = "ChatAction"; break;
+ case GC_EVENT_NICK: szSound = "ChatNick"; break;
+ case GC_EVENT_NOTICE: szSound = "ChatNotice"; break;
+ case GC_EVENT_TOPIC: szSound = "ChatTopic"; break;
case GC_EVENT_MESSAGE:
- if (bInactive || !g_Settings->bSoundsFocus)
- Skin_PlaySound("ChatMessage");
+ szSound = "ChatMessage";
if (bInactive && !(si->wState & STATE_TALK)) {
si->wState |= STATE_TALK;
@@ -336,23 +336,10 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight if (chatApi.OnFlashWindow)
chatApi.OnFlashWindow(si, bInactive);
break;
- case GC_EVENT_ACTION:
- if (bInactive || !g_Settings->bSoundsFocus)
- Skin_PlaySound("ChatAction");
- break;
- case GC_EVENT_NICK:
- if (bInactive || !g_Settings->bSoundsFocus)
- Skin_PlaySound("ChatNick");
- break;
- case GC_EVENT_NOTICE:
- if (bInactive || !g_Settings->bSoundsFocus)
- Skin_PlaySound("ChatNotice");
- break;
- case GC_EVENT_TOPIC:
- if (bInactive || !g_Settings->bSoundsFocus)
- Skin_PlaySound("ChatTopic");
- break;
}
+
+ if (szSound && (bInactive || !g_Settings->bSoundsFocus))
+ Skin_PlaySound(szSound);
}
return TRUE;
|