Don't rely on getting WM_NULL messages in wxIdleWakeUpModule
Since the switch to using an event object for idle handling wakeup, WM_NULLs are not being sent any longer, so wxIdleWakeUpModule didn't do anything, resulting in pending event dispatching being paused while our event loop was not running, as it happened, for example, while the window was resized. See #17579.
This commit is contained in:
@@ -103,6 +103,10 @@ public:
|
|||||||
// use it.
|
// use it.
|
||||||
static wxLayoutDirection MSWGetDefaultLayout(wxWindow* parent = NULL);
|
static wxLayoutDirection MSWGetDefaultLayout(wxWindow* parent = NULL);
|
||||||
|
|
||||||
|
// Call ProcessPendingEvents() but only if we need to do it, i.e. there was
|
||||||
|
// a recent call to WakeUpIdle().
|
||||||
|
void MSWProcessPendingEventsIfNeeded();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
|
int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
|
||||||
|
|
||||||
|
@@ -30,6 +30,10 @@ public:
|
|||||||
WXDWORD MSWWaitForThread(WXHANDLE hThread);
|
WXDWORD MSWWaitForThread(WXHANDLE hThread);
|
||||||
#endif // wxUSE_THREADS
|
#endif // wxUSE_THREADS
|
||||||
|
|
||||||
|
// Return true if wake up was requested and not handled yet, i.e. if
|
||||||
|
// m_heventWake is signaled.
|
||||||
|
bool MSWIsWakeUpRequested();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// get the next message from queue and return true or return false if we
|
// get the next message from queue and return true or return false if we
|
||||||
// got WM_QUIT or an error occurred
|
// got WM_QUIT or an error occurred
|
||||||
|
@@ -790,6 +790,16 @@ void wxApp::WakeUpIdle()
|
|||||||
evtLoop->WakeUp();
|
evtLoop->WakeUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxApp::MSWProcessPendingEventsIfNeeded()
|
||||||
|
{
|
||||||
|
// The cast below is safe as wxEventLoop derives from wxMSWEventLoopBase in
|
||||||
|
// both console and GUI applications.
|
||||||
|
wxMSWEventLoopBase * const evtLoop
|
||||||
|
= static_cast<wxMSWEventLoopBase *>(wxEventLoop::GetActive());
|
||||||
|
if ( evtLoop && evtLoop->MSWIsWakeUpRequested() )
|
||||||
|
ProcessPendingEvents();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// other wxApp event handlers
|
// other wxApp event handlers
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -71,6 +71,11 @@ void wxMSWEventLoopBase::WakeUp()
|
|||||||
wxLogLastError(wxS("SetEvent(wake)"));
|
wxLogLastError(wxS("SetEvent(wake)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxMSWEventLoopBase::MSWIsWakeUpRequested()
|
||||||
|
{
|
||||||
|
return ::WaitForSingleObject(m_heventWake, 0) == WAIT_OBJECT_0;
|
||||||
|
}
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
|
|
||||||
WXDWORD wxMSWEventLoopBase::MSWWaitForThread(WXHANDLE hThread)
|
WXDWORD wxMSWEventLoopBase::MSWWaitForThread(WXHANDLE hThread)
|
||||||
|
@@ -7511,10 +7511,9 @@ bool wxWindowMSW::HandleHotKey(WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
#endif // wxUSE_HOTKEY
|
#endif // wxUSE_HOTKEY
|
||||||
|
|
||||||
// this class installs a message hook which really wakes up our idle processing
|
// this class installs a message hook which really wakes up our idle processing
|
||||||
// each time a WM_NULL is received (wxWakeUpIdle does this), even if we're
|
// each time a message is handled, even if we're sitting inside a local modal
|
||||||
// sitting inside a local modal loop (e.g. a menu is opened or scrollbar is
|
// loop (e.g. a menu is opened or scrollbar is being dragged or even inside
|
||||||
// being dragged or even inside ::MessageBox()) and so don't control message
|
// ::MessageBox()) and so don't control message dispatching otherwise
|
||||||
// dispatching otherwise
|
|
||||||
class wxIdleWakeUpModule : public wxModule
|
class wxIdleWakeUpModule : public wxModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -7545,15 +7544,11 @@ public:
|
|||||||
|
|
||||||
static LRESULT CALLBACK MsgHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK MsgHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
MSG *msg = (MSG*)lParam;
|
// Don't process idle events unless the message is going to be really
|
||||||
|
// handled, i.e. removed from the queue, as it seems wrong to do it
|
||||||
// only process the message if it is actually going to be removed from
|
// just because someone called PeekMessage(PM_NOREMOVE).
|
||||||
// the message queue, this prevents that the same event from being
|
if ( wParam == PM_REMOVE )
|
||||||
// processed multiple times if now someone just called PeekMessage()
|
wxTheApp->MSWProcessPendingEventsIfNeeded();
|
||||||
if ( msg->message == WM_NULL && wParam == PM_REMOVE )
|
|
||||||
{
|
|
||||||
wxTheApp->ProcessPendingEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
return CallNextHookEx(ms_hMsgHookProc, nCode, wParam, lParam);
|
return CallNextHookEx(ms_hMsgHookProc, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user