X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/22cfea03b8abd902001dd2a9a1b9f61a8cf3d69e..169adfa9c4b781f737920bc808da91cd926c3e36:/src/msw/evtloop.cpp diff --git a/src/msw/evtloop.cpp b/src/msw/evtloop.cpp index b329452419..54ac1c55cd 100644 --- a/src/msw/evtloop.cpp +++ b/src/msw/evtloop.cpp @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "evtloop.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -44,12 +40,12 @@ #if wxUSE_THREADS #include "wx/thread.h" - // define the array of MSG strutures - WX_DECLARE_OBJARRAY(MSG, wxMsgArray); + // define the list of MSG strutures + WX_DECLARE_LIST(MSG, wxMsgList); - #include "wx/arrimpl.cpp" + #include "wx/listimpl.cpp" - WX_DEFINE_OBJARRAY(wxMsgArray); + WX_DEFINE_LIST(wxMsgList) #endif // wxUSE_THREADS // ---------------------------------------------------------------------------- @@ -85,6 +81,7 @@ private: // ============================================================================ wxEventLoop *wxEventLoopBase::ms_activeLoop = NULL; +wxWindowMSW *wxEventLoop::ms_winCritical = NULL; // ---------------------------------------------------------------------------- // ctor/dtor @@ -111,12 +108,26 @@ void wxEventLoop::ProcessMessage(WXMSG *msg) } } +bool wxEventLoop::IsChildOfCriticalWindow(wxWindowMSW *win) +{ + while ( win ) + { + if ( win == ms_winCritical ) + return true; + + win = win->GetParent(); + } + + return false; +} + bool wxEventLoop::PreProcessMessage(WXMSG *msg) { HWND hwnd = msg->hwnd; - wxWindow *wndThis = wxGetWindowFromHWND((WXHWND)hwnd); + wxWindow * const wndThis = wxGetWindowFromHWND((WXHWND)hwnd); + wxWindow *wnd; - // this may happen if the event occured in a standard modeless dialog (the + // this may happen if the event occurred in a standard modeless dialog (the // only example of which I know of is the find/replace dialog) - then call // IsDialogMessage() to make TAB navigation in it work if ( !wndThis ) @@ -132,6 +143,17 @@ bool wxEventLoop::PreProcessMessage(WXMSG *msg) return hwnd && ::IsDialogMessage(hwnd, msg) != 0; } + if ( !AllowProcessing(wndThis) ) + { + // not a child of critical window, so we eat the event but take care to + // stop an endless stream of WM_PAINTs which would have resulted if we + // didn't validate the invalidated part of the window + if ( msg->message == WM_PAINT ) + ::ValidateRect(hwnd, NULL); + + return true; + } + #if wxUSE_TOOLTIPS // we must relay WM_MOUSEMOVE events to the tooltip ctrl if we want it to // popup the tooltip bubbles @@ -154,8 +176,6 @@ bool wxEventLoop::PreProcessMessage(WXMSG *msg) } // try translations first: the accelerators override everything - wxWindow *wnd; - for ( wnd = wndThis; wnd; wnd = wnd->GetParent() ) { if ( wnd->MSWTranslateMessage((WXMSG *)msg)) @@ -337,7 +357,7 @@ bool wxEventLoop::Dispatch() wxT("only the main thread can process Windows messages") ); static bool s_hadGuiLock = true; - static wxMsgArray s_aSavedMessages; + static wxMsgList s_aSavedMessages; // if a secondary thread owning the mutex is doing GUI calls, save all // messages for later processing - we can't process them right now because @@ -350,7 +370,8 @@ bool wxEventLoop::Dispatch() // the message will be processed twice if ( !wxIsWaitingForThread() || msg.message != WM_COMMAND ) { - s_aSavedMessages.Add(msg); + MSG* pMsg = new MSG(msg); + s_aSavedMessages.Append(pMsg); } return true; @@ -366,14 +387,17 @@ bool wxEventLoop::Dispatch() { s_hadGuiLock = true; - size_t count = s_aSavedMessages.Count(); - for ( size_t n = 0; n < count; n++ ) + wxMsgList::compatibility_iterator node = s_aSavedMessages.GetFirst(); + while (node) { - MSG& msg = s_aSavedMessages[n]; - ProcessMessage(&msg); - } + MSG* pMsg = node->GetData(); + s_aSavedMessages.Erase(node); - s_aSavedMessages.Empty(); + ProcessMessage(pMsg); + delete pMsg; + + node = s_aSavedMessages.GetFirst(); + } } } #endif // wxUSE_THREADS