Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- a/src/event-stream.c Mon Aug 13 08:47:16 2007 +0200 +++ b/src/event-stream.c Mon Aug 13 08:47:35 2007 +0200 @@ -1196,6 +1196,34 @@ } } +int +event_stream_wakeup_pending_p (int id, int async_p) +{ + struct timeout *timeout; + Lisp_Object rest = Qnil; + Lisp_Object timeout_list; + int found = 0; + + + if (async_p) + timeout_list = pending_async_timeout_list; + else + timeout_list = pending_timeout_list; + + /* Find the element on the list of pending ones, if it's still there. */ + LIST_LOOP (rest, timeout_list) + { + timeout = (struct timeout *) XOPAQUE_DATA (XCAR (rest)); + if (timeout->id == id) + { + found = 1; + break; + } + } + + return found; +} + /**** Asynch. timeout functions (see also signal.c) ****/ @@ -2403,6 +2431,13 @@ and really need the processes to be handled. */ || (!EQ (result, Qt) && event_stream_event_pending_p (0))) { + /* If our timeout has arrived, we move along. */ + if (!event_stream_wakeup_pending_p (timeout_id, 0)) + { + timeout_enabled = 0; + process = Qnil; /* We're done. */ + } + QUIT; /* next_event_internal() does not QUIT, so check for ^G before reading output from the process - this makes it less likely that the filter will actually be aborted. @@ -2429,21 +2464,11 @@ break; } case timeout_event: - { - if (timeout_enabled && - XEVENT (event)->event.timeout.id_number == timeout_id) - { - timeout_enabled = 0; - process = Qnil; /* we're done */ - } - else /* a timeout that's not the one we're waiting for */ - goto EXECUTE_INTERNAL; - break; - } + /* We execute the event even if it's ours, and notice that it's + happened above. */ case pointer_motion_event: case magic_event: { - EXECUTE_INTERNAL: execute_internal_event (event); break; } @@ -2484,6 +2509,10 @@ event = Fmake_event (); while (1) { + /* If our timeout has arrived, we move along. */ + if (!event_stream_wakeup_pending_p (id, 0)) + goto DONE_LABEL; + QUIT; /* next_event_internal() does not QUIT, so check for ^G before reading output from the process - this makes it less likely that the filter will actually be aborted. @@ -2497,12 +2526,8 @@ switch (XEVENT_TYPE (event)) { case timeout_event: - { - if (XEVENT (event)->event.timeout.id_number == id) - goto DONE_LABEL; - else - goto EXECUTE_INTERNAL; - } + /* We execute the event even if it's ours, and notice that it's + happened above. */ case pointer_motion_event: case process_event: case magic_event: @@ -2587,8 +2612,8 @@ redisplay (); } - /* If we're no longer waiting for a timeout, bug out. */ - if (! id) + /* If our timeout has arrived, we move along. */ + if (!event_stream_wakeup_pending_p (id, 0)) { result = Qt; goto DONE_LABEL; @@ -2619,15 +2644,9 @@ break; } case timeout_event: - { - if (XEVENT (event)->event.timeout.id_number != id) - /* a timeout that wasn't the one we're waiting for */ - goto EXECUTE_INTERNAL; - id = 0; /* assert that we are no longer waiting for it. */ - result = Qt; - goto DONE_LABEL; - } - default: + /* We execute the event even if it's ours, and notice that it's + happened above. */ + default: { EXECUTE_INTERNAL: execute_internal_event (event); @@ -2638,7 +2657,7 @@ DONE_LABEL: /* If our timeout has not been signalled yet, disable it. */ - if (id) + if (NILP (result)) event_stream_disable_wakeup (id, 0); /* Put back the event (if any) that made Fsit_for() exit before the