Mercurial > emacs
comparison src/w32proc.c @ 24915:ff85091a55e7
(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.
author | Andrew Innes <andrewi@gnu.org> |
---|---|
date | Thu, 01 Jul 1999 19:47:32 +0000 |
parents | 65ebab3569e0 |
children | 9154af188477 |
comparison
equal
deleted
inserted
replaced
24914:71f071c1bdf7 | 24915:ff85091a55e7 |
---|---|
1173 if (timeout) | 1173 if (timeout) |
1174 Sleep (timeout_ms); | 1174 Sleep (timeout_ms); |
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 { |
1184 DebPrint (("select.WaitForMultipleObjects (%d, %lu) failed with %lu\n", | 1190 DebPrint (("select.WaitForMultipleObjects (%d, %lu) failed with %lu\n", |
1185 nh + nc, timeout_ms, GetLastError ())); | 1191 nh + nc, timeout_ms, GetLastError ())); |
1211 being the first signalled handle in the array). We do this to | 1217 being the first signalled handle in the array). We do this to |
1212 ensure fairness, so that all channels with data available will be | 1218 ensure fairness, so that all channels with data available will be |
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 |
1220 /* We cannot always signal SIGCHLD immediately; if we have not | 1245 /* We cannot always signal SIGCHLD immediately; if we have not |
1221 finished reading the process output, we must delay sending | 1246 finished reading the process output, we must delay sending |