From d0735d50571bca069ee2fe372095b3750a32f51d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 17 Sep 2016 17:42:48 +0000 Subject: - fix for tray icon blinking in chats; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@17310 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_app/src/chat_clist.cpp | 2 +- src/mir_app/src/chat_manager.cpp | 30 +----------------------- src/mir_app/src/chat_svc.cpp | 50 ++++++++++++++++++++++++++++++++++++---- src/mir_app/src/clcfiledrop.cpp | 2 +- 4 files changed, 49 insertions(+), 35 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index b6fdad1875..679e24e880 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -210,7 +210,7 @@ BOOL AddEvent(MCONTACT hContact, HICON hIcon, MEVENT hEvent, int type, wchar_t* cle.hDbEvent = hEvent; cle.flags = type | CLEF_TCHAR; cle.hIcon = hIcon; - cle.pszService = "GChat/DblClickEvent" ; + cle.pszService = "GChat/DblClickEvent"; cle.ptszTooltip = TranslateW(szBuf); if (!ServiceExists(cle.pszService)) diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 635478ce8f..9758431011 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -123,8 +123,6 @@ static int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL re while (pTemp != NULL) { // match if ((!pszID && pTemp->iType != GCW_SERVER || !mir_wstrcmpi(pTemp->ptszID, pszID)) && !mir_strcmpi(pTemp->pszModule, pszModule)) { - void *pItemData = pTemp->pItemData; - if (chatApi.OnRemoveSession) chatApi.OnRemoveSession(pTemp); DoEventHook(pTemp->ptszID, pTemp->pszModule, GC_SESSION_TERMINATE, NULL, NULL, (INT_PTR)pTemp->pItemData); @@ -142,7 +140,7 @@ static int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL re SM_FreeSession(pTemp); if (pszID) - return (int)pItemData; + return 1; if (pLast) pTemp = pLast->next; @@ -224,31 +222,6 @@ static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui) return chatApi.hIcons[ICON_STATUS0]; } -static BOOL SM_AddEventToAllMatchingUID(GCEVENT *gce) -{ - int bManyFix = 0; - - for (SESSION_INFO *p = chatApi.wndList; p != NULL; p = p->next) { - if (!p->bInitDone || mir_strcmpi(p->pszModule, gce->pDest->pszModule)) - continue; - - if (!chatApi.UM_FindUser(p->pUsers, gce->ptszUID)) - continue; - - if (chatApi.OnEventBroadcast) - chatApi.OnEventBroadcast(p, gce); - - if (!(gce->dwFlags & GCEF_NOTNOTIFY)) - chatApi.DoSoundsFlashPopupTrayStuff(p, gce, FALSE, bManyFix); - - bManyFix++; - if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->bLoggingEnabled) - chatApi.LogToFile(p, gce); - } - - return 0; -} - static BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, BOOL bIsHighlighted) { SESSION_INFO *p = SM_FindSession(pszID, pszModule); @@ -1244,7 +1217,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ chatApi.SM_SetStatusEx = SM_SetStatusEx; chatApi.SM_SendUserMessage = SM_SendUserMessage; chatApi.SM_AddStatus = SM_AddStatus; - chatApi.SM_AddEventToAllMatchingUID = SM_AddEventToAllMatchingUID; chatApi.SM_AddEvent = SM_AddEvent; chatApi.SM_SendMessage = SM_SendMessage; chatApi.SM_PostMessage = SM_PostMessage; diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 2320292da5..c6b1e486ec 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -353,6 +353,19 @@ MIR_APP_DLL(int) Chat_Terminate(const char *szModule, const wchar_t *wszId, bool ///////////////////////////////////////////////////////////////////////////////////////// // handles chat event +struct DoFlashParam +{ + SESSION_INFO *si; + GCEVENT *gce; + int i1, i2; +}; + +static INT_PTR __stdcall stubFlash(void *param) +{ + DoFlashParam *p = (DoFlashParam*)param; + return chatApi.DoSoundsFlashPopupTrayStuff(p->si, p->gce, p->i1, p->i2); +} + static void AddUser(GCEVENT *gce) { SESSION_INFO *si = chatApi.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); @@ -372,6 +385,33 @@ static void AddUser(GCEVENT *gce) chatApi.OnNewUser(si, ui); } +static BOOL AddEventToAllMatchingUID(GCEVENT *gce) +{ + int bManyFix = 0; + + for (SESSION_INFO *p = chatApi.wndList; p != NULL; p = p->next) { + if (!p->bInitDone || mir_strcmpi(p->pszModule, gce->pDest->pszModule)) + continue; + + if (!chatApi.UM_FindUser(p->pUsers, gce->ptszUID)) + continue; + + if (chatApi.OnEventBroadcast) + chatApi.OnEventBroadcast(p, gce); + + if (!(gce->dwFlags & GCEF_NOTNOTIFY)) { + DoFlashParam param = { p, gce, FALSE, bManyFix }; + CallFunctionSync(stubFlash, ¶m); + } + + bManyFix++; + if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->bLoggingEnabled) + chatApi.LogToFile(p, gce); + } + + return 0; +} + EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) { BOOL bIsHighlighted = FALSE; @@ -471,7 +511,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) } else { // Send the event to all windows with a user pszUID. Used for broadcasting QUIT etc - chatApi.SM_AddEventToAllMatchingUID(gce); + AddEventToAllMatchingUID(gce); if (!bRemoveFlag) return 0; } @@ -480,7 +520,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) if (pWnd) { SESSION_INFO *si = chatApi.SM_FindSession(pWnd, pMod); - // fix for IRC's old stuyle mode notifications. Should not affect any other protocol + // fix for IRC's old style mode notifications. Should not affect any other protocol if ((gcd->iType == GC_EVENT_ADDSTATUS || gcd->iType == GC_EVENT_REMOVESTATUS) && !(gce->dwFlags & GCEF_ADDTOLOG)) return 0; @@ -491,8 +531,10 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) int isOk = chatApi.SM_AddEvent(pWnd, pMod, gce, bIsHighlighted); if (chatApi.OnAddLog) chatApi.OnAddLog(si, isOk); - if (!(gce->dwFlags & GCEF_NOTNOTIFY)) - chatApi.DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0); + if (!(gce->dwFlags & GCEF_NOTNOTIFY)) { + DoFlashParam param = { si, gce, bIsHighlighted, 0 }; + CallFunctionSync(stubFlash, ¶m); + } if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->bLoggingEnabled) chatApi.LogToFile(si, gce); } diff --git a/src/mir_app/src/clcfiledrop.cpp b/src/mir_app/src/clcfiledrop.cpp index 77ece42958..294a65e1a4 100644 --- a/src/mir_app/src/clcfiledrop.cpp +++ b/src/mir_app/src/clcfiledrop.cpp @@ -108,7 +108,7 @@ HRESULT CDropTarget::DragOver(DWORD /*grfKeyState*/, POINTL pt, DWORD * pdwEffec return S_OK; } cli.pfnTrayIconPauseAutoHide(0, 0); - ClcData *dat = (ClcData *) GetWindowLongPtr(hwndCurrentDrag, 0); + ClcData *dat = (ClcData*)GetWindowLongPtr(hwndCurrentDrag, 0); shortPt.x = pt.x; shortPt.y = pt.y; ScreenToClient(hwndCurrentDrag, &shortPt); -- cgit v1.2.3