Mercurial > hg > xemacs-beta
comparison src/event-stream.c @ 8:4b173ad71786 r19-15b5
Import from CVS: tag r19-15b5
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:47:35 +0200 |
parents | b82b59fe008d |
children | 9ee227acff29 |
comparison
equal
deleted
inserted
replaced
7:c153ca296910 | 8:4b173ad71786 |
---|---|
1192 event_stream_remove_async_timeout (timeout->interval_id); | 1192 event_stream_remove_async_timeout (timeout->interval_id); |
1193 else | 1193 else |
1194 event_stream_remove_timeout (timeout->interval_id); | 1194 event_stream_remove_timeout (timeout->interval_id); |
1195 free_managed_opaque (Vtimeout_free_list, op); | 1195 free_managed_opaque (Vtimeout_free_list, op); |
1196 } | 1196 } |
1197 } | |
1198 | |
1199 int | |
1200 event_stream_wakeup_pending_p (int id, int async_p) | |
1201 { | |
1202 struct timeout *timeout; | |
1203 Lisp_Object rest = Qnil; | |
1204 Lisp_Object timeout_list; | |
1205 int found = 0; | |
1206 | |
1207 | |
1208 if (async_p) | |
1209 timeout_list = pending_async_timeout_list; | |
1210 else | |
1211 timeout_list = pending_timeout_list; | |
1212 | |
1213 /* Find the element on the list of pending ones, if it's still there. */ | |
1214 LIST_LOOP (rest, timeout_list) | |
1215 { | |
1216 timeout = (struct timeout *) XOPAQUE_DATA (XCAR (rest)); | |
1217 if (timeout->id == id) | |
1218 { | |
1219 found = 1; | |
1220 break; | |
1221 } | |
1222 } | |
1223 | |
1224 return found; | |
1197 } | 1225 } |
1198 | 1226 |
1199 | 1227 |
1200 /**** Asynch. timeout functions (see also signal.c) ****/ | 1228 /**** Asynch. timeout functions (see also signal.c) ****/ |
1201 | 1229 |
2401 loop will process it, and I don't think that there is ever a | 2429 loop will process it, and I don't think that there is ever a |
2402 time when one calls accept-process-output with a nil argument | 2430 time when one calls accept-process-output with a nil argument |
2403 and really need the processes to be handled. */ | 2431 and really need the processes to be handled. */ |
2404 || (!EQ (result, Qt) && event_stream_event_pending_p (0))) | 2432 || (!EQ (result, Qt) && event_stream_event_pending_p (0))) |
2405 { | 2433 { |
2434 /* If our timeout has arrived, we move along. */ | |
2435 if (!event_stream_wakeup_pending_p (timeout_id, 0)) | |
2436 { | |
2437 timeout_enabled = 0; | |
2438 process = Qnil; /* We're done. */ | |
2439 } | |
2440 | |
2406 QUIT; /* next_event_internal() does not QUIT, so check for ^G | 2441 QUIT; /* next_event_internal() does not QUIT, so check for ^G |
2407 before reading output from the process - this makes it | 2442 before reading output from the process - this makes it |
2408 less likely that the filter will actually be aborted. | 2443 less likely that the filter will actually be aborted. |
2409 */ | 2444 */ |
2410 | 2445 |
2427 | 2462 |
2428 execute_internal_event (event); | 2463 execute_internal_event (event); |
2429 break; | 2464 break; |
2430 } | 2465 } |
2431 case timeout_event: | 2466 case timeout_event: |
2432 { | 2467 /* We execute the event even if it's ours, and notice that it's |
2433 if (timeout_enabled && | 2468 happened above. */ |
2434 XEVENT (event)->event.timeout.id_number == timeout_id) | |
2435 { | |
2436 timeout_enabled = 0; | |
2437 process = Qnil; /* we're done */ | |
2438 } | |
2439 else /* a timeout that's not the one we're waiting for */ | |
2440 goto EXECUTE_INTERNAL; | |
2441 break; | |
2442 } | |
2443 case pointer_motion_event: | 2469 case pointer_motion_event: |
2444 case magic_event: | 2470 case magic_event: |
2445 { | 2471 { |
2446 EXECUTE_INTERNAL: | |
2447 execute_internal_event (event); | 2472 execute_internal_event (event); |
2448 break; | 2473 break; |
2449 } | 2474 } |
2450 default: | 2475 default: |
2451 { | 2476 { |
2482 | 2507 |
2483 id = event_stream_generate_wakeup (msecs, 0, Qnil, Qnil, 0); | 2508 id = event_stream_generate_wakeup (msecs, 0, Qnil, Qnil, 0); |
2484 event = Fmake_event (); | 2509 event = Fmake_event (); |
2485 while (1) | 2510 while (1) |
2486 { | 2511 { |
2512 /* If our timeout has arrived, we move along. */ | |
2513 if (!event_stream_wakeup_pending_p (id, 0)) | |
2514 goto DONE_LABEL; | |
2515 | |
2487 QUIT; /* next_event_internal() does not QUIT, so check for ^G | 2516 QUIT; /* next_event_internal() does not QUIT, so check for ^G |
2488 before reading output from the process - this makes it | 2517 before reading output from the process - this makes it |
2489 less likely that the filter will actually be aborted. | 2518 less likely that the filter will actually be aborted. |
2490 */ | 2519 */ |
2491 /* We're a generator of the command_event_queue, so we can't be a | 2520 /* We're a generator of the command_event_queue, so we can't be a |
2495 next_event_internal (event, 0); /* blocks */ | 2524 next_event_internal (event, 0); /* blocks */ |
2496 /* See the comment in accept-process-output about Vquit_flag */ | 2525 /* See the comment in accept-process-output about Vquit_flag */ |
2497 switch (XEVENT_TYPE (event)) | 2526 switch (XEVENT_TYPE (event)) |
2498 { | 2527 { |
2499 case timeout_event: | 2528 case timeout_event: |
2500 { | 2529 /* We execute the event even if it's ours, and notice that it's |
2501 if (XEVENT (event)->event.timeout.id_number == id) | 2530 happened above. */ |
2502 goto DONE_LABEL; | |
2503 else | |
2504 goto EXECUTE_INTERNAL; | |
2505 } | |
2506 case pointer_motion_event: | 2531 case pointer_motion_event: |
2507 case process_event: | 2532 case process_event: |
2508 case magic_event: | 2533 case magic_event: |
2509 { | 2534 { |
2510 EXECUTE_INTERNAL: | 2535 EXECUTE_INTERNAL: |
2585 { | 2610 { |
2586 run_pre_idle_hook (); | 2611 run_pre_idle_hook (); |
2587 redisplay (); | 2612 redisplay (); |
2588 } | 2613 } |
2589 | 2614 |
2590 /* If we're no longer waiting for a timeout, bug out. */ | 2615 /* If our timeout has arrived, we move along. */ |
2591 if (! id) | 2616 if (!event_stream_wakeup_pending_p (id, 0)) |
2592 { | 2617 { |
2593 result = Qt; | 2618 result = Qt; |
2594 goto DONE_LABEL; | 2619 goto DONE_LABEL; |
2595 } | 2620 } |
2596 | 2621 |
2617 /* eval-events get delayed until later. */ | 2642 /* eval-events get delayed until later. */ |
2618 enqueue_command_event (Fcopy_event (event, Qnil)); | 2643 enqueue_command_event (Fcopy_event (event, Qnil)); |
2619 break; | 2644 break; |
2620 } | 2645 } |
2621 case timeout_event: | 2646 case timeout_event: |
2622 { | 2647 /* We execute the event even if it's ours, and notice that it's |
2623 if (XEVENT (event)->event.timeout.id_number != id) | 2648 happened above. */ |
2624 /* a timeout that wasn't the one we're waiting for */ | 2649 default: |
2625 goto EXECUTE_INTERNAL; | |
2626 id = 0; /* assert that we are no longer waiting for it. */ | |
2627 result = Qt; | |
2628 goto DONE_LABEL; | |
2629 } | |
2630 default: | |
2631 { | 2650 { |
2632 EXECUTE_INTERNAL: | 2651 EXECUTE_INTERNAL: |
2633 execute_internal_event (event); | 2652 execute_internal_event (event); |
2634 break; | 2653 break; |
2635 } | 2654 } |
2636 } | 2655 } |
2637 } | 2656 } |
2638 | 2657 |
2639 DONE_LABEL: | 2658 DONE_LABEL: |
2640 /* If our timeout has not been signalled yet, disable it. */ | 2659 /* If our timeout has not been signalled yet, disable it. */ |
2641 if (id) | 2660 if (NILP (result)) |
2642 event_stream_disable_wakeup (id, 0); | 2661 event_stream_disable_wakeup (id, 0); |
2643 | 2662 |
2644 /* Put back the event (if any) that made Fsit_for() exit before the | 2663 /* Put back the event (if any) that made Fsit_for() exit before the |
2645 timeout. Note that it is being added to the back of the queue, which | 2664 timeout. Note that it is being added to the back of the queue, which |
2646 would be inappropriate if there were any user events on the queue | 2665 would be inappropriate if there were any user events on the queue |