From 65aaaa950c793e9408a42d352db919d487ef2a2f Mon Sep 17 00:00:00 2001 From: Rozhuk Ivan Date: Tue, 24 Mar 2015 02:53:25 +0000 Subject: * multiple WINE bug fixes over IsDialogMessage(), bug rep: https://bugs.winehq.org/show_bug.cgi?id=38276 git-svn-id: http://svn.miranda-ng.org/main/trunk@12489 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/modern_aniavatars.cpp | 3 +- plugins/ConnectionNotify/src/filter.cpp | 3 +- plugins/Console/src/Console.cpp | 2 +- plugins/Db_autobackups/src/backup.cpp | 2 +- plugins/HistoryStats/src/statistic.cpp | 2 +- plugins/SendScreenshotPlus/src/UMainForm.cpp | 6 +- plugins/TipperYM/src/message_pump.cpp | 173 ++++++++++----------- .../UserInfoEx/src/ex_import/dlg_ExImProgress.cpp | 2 +- plugins/YAMN/src/browser/mailbrowser.cpp | 7 +- plugins/YAPP/src/message_pump.cpp | 96 ++++++------ src/core/miranda.cpp | 2 +- src/mir_core/src/threads.cpp | 3 +- 12 files changed, 143 insertions(+), 158 deletions(-) diff --git a/plugins/Clist_modern/src/modern_aniavatars.cpp b/plugins/Clist_modern/src/modern_aniavatars.cpp index 3f27ffccec..c3c3c4a912 100644 --- a/plugins/Clist_modern/src/modern_aniavatars.cpp +++ b/plugins/Clist_modern/src/modern_aniavatars.cpp @@ -193,7 +193,8 @@ static void _AniAva_AnimationTreadProc(void*) if (rc == WAIT_OBJECT_0 + 1) { MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (IsDialogMessage(msg.hwnd, &msg)) continue; + if (msg.hwnd != NULL && IsDialogMessage(msg.hwnd, &msg)) /* Wine fix. */ + continue; TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/plugins/ConnectionNotify/src/filter.cpp b/plugins/ConnectionNotify/src/filter.cpp index c77ab89156..a3295c59b1 100644 --- a/plugins/ConnectionNotify/src/filter.cpp +++ b/plugins/ConnectionNotify/src/filter.cpp @@ -40,8 +40,7 @@ static unsigned __stdcall filterQueue(void *dummy) ShowWindow(filterAddDlg,SW_SHOW); } - if (NULL == filterAddDlg || !IsDialogMessage(filterAddDlg, &msg)) - { + if (NULL == filterAddDlg || !IsDialogMessage(filterAddDlg, &msg)) { /* Wine fix. */ TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/plugins/Console/src/Console.cpp b/plugins/Console/src/Console.cpp index fffcceddc0..50c07efb08 100644 --- a/plugins/Console/src/Console.cpp +++ b/plugins/Console/src/Console.cpp @@ -932,7 +932,7 @@ void __cdecl ConsoleThread(void *arg) break; } - if (IsDialogMessage(hwnd, &msg)) + if (hwnd != NULL && IsDialogMessage(hwnd, &msg)) /* Wine fix. */ continue; TranslateMessage(&msg); diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index a637ba7fe4..765a936daf 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -129,7 +129,7 @@ bool MakeZip(TCHAR *tszSource, TCHAR *tszDest, TCHAR *dbname, HWND progress_dial dwTotalBytes += dwRead; SendMessage(hProgBar, PBM_SETPOS, (WPARAM)((100 * dwTotalBytes) / dwSrcFileSize), 0); while (PeekMessage(&msg, progress_dialog, 0, 0, PM_REMOVE) != 0) { - if (!IsDialogMessage(progress_dialog, &msg)) { + if (progress_dialog == NULL || !IsDialogMessage(progress_dialog, &msg)) { /* Wine fix. */ TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/plugins/HistoryStats/src/statistic.cpp b/plugins/HistoryStats/src/statistic.cpp index 61647087cd..85ee17b7be 100644 --- a/plugins/HistoryStats/src/statistic.cpp +++ b/plugins/HistoryStats/src/statistic.cpp @@ -1274,7 +1274,7 @@ bool Statistic::createStatistics() break; } - if (!IsDialogMessage(msg.hwnd, &msg)) { + if (msg.hwnd == NULL || !IsDialogMessage(msg.hwnd, &msg)) { /* Wine fix. */ TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp index 2533f6e27b..6214ba2763 100644 --- a/plugins/SendScreenshotPlus/src/UMainForm.cpp +++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp @@ -1146,10 +1146,10 @@ void TfrmMain::FormClose() { break; } // process dialog messages (of unknown dialogs) -// HWND hwndDlgModeless=msg.hwnd; + HWND hwndDlgModeless = GetActiveWindow(); +// HWND hwndDlgModeless = msg.hwnd; // for(HWND hTMP; (hTMP=GetAncestor(hwndDlgModeless,GA_PARENT)) && IsChild(hTMP,hwndDlgModeless); hwndDlgModeless=hTMP); -// if(IsDialogMessage(hwndDlgModeless,&msg)) - if(IsDialogMessage(GetActiveWindow(),&msg)) + if(hwndDlgModeless != NULL && IsDialogMessage(hwndDlgModeless, &msg)) /* Wine fix. */ continue; // process messages TranslateMessage(&msg); diff --git a/plugins/TipperYM/src/message_pump.cpp b/plugins/TipperYM/src/message_pump.cpp index 598d9fb69b..6a17dd0aba 100644 --- a/plugins/TipperYM/src/message_pump.cpp +++ b/plugins/TipperYM/src/message_pump.cpp @@ -102,114 +102,99 @@ bool NeedWaitForContent(CLCINFOTIPEX *clcitex) unsigned int CALLBACK MessagePumpThread(void *param) { - HWND hwndTip = 0; - CLCINFOTIPEX *clcitex = 0; - + HWND hwndTip = NULL; + CLCINFOTIPEX *clcitex = NULL; MSG hwndMsg = {0}; - while (GetMessage(&hwndMsg, 0, 0, 0) > 0 && !Miranda_Terminated()) - { - if (!IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) - { - switch (hwndMsg.message) - { - case MUM_CREATEPOPUP: - { - if (!clcitex) - { - if (hwndMsg.lParam) clcitex = (CLCINFOTIPEX *)hwndMsg.lParam; - else break; - } - - if (!NeedWaitForContent(clcitex)) - { - if (hwndTip) MyDestroyWindow(hwndTip); - hwndTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)clcitex); - if (clcitex) - { - mir_free(clcitex); - clcitex = 0; - } - - bStatusMsgReady = false; - bAvatarReady = false; - } + while (GetMessage(&hwndMsg, NULL, 0, 0) > 0 && !Miranda_Terminated()) { + if (hwndMsg.hwnd != NULL && IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) /* Wine fix. */ + continue; + switch (hwndMsg.message) { + case MUM_CREATEPOPUP: + if (!clcitex) { + if (hwndMsg.lParam) + clcitex = (CLCINFOTIPEX*)hwndMsg.lParam; + else break; - } - case MUM_DELETEPOPUP: - { - if (hwndTip) { - MyDestroyWindow(hwndTip); - hwndTip = 0; - } + } - if (clcitex) { - mir_free(clcitex); - clcitex = 0; - } + if (!NeedWaitForContent(clcitex)) { + if (hwndTip) + MyDestroyWindow(hwndTip); + hwndTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)clcitex); - bStatusMsgReady = false; - bAvatarReady = false; - break; + if (clcitex) { + mir_free(clcitex); + clcitex = NULL; } - case MUM_GOTSTATUS: - { - MCONTACT hContact = (MCONTACT)hwndMsg.wParam; - TCHAR *swzMsg = (TCHAR *)hwndMsg.lParam; - if (opt.bWaitForContent && bStatusMsgReady == false && clcitex && clcitex->hItem == (HANDLE)hContact) { - if (WaitForContentTimerID) { - KillTimer(0, WaitForContentTimerID); - WaitForContentTimerID = 0; - } + bStatusMsgReady = false; + bAvatarReady = false; + } + break; + case MUM_DELETEPOPUP: + if (hwndTip) { + MyDestroyWindow(hwndTip); + hwndTip = 0; + } - if (swzMsg) { - db_set_ts((MCONTACT)clcitex->hItem, MODULE, "TempStatusMsg", swzMsg); - mir_free(swzMsg); - } + if (clcitex) { + mir_free(clcitex); + clcitex = NULL; + } - bStatusMsgReady = true; - PostMPMessage(MUM_CREATEPOPUP, 0, 0); + bStatusMsgReady = false; + bAvatarReady = false; + break; + case MUM_GOTSTATUS: + { + MCONTACT hContact = (MCONTACT)hwndMsg.wParam; + TCHAR *swzMsg = (TCHAR *)hwndMsg.lParam; + + if (opt.bWaitForContent && bStatusMsgReady == false && clcitex && clcitex->hItem == (HANDLE)hContact) { + if (WaitForContentTimerID) { + KillTimer(0, WaitForContentTimerID); + WaitForContentTimerID = 0; } - else if (!opt.bWaitForContent && hwndTip) - SendMessage(hwndTip, PUM_SETSTATUSTEXT, hContact, (LPARAM)swzMsg); - else if (swzMsg) + + if (swzMsg) { + db_set_ts((MCONTACT)clcitex->hItem, MODULE, "TempStatusMsg", swzMsg); mir_free(swzMsg); + } - break; - } - case MUM_GOTXSTATUS: - { - if (hwndTip && !opt.bWaitForContent) - SendMessage(hwndTip, PUM_SHOWXSTATUS, hwndMsg.wParam, 0); - break; + bStatusMsgReady = true; + PostMPMessage(MUM_CREATEPOPUP, 0, 0); } - case MUM_GOTAVATAR: - { - MCONTACT hContact = (MCONTACT)hwndMsg.wParam; - if (opt.bWaitForContent && bAvatarReady == false && clcitex && clcitex->hItem == (HANDLE)hContact) - { - if (WaitForContentTimerID) - { - KillTimer(0, WaitForContentTimerID); - WaitForContentTimerID = 0; - } - - bAvatarReady = true; - PostMPMessage(MUM_CREATEPOPUP, 0, 0); + else if (!opt.bWaitForContent && hwndTip) + SendMessage(hwndTip, PUM_SETSTATUSTEXT, hContact, (LPARAM)swzMsg); + else if (swzMsg) + mir_free(swzMsg); + } + break; + case MUM_GOTXSTATUS: + if (hwndTip && !opt.bWaitForContent) + SendMessage(hwndTip, PUM_SHOWXSTATUS, hwndMsg.wParam, 0); + break; + case MUM_GOTAVATAR: + { + MCONTACT hContact = (MCONTACT)hwndMsg.wParam; + if (opt.bWaitForContent && bAvatarReady == false && clcitex && clcitex->hItem == (HANDLE)hContact) { + if (WaitForContentTimerID) { + KillTimer(0, WaitForContentTimerID); + WaitForContentTimerID = 0; } - else if (!opt.bWaitForContent && hwndTip) - SendMessage(hwndTip, PUM_SETAVATAR, hwndMsg.wParam, 0); - break; - } - default: - { - TranslateMessage(&hwndMsg); - DispatchMessage(&hwndMsg); - break; + bAvatarReady = true; + PostMPMessage(MUM_CREATEPOPUP, 0, 0); } + else if (!opt.bWaitForContent && hwndTip) + SendMessage(hwndTip, PUM_SETAVATAR, hwndMsg.wParam, 0); } + break; + default: + TranslateMessage(&hwndMsg); + DispatchMessage(&hwndMsg); + break; } } @@ -250,7 +235,7 @@ INT_PTR ShowTip(WPARAM wParam, LPARAM lParam) { CLCINFOTIP *clcit = (CLCINFOTIP *)lParam; HWND clist = (HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0); - + if (clcit->isGroup) return 0; // no group tips (since they're pretty useless) if (clcit->isTreeFocused == 0 && opt.bShowNoFocus == false && clist == WindowFromPoint(clcit->ptCursor)) return 0; if (clcit->ptCursor.x == pt.x && clcit->ptCursor.y == pt.y) return 0; @@ -317,8 +302,8 @@ INT_PTR HideTip(WPARAM wParam, LPARAM lParam) int HideTipHook(WPARAM wParam, LPARAM lParam) { - HideTip(wParam, lParam); - return 0; + HideTip(wParam, lParam); + return 0; } int ProtoAck(WPARAM wParam, LPARAM lParam) diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp index 09bcaa0469..16d26c73d9 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp @@ -170,7 +170,7 @@ BYTE CProgress::Update() UpdateWindow(_hDlg); while (PeekMessage(&msg, _hDlg, 0, 0, PM_REMOVE) != 0) { - if (!IsDialogMessage(_hDlg, &msg)) { + if (_hDlg == NULL || !IsDialogMessage(_hDlg, &msg)) { /* Wine fix. */ TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/plugins/YAMN/src/browser/mailbrowser.cpp b/plugins/YAMN/src/browser/mailbrowser.cpp index 644ee20222..84596f43ce 100644 --- a/plugins/YAMN/src/browser/mailbrowser.cpp +++ b/plugins/YAMN/src/browser/mailbrowser.cpp @@ -1662,8 +1662,8 @@ CREADTEVIEWMESSAGEWINDOW: MyParam.mail->MsgWindow = CreateDialogParamW(YAMNVar.hInst,MAKEINTRESOURCEW(IDD_DLGSHOWMESSAGE),NULL,DlgProcYAMNShowMessage,(LPARAM)&MyParam); WindowList_Add(YAMNVar.MessageWnds,MyParam.mail->MsgWindow,NULL); MSG msg; - while(GetMessage(&msg,NULL,0,0)) { - if (!IsDialogMessage(MyParam.mail->MsgWindow, &msg)) { + while (GetMessage(&msg, NULL, 0, 0)) { + if (MyParam.mail->MsgWindow == NULL || !IsDialogMessage(MyParam.mail->MsgWindow, &msg)) { /* Wine fix. */ TranslateMessage(&msg); DispatchMessage(&msg); } } @@ -2534,8 +2534,7 @@ DWORD WINAPI MailBrowser(LPVOID Param) { while(GetMessage(&msg,NULL,0,0)) { - if (!IsDialogMessage(hMailBrowser, &msg)) - { + if (hMailBrowser == NULL || !IsDialogMessage(hMailBrowser, &msg)) { /* Wine fix. */ TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/plugins/YAPP/src/message_pump.cpp b/plugins/YAPP/src/message_pump.cpp index 3da223b89e..24b034001c 100644 --- a/plugins/YAPP/src/message_pump.cpp +++ b/plugins/YAPP/src/message_pump.cpp @@ -16,60 +16,60 @@ unsigned __stdcall MessagePumpThread(void* param) MSG hwndMsg = { 0 }; while (GetMessage(&hwndMsg, 0, 0, 0) > 0 && !bShutdown) { - if (!IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) { - switch(hwndMsg.message) { - case MUM_CREATEPOPUP: - { - bool enabled = true; - int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0); - if (status >= ID_STATUS_OFFLINE && status <= ID_STATUS_OUTTOLUNCH && options.disable_status[status - ID_STATUS_OFFLINE]) - enabled = false; - if ((options.disable_full_screen && IsFullScreen()) || IsWorkstationLocked()) - enabled = false; - - PopupData *pd = (PopupData*)hwndMsg.lParam; - if (enabled && num_popups < MAX_POPUPS) { - //HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, GetDesktopWindow(), 0, hInst, (LPVOID)hwndMsg.lParam); - HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)hwndMsg.lParam); - num_popups++; - if (hwndMsg.wParam) // set notifyer handle - SendMessage(hwnd, PUM_SETNOTIFYH, hwndMsg.wParam, 0); - } - else if (pd) { - mir_free(pd->pwzTitle); - mir_free(pd->pwzText); - mir_free(pd); - } + if (hwndMsg.hwnd != NULL && IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) /* Wine fix. */ + continue; + switch(hwndMsg.message) { + case MUM_CREATEPOPUP: + { + bool enabled = true; + int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0); + if (status >= ID_STATUS_OFFLINE && status <= ID_STATUS_OUTTOLUNCH && options.disable_status[status - ID_STATUS_OFFLINE]) + enabled = false; + if ((options.disable_full_screen && IsFullScreen()) || IsWorkstationLocked()) + enabled = false; + + PopupData *pd = (PopupData*)hwndMsg.lParam; + if (enabled && num_popups < MAX_POPUPS) { + //HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, GetDesktopWindow(), 0, hInst, (LPVOID)hwndMsg.lParam); + HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)hwndMsg.lParam); + num_popups++; + if (hwndMsg.wParam) // set notifyer handle + SendMessage(hwnd, PUM_SETNOTIFYH, hwndMsg.wParam, 0); } - break; - - case MUM_DELETEPOPUP: - { - HWND hwnd = (HWND)hwndMsg.lParam; - if (IsWindow(hwnd)) { - DestroyWindow(hwnd); - num_popups--; - } + else if (pd) { + mir_free(pd->pwzTitle); + mir_free(pd->pwzText); + mir_free(pd); } - break; + } + break; + + case MUM_DELETEPOPUP: + { + HWND hwnd = (HWND)hwndMsg.lParam; + if (IsWindow(hwnd)) { + DestroyWindow(hwnd); + num_popups--; + } + } + break; - case MUM_NMUPDATE: - BroadcastMessage(PUM_UPDATENOTIFY, hwndMsg.wParam, 0); - break; + case MUM_NMUPDATE: + BroadcastMessage(PUM_UPDATENOTIFY, hwndMsg.wParam, 0); + break; - case MUM_NMREMOVE: - BroadcastMessage(PUM_KILLNOTIFY, hwndMsg.wParam, 0); - break; + case MUM_NMREMOVE: + BroadcastMessage(PUM_KILLNOTIFY, hwndMsg.wParam, 0); + break; - case MUM_NMAVATAR: - RepositionWindows(); - break; + case MUM_NMAVATAR: + RepositionWindows(); + break; - default: - TranslateMessage(&hwndMsg); - DispatchMessage(&hwndMsg); - break; - } + default: + TranslateMessage(&hwndMsg); + DispatchMessage(&hwndMsg); + break; } } diff --git a/src/core/miranda.cpp b/src/core/miranda.cpp index c2f92d7e9d..b5b65f8d40 100644 --- a/src/core/miranda.cpp +++ b/src/core/miranda.cpp @@ -266,7 +266,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int) DWORD pid = 0; checkIdle(&msg); if (h != NULL && GetWindowThreadProcessId(h, &pid) && pid == myPid && GetClassLongPtr(h, GCW_ATOM) == 32770) - if (IsDialogMessage(h, &msg)) + if (h != NULL && IsDialogMessage(h, &msg)) /* Wine fix. */ continue; TranslateMessage(&msg); diff --git a/src/mir_core/src/threads.cpp b/src/mir_core/src/threads.cpp index 5ab917460f..237bc2ed97 100644 --- a/src/mir_core/src/threads.cpp +++ b/src/mir_core/src/threads.cpp @@ -44,7 +44,8 @@ static int MirandaWaitForMutex(HANDLE hEvent) if (rc == WAIT_OBJECT_0 + 1) { MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (IsDialogMessage(msg.hwnd, &msg)) continue; + if (msg.hwnd != NULL && IsDialogMessage(msg.hwnd, &msg)) /* Wine fix. */ + continue; TranslateMessage(&msg); DispatchMessage(&msg); } -- cgit v1.2.3