From 1be3c6c424085c953b1e63f922ca0c349b364c8b Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Fri, 15 Jan 2010 12:35:53 -0800 Subject: [PATCH] Bug 539061 - 'OOPP: ASSERTION: Received "nonqueued" message 31, 10'. r=jimm. --- ipc/glue/WindowsMessageLoop.cpp | 109 +++++++++++++------------------- ipc/glue/WindowsMessageLoop.h | 24 ++----- 2 files changed, 48 insertions(+), 85 deletions(-) diff --git a/ipc/glue/WindowsMessageLoop.cpp b/ipc/glue/WindowsMessageLoop.cpp index a2830917288..fa01b1b3f3f 100644 --- a/ipc/glue/WindowsMessageLoop.cpp +++ b/ipc/glue/WindowsMessageLoop.cpp @@ -173,12 +173,15 @@ ProcessOrDeferMessage(HWND hwnd, // their wParam or lParam arguments! case WM_ACTIVATE: case WM_ACTIVATEAPP: + case WM_CANCELMODE: case WM_CAPTURECHANGED: case WM_CHILDACTIVATE: case WM_DESTROY: + case WM_ENABLE: case WM_IME_NOTIFY: case WM_IME_SETCONTEXT: case WM_KILLFOCUS: + case WM_MOUSEWHEEL: case WM_NCDESTROY: case WM_PARENTNOTIFY: case WM_SETFOCUS: @@ -188,6 +191,8 @@ ProcessOrDeferMessage(HWND hwnd, break; } + case WM_DEVICECHANGE: + case WM_NCACTIVATE: // Intentional fall-through. case WM_SETCURSOR: { // Friggin unconventional return value... res = TRUE; @@ -195,12 +200,6 @@ ProcessOrDeferMessage(HWND hwnd, break; } - case WM_NCACTIVATE: { - res = TRUE; - deferred = new DeferredNCActivateMessage(hwnd, uMsg, wParam, lParam); - break; - } - case WM_MOUSEACTIVATE: { res = MA_NOACTIVATE; deferred = new DeferredSendMessage(hwnd, uMsg, wParam, lParam); @@ -237,18 +236,15 @@ ProcessOrDeferMessage(HWND hwnd, } // These messages are faked via a call to SetWindowPos. - case WM_WINDOWPOSCHANGED: // Intentional fall-through. - case WM_WINDOWPOSCHANGING: { - UINT flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | - SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_DEFERERASE; - deferred = new DeferredWindowPosMessage(hwnd, flags); + case WM_WINDOWPOSCHANGED: { + deferred = new DeferredWindowPosMessage(hwnd, lParam); break; } case WM_NCCALCSIZE: { UINT flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_DEFERERASE | SWP_NOSENDCHANGING; - deferred = new DeferredWindowPosMessage(hwnd, flags); + deferred = new DeferredWindowPosMessage(hwnd, lParam, true, flags); break; } @@ -257,8 +253,9 @@ ProcessOrDeferMessage(HWND hwnd, case WM_GETMINMAXINFO: case WM_GETTEXT: case WM_NCHITTEST: - case WM_SETICON: // Intentional fall-through. - case WM_SYNCPAINT: { + case WM_SETICON: + case WM_SYNCPAINT: // Intentional fall-through. + case WM_WINDOWPOSCHANGING: { return DefWindowProc(hwnd, uMsg, wParam, lParam); } @@ -664,66 +661,48 @@ DeferredSettingChangeMessage::~DeferredSettingChangeMessage() } } +DeferredWindowPosMessage::DeferredWindowPosMessage(HWND aHWnd, + LPARAM aLParam, + bool aUseCustomFlags, + UINT aFlags) +{ + WINDOWPOS* source = reinterpret_cast(aLParam); + memcpy(&windowPos, source, sizeof(windowPos)); + NS_ASSERTION(aHWnd == source->hwnd, "Mismatched hwnds!"); + if (aUseCustomFlags) { + windowPos.flags = aFlags; + } + else { + // Windows sends in some private flags sometimes that we can't simply copy. + // Filter here. + UINT mask = SWP_ASYNCWINDOWPOS | SWP_DEFERERASE | SWP_DRAWFRAME | + SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_NOACTIVATE | + SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | + SWP_NOREPOSITION | SWP_NOSENDCHANGING | SWP_NOSIZE | + SWP_NOZORDER | SWP_SHOWWINDOW; + windowPos.flags &= mask; + } +} + void DeferredWindowPosMessage::Run() { - AssertWindowIsNotNeutered(hWnd); - if (!IsWindow(hWnd)) { + AssertWindowIsNotNeutered(windowPos.hwnd); + if (!IsWindow(windowPos.hwnd)) { NS_ERROR("Invalid window!"); return; } + if (!IsWindow(windowPos.hwndInsertAfter)) { + NS_WARNING("ZOrder change cannot be honored"); + windowPos.hwndInsertAfter = 0; + windowPos.flags |= SWP_NOZORDER; + } + #ifdef DEBUG BOOL ret = #endif - SetWindowPos(hWnd, 0, 0, 0, 0, 0, flags); + SetWindowPos(windowPos.hwnd, windowPos.hwndInsertAfter, windowPos.x, + windowPos.y, windowPos.cx, windowPos.cy, windowPos.flags); NS_ASSERTION(ret, "SetWindowPos failed!"); } - -DeferredNCActivateMessage::DeferredNCActivateMessage(HWND aHWnd, - UINT aMessage, - WPARAM aWParam, - LPARAM aLParam) -: DeferredSendMessage(aHWnd, aMessage, aWParam, aLParam), - region(NULL) -{ - NS_ASSERTION(aMessage == WM_NCACTIVATE, "Wrong message!"); - if (aLParam) { - // This is a window that doesn't have a visual style and so lParam is a - // handle to an update region. We need to duplicate it. - HRGN source = reinterpret_cast(aLParam); - - DWORD dataSize = GetRegionData(source, 0, NULL); - if (!dataSize) { - NS_ERROR("GetRegionData failed!"); - return; - } - - nsAutoArrayPtr buffer = new char[dataSize]; - NS_ASSERTION(buffer, "Out of memory!"); - - RGNDATA* data = reinterpret_cast(buffer.get()); - - dataSize = GetRegionData(source, dataSize, data); - if (!dataSize) { - NS_ERROR("GetRegionData failed!"); - return; - } - - HRGN tempRegion = ExtCreateRegion(NULL, dataSize, data); - if (!tempRegion) { - NS_ERROR("ExtCreateRegion failed!"); - return; - } - - region = tempRegion; - lParam = reinterpret_cast(region); - } -} - -DeferredNCActivateMessage::~DeferredNCActivateMessage() -{ - if (region) { - DeleteObject(region); - } -} diff --git a/ipc/glue/WindowsMessageLoop.h b/ipc/glue/WindowsMessageLoop.h index 34aed0679dd..1b029165e6c 100644 --- a/ipc/glue/WindowsMessageLoop.h +++ b/ipc/glue/WindowsMessageLoop.h @@ -144,30 +144,14 @@ class DeferredWindowPosMessage : public DeferredMessage { public: DeferredWindowPosMessage(HWND aHWnd, - UINT aFlags) - : hWnd(aHWnd), - flags(aFlags) - { } + LPARAM aLParam, + bool aUseCustomFlags = false, + UINT aFlags = 0); virtual void Run(); private: - HWND hWnd; - UINT flags; -}; - -class DeferredNCActivateMessage : public DeferredSendMessage -{ -public: - DeferredNCActivateMessage(HWND aHWnd, - UINT aMessage, - WPARAM aWParam, - LPARAM aLParam); - - ~DeferredNCActivateMessage(); - -private: - HRGN region; + WINDOWPOS windowPos; }; } /* namespace windows */