summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2010-02-23 13:38:48 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2013-01-10 15:33:12 +0000
commitf57100bb36eae3b4d75f3c315973405f705b8de6 (patch)
treeb6ad0c9fb431460874fe9d22769de10b6ebba801 /hw
parente30e1ea98720acc583f34c830a1c1b7e3e88f694 (diff)
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>
Diffstat (limited to 'hw')
-rw-r--r--hw/xwin/winblock.c32
-rw-r--r--hw/xwin/winwakeup.c4
2 files changed, 18 insertions, 18 deletions
diff --git a/hw/xwin/winblock.c b/hw/xwin/winblock.c
index a4ae8669f..c3ef4becd 100644
--- a/hw/xwin/winblock.c
+++ b/hw/xwin/winblock.c
@@ -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,24 +80,12 @@ 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");
- }
-
- 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);
+ else {
+ winDebug("winBlockHandler - pthread_mutex_unlock () returned\n");
}
}
+#endif
/*
At least one X client has asked to suspend the screensaver, so
diff --git a/hw/xwin/winwakeup.c b/hw/xwin/winwakeup.c
index 77c160533..795221a1a 100644
--- a/hw/xwin/winwakeup.c
+++ b/hw/xwin/winwakeup.c
@@ -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))