diff options
| author | Andrew Innes | 1999-07-01 19:47:32 +0000 |
|---|---|---|
| committer | Andrew Innes | 1999-07-01 19:47:32 +0000 |
| commit | 8b031dcc5f69c3c436fdeb4695e4cd4bbe73e915 (patch) | |
| tree | a842c2c3f09afaa39513996115e241d811068a1d /src/w32proc.c | |
| parent | 3945a18ace4501399b3b8f7ac3b44b531a0f7c8d (diff) | |
| download | emacs-8b031dcc5f69c3c436fdeb4695e4cd4bbe73e915.tar.gz emacs-8b031dcc5f69c3c436fdeb4695e4cd4bbe73e915.zip | |
(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.
Diffstat (limited to 'src/w32proc.c')
| -rw-r--r-- | src/w32proc.c | 31 |
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: | |||
| 1175 | return 0; | 1175 | return 0; |
| 1176 | } | 1176 | } |
| 1177 | 1177 | ||
| 1178 | /* Wait for input or child death to be signalled. */ | ||
| 1179 | start_time = GetTickCount (); | 1178 | start_time = GetTickCount (); |
| 1180 | active = WaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms); | 1179 | |
| 1180 | /* Wait for input or child death to be signalled. If user input is | ||
| 1181 | allowed, then also accept window messages. */ | ||
| 1182 | if (FD_ISSET (0, &orfds)) | ||
| 1183 | active = MsgWaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms, | ||
| 1184 | QS_ALLINPUT); | ||
| 1185 | else | ||
| 1186 | active = WaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms); | ||
| 1181 | 1187 | ||
| 1182 | if (active == WAIT_FAILED) | 1188 | if (active == WAIT_FAILED) |
| 1183 | { | 1189 | { |
| @@ -1213,7 +1219,26 @@ count_children: | |||
| 1213 | processed - otherwise higher numbered channels could be starved. */ | 1219 | processed - otherwise higher numbered channels could be starved. */ |
| 1214 | do | 1220 | do |
| 1215 | { | 1221 | { |
| 1216 | if (active >= nh) | 1222 | if (active == nh + nc) |
| 1223 | { | ||
| 1224 | /* There are messages in the lisp thread's queue; we must | ||
| 1225 | drain the queue now to ensure they are processed promptly, | ||
| 1226 | because if we don't do so, we will not be woken again until | ||
| 1227 | further messages arrive. | ||
| 1228 | |||
| 1229 | NB. If ever we allow window message procedures to callback | ||
| 1230 | into lisp, we will need to ensure messages are dispatched | ||
| 1231 | at a safe time for lisp code to be run (*), and we may also | ||
| 1232 | want to provide some hooks in the dispatch loop to cater | ||
| 1233 | for modeless dialogs created by lisp (ie. to register | ||
| 1234 | window handles to pass to IsDialogMessage). | ||
| 1235 | |||
| 1236 | (*) Note that MsgWaitForMultipleObjects above is an | ||
| 1237 | internal dispatch point for messages that are sent to | ||
| 1238 | windows created by this thread. */ | ||
| 1239 | drain_message_queue (); | ||
| 1240 | } | ||
| 1241 | else if (active >= nh) | ||
| 1217 | { | 1242 | { |
| 1218 | cp = cps[active - nh]; | 1243 | cp = cps[active - nh]; |
| 1219 | 1244 | ||