Mercurial > hg > xemacs-beta
comparison src/event-stream.c @ 593:5fd7ba8b56e7
[xemacs-hg @ 2001-05-31 12:45:27 by ben]
xemacs-faq.texi: Major rewrite.
Update all MS Windows info to current.
Redo section 6.1 almost completely.
Incorporate sections 1 and 2 of Hrvoje's FAQ.
etags.el: Fix infloop when going up to the root.
s\cygwin32.h: Don't unilaterally include ntplay, but only when we're compiling
with native sound (look in configure now).
event-msw.c: Fix yet more problems with C-g handling.
Implement debug-mswindows-events.
event-stream.c, events.h, signal.c, sysdep.h:
Rearrange the signal-handling code to eliminate the former
spaghetti logic paths in it. Document clearly what
"low-level" and "high-level" timeouts are. Rename some
functions with unclear names (e.g. "...alarm...") to names
that reflect what they actually do (e.g. "...async_timeout...").
Fix numerous bugs discovered in the process.
console-x.h, event-Xt.c, event-msw.c, frame-x.c:
Hopefully make XEmacs properly maintain the "iconified"
state on frames at all times. This should fix the "can't
delete a frame with C-x 5 0 when there's another iconified
frame out there" bug.
Put a notice in of further changes that should probably
be made to clean up the frame-visibility support.
(especially directed at Jan Vroonhof)
lisp.h, miscplay.c:
Rename SBufbyte to CBufbyte to avoid a misleading name.
Eliminate UChar, which is not used anywhere and contributes
no semantic info. Add a comment about the documentation-only
properties of the char/unsigned char typedefs. Add
SChar_Binary as an explicitly `signed' version of Char_Binary
and put back the `signed' declarations in miscplay.c.
alloc.c:
Use char typedefs.
console-msw.c, device-msw.c, dialog-msw.c, editfns.c, fileio.c, glyphs-eimage.c, menubar-msw.c, ntplay.c, objects-msw.c, realpath.c, redisplay-msw.c, select-msw.c, syswindows.h, win32.c:
Eliminate numerous C++ errors.
frame-msw.c:
Eliminate numerous C++ errors and Mule-ize.
glyphs-msw.c:
Eliminate numerous C++ errors and use char typedefs.
configure.in:
Fix problems detecting both native and Linux sound on Cygwin
when compiled with --with-msw=no.
Rearrange file-coding handling a bit to avoid warning when
compiling with Mule.
configure.in, configure.usage, INSTALL:
Document XEMACS_CC and corresponding compiler option --xemacs-compiler.
Explain how to build xemacs using a C++ compiler.
author | ben |
---|---|
date | Thu, 31 May 2001 12:45:41 +0000 |
parents | 183866b06e0b |
children | fdefd0186b75 |
comparison
equal
deleted
inserted
replaced
592:4f6ba8f1fb3d | 593:5fd7ba8b56e7 |
---|---|
922 | 922 |
923 /**********************************************************************/ | 923 /**********************************************************************/ |
924 /* timeouts */ | 924 /* timeouts */ |
925 /**********************************************************************/ | 925 /**********************************************************************/ |
926 | 926 |
927 /**** Low-level timeout functions. **** | 927 /* NOTE: "Low-level" or "interval" timeouts are one-shot timeouts that |
928 measure single intervals. "High-level timeouts" or "wakeups" are | |
929 the objects generated by `add-timeout' or `add-async-timout' -- | |
930 they can fire repeatedly (and in fact can have a different initial | |
931 time and resignal time). Given the nature of both setitimer() and | |
932 select() -- i.e. all we get is a single one-shot timer -- we have | |
933 to decompose all high-level timeouts into a series of intervals or | |
934 low-level timeouts. | |
935 | |
936 Low-level timeouts are of two varieties: synchronous and asynchronous. | |
937 The former are handled at the window-system level, the latter in | |
938 signal.c. | |
939 */ | |
940 | |
941 /**** Low-level timeout helper functions. **** | |
928 | 942 |
929 These functions maintain a sorted list of one-shot timeouts (where | 943 These functions maintain a sorted list of one-shot timeouts (where |
930 the timeouts are in absolute time). They are intended for use by | 944 the timeouts are in absolute time so we never lose any time as a |
931 functions that need to convert a list of absolute timeouts into a | 945 result of the delay between noting an interval and firing the next |
932 series of intervals to wait for. */ | 946 one). They are intended for use by functions that need to convert |
947 a list of absolute timeouts into a series of intervals to wait | |
948 for. */ | |
933 | 949 |
934 /* We ensure that 0 is never a valid ID, so that a value of 0 can be | 950 /* We ensure that 0 is never a valid ID, so that a value of 0 can be |
935 used to indicate an absence of a timer. */ | 951 used to indicate an absence of a timer. */ |
936 static int low_level_timeout_id_tick; | 952 static int low_level_timeout_id_tick; |
937 | 953 |
952 | 968 |
953 /* Allocate a new time struct. */ | 969 /* Allocate a new time struct. */ |
954 | 970 |
955 tm = Blocktype_alloc (the_low_level_timeout_blocktype); | 971 tm = Blocktype_alloc (the_low_level_timeout_blocktype); |
956 tm->next = NULL; | 972 tm->next = NULL; |
973 /* Don't just use ++low_level_timeout_id_tick, for the (admittedly | |
974 rare) case in which numbers wrap around. */ | |
957 if (low_level_timeout_id_tick == 0) | 975 if (low_level_timeout_id_tick == 0) |
958 low_level_timeout_id_tick++; | 976 low_level_timeout_id_tick++; |
959 tm->id = low_level_timeout_id_tick++; | 977 tm->id = low_level_timeout_id_tick++; |
960 tm->time = thyme; | 978 tm->time = thyme; |
961 | 979 |
1045 Blocktype_free (the_low_level_timeout_blocktype, tm); | 1063 Blocktype_free (the_low_level_timeout_blocktype, tm); |
1046 return id; | 1064 return id; |
1047 } | 1065 } |
1048 | 1066 |
1049 | 1067 |
1050 /**** High-level timeout functions. ****/ | 1068 /**** High-level timeout functions. **** */ |
1051 | 1069 |
1070 /* We ensure that 0 is never a valid ID, so that a value of 0 can be | |
1071 used to indicate an absence of a timer. */ | |
1052 static int timeout_id_tick; | 1072 static int timeout_id_tick; |
1053 | 1073 |
1054 static Lisp_Object pending_timeout_list, pending_async_timeout_list; | 1074 static Lisp_Object pending_timeout_list, pending_async_timeout_list; |
1055 | 1075 |
1056 static Lisp_Object Vtimeout_free_list; | 1076 static Lisp_Object Vtimeout_free_list; |
1096 Lisp_Object op = allocate_managed_lcrecord (Vtimeout_free_list); | 1116 Lisp_Object op = allocate_managed_lcrecord (Vtimeout_free_list); |
1097 Lisp_Timeout *timeout = XTIMEOUT (op); | 1117 Lisp_Timeout *timeout = XTIMEOUT (op); |
1098 EMACS_TIME current_time; | 1118 EMACS_TIME current_time; |
1099 EMACS_TIME interval; | 1119 EMACS_TIME interval; |
1100 | 1120 |
1121 /* Don't just use ++timeout_id_tick, for the (admittedly rare) case | |
1122 in which numbers wrap around. */ | |
1123 if (timeout_id_tick == 0) | |
1124 timeout_id_tick++; | |
1101 timeout->id = timeout_id_tick++; | 1125 timeout->id = timeout_id_tick++; |
1102 timeout->resignal_msecs = vanilliseconds; | 1126 timeout->resignal_msecs = vanilliseconds; |
1103 timeout->function = function; | 1127 timeout->function = function; |
1104 timeout->object = object; | 1128 timeout->object = object; |
1105 | 1129 |
1109 EMACS_ADD_TIME (timeout->next_signal_time, current_time, interval); | 1133 EMACS_ADD_TIME (timeout->next_signal_time, current_time, interval); |
1110 | 1134 |
1111 if (async_p) | 1135 if (async_p) |
1112 { | 1136 { |
1113 timeout->interval_id = | 1137 timeout->interval_id = |
1114 event_stream_add_async_timeout (timeout->next_signal_time); | 1138 signal_add_async_interval_timeout (timeout->next_signal_time); |
1115 pending_async_timeout_list = noseeum_cons (op, | 1139 pending_async_timeout_list = |
1116 pending_async_timeout_list); | 1140 noseeum_cons (op, pending_async_timeout_list); |
1117 } | 1141 } |
1118 else | 1142 else |
1119 { | 1143 { |
1120 timeout->interval_id = | 1144 timeout->interval_id = |
1121 event_stream_add_timeout (timeout->next_signal_time); | 1145 event_stream_add_timeout (timeout->next_signal_time); |
1136 that may fire repeatedly. | 1160 that may fire repeatedly. |
1137 | 1161 |
1138 NOTE: The returned FUNCTION and OBJECT are *not* GC-protected at all. | 1162 NOTE: The returned FUNCTION and OBJECT are *not* GC-protected at all. |
1139 */ | 1163 */ |
1140 | 1164 |
1141 static int | 1165 int |
1142 event_stream_resignal_wakeup (int interval_id, int async_p, | 1166 event_stream_resignal_wakeup (int interval_id, int async_p, |
1143 Lisp_Object *function, Lisp_Object *object) | 1167 Lisp_Object *function, Lisp_Object *object) |
1144 { | 1168 { |
1145 Lisp_Object op = Qnil, rest; | 1169 Lisp_Object op = Qnil, rest; |
1146 Lisp_Timeout *timeout; | 1170 Lisp_Timeout *timeout; |
1195 interval); | 1219 interval); |
1196 } while (EMACS_TIME_GREATER (current_time, timeout->next_signal_time)); | 1220 } while (EMACS_TIME_GREATER (current_time, timeout->next_signal_time)); |
1197 | 1221 |
1198 if (async_p) | 1222 if (async_p) |
1199 timeout->interval_id = | 1223 timeout->interval_id = |
1200 event_stream_add_async_timeout (timeout->next_signal_time); | 1224 signal_add_async_interval_timeout (timeout->next_signal_time); |
1201 else | 1225 else |
1202 timeout->interval_id = | 1226 timeout->interval_id = |
1203 event_stream_add_timeout (timeout->next_signal_time); | 1227 event_stream_add_timeout (timeout->next_signal_time); |
1204 /* Add back onto the list. Note that the effect of this | 1228 /* Add back onto the list. Note that the effect of this |
1205 is to move frequently-hit timeouts to the front of the | 1229 is to move frequently-hit timeouts to the front of the |
1239 { | 1263 { |
1240 Lisp_Object op = XCAR (rest); | 1264 Lisp_Object op = XCAR (rest); |
1241 *timeout_list = | 1265 *timeout_list = |
1242 delq_no_quit_and_free_cons (op, *timeout_list); | 1266 delq_no_quit_and_free_cons (op, *timeout_list); |
1243 if (async_p) | 1267 if (async_p) |
1244 event_stream_remove_async_timeout (timeout->interval_id); | 1268 signal_remove_async_interval_timeout (timeout->interval_id); |
1245 else | 1269 else |
1246 event_stream_remove_timeout (timeout->interval_id); | 1270 event_stream_remove_timeout (timeout->interval_id); |
1247 free_managed_lcrecord (Vtimeout_free_list, op); | 1271 free_managed_lcrecord (Vtimeout_free_list, op); |
1248 } | 1272 } |
1249 } | 1273 } |
1272 break; | 1296 break; |
1273 } | 1297 } |
1274 } | 1298 } |
1275 | 1299 |
1276 return found; | 1300 return found; |
1277 } | |
1278 | |
1279 | |
1280 /**** Asynch. timeout functions (see also signal.c) ****/ | |
1281 | |
1282 #if !defined (SIGIO) && !defined (DONT_POLL_FOR_QUIT) | |
1283 extern int poll_for_quit_id; | |
1284 #endif | |
1285 | |
1286 #if defined(HAVE_UNIX_PROCESSES) && !defined(SIGCHLD) | |
1287 extern int poll_for_sigchld_id; | |
1288 #endif | |
1289 | |
1290 void | |
1291 event_stream_deal_with_async_timeout (int interval_id) | |
1292 { | |
1293 /* This function can GC */ | |
1294 Lisp_Object humpty, dumpty; | |
1295 #if ((!defined (SIGIO) && !defined (DONT_POLL_FOR_QUIT)) \ | |
1296 || defined(HAVE_UNIX_PROCESSES) && !defined(SIGCHLD)) | |
1297 int id = | |
1298 #endif | |
1299 event_stream_resignal_wakeup (interval_id, 1, &humpty, &dumpty); | |
1300 | |
1301 #if !defined (SIGIO) && !defined (DONT_POLL_FOR_QUIT) | |
1302 if (id == poll_for_quit_id) | |
1303 { | |
1304 quit_check_signal_happened = 1; | |
1305 quit_check_signal_tick_count++; | |
1306 return; | |
1307 } | |
1308 #endif | |
1309 | |
1310 #if defined(HAVE_UNIX_PROCESSES) && !defined(SIGCHLD) | |
1311 if (id == poll_for_sigchld_id) | |
1312 { | |
1313 kick_status_notify (); | |
1314 return; | |
1315 } | |
1316 #endif | |
1317 | |
1318 /* call1 GC-protects its arguments */ | |
1319 call1_trapping_errors ("Error in asynchronous timeout callback", | |
1320 humpty, dumpty); | |
1321 } | 1301 } |
1322 | 1302 |
1323 | 1303 |
1324 /**** Lisp-level timeout functions. ****/ | 1304 /**** Lisp-level timeout functions. ****/ |
1325 | 1305 |