summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Innes <andrewi@gnu.org>1999-07-01 19:47:32 +0000
committerAndrew Innes <andrewi@gnu.org>1999-07-01 19:47:32 +0000
commit8b031dcc5f69c3c436fdeb4695e4cd4bbe73e915 (patch)
treea842c2c3f09afaa39513996115e241d811068a1d
parent3945a18ace4501399b3b8f7ac3b44b531a0f7c8d (diff)
downloademacs-8b031dcc5f69c3c436fdeb4695e4cd4bbe73e915.tar.gz
(sys_select): Call MsgWaitForMultipleObjects instead
of WaitForMultipleObjects when user input is allowed, so we can handle incoming window messages. Call drain_message_queue when there are messages waiting; this ensures that windows created indirectly from the lisp thread get processed properly, and don't hang other applications by failing to respond to broadcasts.
-rw-r--r--src/w32proc.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/w32proc.c b/src/w32proc.c
index 8fcf3382da9..97ab6fcc150 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1175,9 +1175,15 @@ count_children:
return 0;
}
- /* Wait for input or child death to be signalled. */
start_time = GetTickCount ();
- active = WaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms);
+
+ /* Wait for input or child death to be signalled. If user input is
+ allowed, then also accept window messages. */
+ if (FD_ISSET (0, &orfds))
+ active = MsgWaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms,
+ QS_ALLINPUT);
+ else
+ active = WaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms);
if (active == WAIT_FAILED)
{
@@ -1213,7 +1219,26 @@ count_children:
processed - otherwise higher numbered channels could be starved. */
do
{
- if (active >= nh)
+ if (active == nh + nc)
+ {
+ /* There are messages in the lisp thread's queue; we must
+ drain the queue now to ensure they are processed promptly,
+ because if we don't do so, we will not be woken again until
+ further messages arrive.
+
+ NB. If ever we allow window message procedures to callback
+ into lisp, we will need to ensure messages are dispatched
+ at a safe time for lisp code to be run (*), and we may also
+ want to provide some hooks in the dispatch loop to cater
+ for modeless dialogs created by lisp (ie. to register
+ window handles to pass to IsDialogMessage).
+
+ (*) Note that MsgWaitForMultipleObjects above is an
+ internal dispatch point for messages that are sent to
+ windows created by this thread. */
+ drain_message_queue ();
+ }
+ else if (active >= nh)
{
cp = cps[active - nh];