hw/xwin: Process one Windows message per wakeup, rather than all of them.
De-queuing Windows messages and X events happens in the same thread of execution. Draining the windows message queue can lead to the X event queue overflowing if lots of those windows messages cause X events (e.g. if a keyboard macro program has just dumped thousands of keypresses into the Windows message queue). See the mailing list thread [1] for more details. Processing one Windows message per wakeup, rather than all of them gives the X server a chance to do stuff as well after each message. [1] http://cygwin.com/ml/cygwin-xfree/2010-01/msg00056.html Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
parent
e30e1ea987
commit
f57100bb36
|
@ -42,14 +42,26 @@ winBlockHandler(ScreenPtr pScreen,
|
|||
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
|
||||
winScreenPriv(pScreen);
|
||||
#endif
|
||||
MSG msg;
|
||||
|
||||
#ifndef HAS_DEVWINDOWS
|
||||
struct timeval **tvp = pTimeout;
|
||||
|
||||
if (*tvp != NULL) {
|
||||
if (GetQueueStatus(QS_ALLINPUT | QS_ALLPOSTMESSAGE) != 0) {
|
||||
/* If there are still messages to process on the Windows message
|
||||
queue, make sure select() just polls rather than blocking.
|
||||
*/
|
||||
(*tvp)->tv_sec = 0;
|
||||
(*tvp)->tv_usec = 0;
|
||||
}
|
||||
else {
|
||||
/* Otherwise, lacking /dev/windows, we must wake up again in
|
||||
a reasonable time to check the Windows message queue. without
|
||||
noticeable delay.
|
||||
*/
|
||||
(*tvp)->tv_sec = 0;
|
||||
(*tvp)->tv_usec = 100;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -68,25 +80,13 @@ winBlockHandler(ScreenPtr pScreen,
|
|||
if (iReturn != 0) {
|
||||
ErrorF("winBlockHandler - pthread_mutex_unlock () failed: %d\n",
|
||||
iReturn);
|
||||
goto winBlockHandler_ProcessMessages;
|
||||
}
|
||||
|
||||
winDebug("winBlockHandler - pthread_mutex_unlock () returned\n");
|
||||
else {
|
||||
winDebug("winBlockHandler - pthread_mutex_unlock () returned\n");
|
||||
}
|
||||
}
|
||||
|
||||
winBlockHandler_ProcessMessages:
|
||||
#endif
|
||||
|
||||
/* Process all messages on our queue */
|
||||
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
if ((g_hDlgDepthChange == 0
|
||||
|| !IsDialogMessage(g_hDlgDepthChange, &msg))
|
||||
&& (g_hDlgExit == 0 || !IsDialogMessage(g_hDlgExit, &msg))
|
||||
&& (g_hDlgAbout == 0 || !IsDialogMessage(g_hDlgAbout, &msg))) {
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
At least one X client has asked to suspend the screensaver, so
|
||||
reset Windows' display idle timer
|
||||
|
|
|
@ -43,8 +43,8 @@ winWakeupHandler(ScreenPtr pScreen,
|
|||
{
|
||||
MSG msg;
|
||||
|
||||
/* Process all messages on our queue */
|
||||
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
/* Process one message from our queue */
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
if ((g_hDlgDepthChange == 0
|
||||
|| !IsDialogMessage(g_hDlgDepthChange, &msg))
|
||||
&& (g_hDlgExit == 0 || !IsDialogMessage(g_hDlgExit, &msg))
|
||||
|
|
Loading…
Reference in New Issue