summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Scriver/src/chat.h1
-rw-r--r--src/mir_app/src/chat_tools.cpp65
2 files changed, 26 insertions, 40 deletions
diff --git a/plugins/Scriver/src/chat.h b/plugins/Scriver/src/chat.h
index 384bfd2ab3..3226e0a557 100644
--- a/plugins/Scriver/src/chat.h
+++ b/plugins/Scriver/src/chat.h
@@ -78,7 +78,6 @@ SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* cu
char SM_GetStatusIndicator(SESSION_INFO *si, USERINFO *ui);
// tools.c
-BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2) ;
/////////////////////////////////////////////////////////////////////////////////////////
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;