Mercurial > hg > xemacs-beta
comparison src/event-msw.c @ 392:1f50e6fe4f3f r21-2-11
Import from CVS: tag r21-2-11
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:10:50 +0200 |
parents | aabb7f5b1c81 |
children | 74fd4e045ea6 |
comparison
equal
deleted
inserted
replaced
391:e50d8e68d7a5 | 392:1f50e6fe4f3f |
---|---|
63 #include "objects-msw.h" | 63 #include "objects-msw.h" |
64 | 64 |
65 #include "events-mod.h" | 65 #include "events-mod.h" |
66 #ifdef HAVE_MSG_SELECT | 66 #ifdef HAVE_MSG_SELECT |
67 #include "sysfile.h" | 67 #include "sysfile.h" |
68 #include "console-tty.h" | |
68 #elif defined(__CYGWIN32__) | 69 #elif defined(__CYGWIN32__) |
69 typedef unsigned int SOCKET; | 70 typedef unsigned int SOCKET; |
70 #endif | 71 #endif |
71 #include <io.h> | 72 #include <io.h> |
72 #include <errno.h> | 73 #include <errno.h> |
119 static Lisp_Object mswindows_s_dispatch_event_queue, mswindows_s_dispatch_event_queue_tail; | 120 static Lisp_Object mswindows_s_dispatch_event_queue, mswindows_s_dispatch_event_queue_tail; |
120 | 121 |
121 /* The number of things we can wait on */ | 122 /* The number of things we can wait on */ |
122 #define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1) | 123 #define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1) |
123 | 124 |
125 #ifndef HAVE_MSG_SELECT | |
124 /* List of mswindows waitable handles. */ | 126 /* List of mswindows waitable handles. */ |
125 static HANDLE mswindows_waitable_handles[MAX_WAITABLE]; | 127 static HANDLE mswindows_waitable_handles[MAX_WAITABLE]; |
126 | 128 |
127 #ifndef HAVE_MSG_SELECT | |
128 /* Number of wait handles */ | 129 /* Number of wait handles */ |
129 static int mswindows_waitable_count=0; | 130 static int mswindows_waitable_count=0; |
130 #endif /* HAVE_MSG_SELECT */ | 131 #endif /* HAVE_MSG_SELECT */ |
131 /* Brush for painting widgets */ | 132 /* Brush for painting widgets */ |
132 static HBRUSH widget_brush = 0; | 133 static HBRUSH widget_brush = 0; |
1320 EMACS_SET_SECS_USECS (sometime, 0, 0); | 1321 EMACS_SET_SECS_USECS (sometime, 0, 0); |
1321 EMACS_TIME_TO_SELECT_TIME (sometime, select_time_to_block); | 1322 EMACS_TIME_TO_SELECT_TIME (sometime, select_time_to_block); |
1322 pointer_to_this = &select_time_to_block; | 1323 pointer_to_this = &select_time_to_block; |
1323 } | 1324 } |
1324 | 1325 |
1325 /* select() is slow and buggy so if we don't have any processes | |
1326 just wait as normal */ | |
1327 if (memcmp (&process_only_mask, &zero_mask, sizeof(SELECT_TYPE))==0) | |
1328 { | |
1329 /* Now try getting a message or process event */ | |
1330 active = MsgWaitForMultipleObjects (0, mswindows_waitable_handles, | |
1331 FALSE, badly_p ? INFINITE : 0, | |
1332 QS_ALLINPUT); | |
1333 | |
1334 if (active == WAIT_TIMEOUT) | |
1335 { | |
1336 /* No luck trying - just return what we've already got */ | |
1337 return; | |
1338 } | |
1339 else if (active == WAIT_OBJECT_0) | |
1340 { | |
1341 /* Got your message, thanks */ | |
1342 mswindows_drain_windows_queue (); | |
1343 continue; | |
1344 } | |
1345 } | |
1346 | |
1347 active = select (MAXDESC, &temp_mask, 0, 0, pointer_to_this); | 1326 active = select (MAXDESC, &temp_mask, 0, 0, pointer_to_this); |
1348 | 1327 |
1349 if (active == 0) | 1328 if (active == 0) |
1350 { | 1329 { |
1351 return; /* timeout */ | 1330 return; /* timeout */ |
1354 { | 1333 { |
1355 if (FD_ISSET (windows_fd, &temp_mask)) | 1334 if (FD_ISSET (windows_fd, &temp_mask)) |
1356 { | 1335 { |
1357 mswindows_drain_windows_queue (); | 1336 mswindows_drain_windows_queue (); |
1358 } | 1337 } |
1359 | 1338 #ifdef HAVE_TTY |
1339 /* Look for a TTY event */ | |
1340 for (i = 0; i < MAXDESC-1; i++) | |
1341 { | |
1342 /* To avoid race conditions (among other things, an infinite | |
1343 loop when called from Fdiscard_input()), we must return | |
1344 user events ahead of process events. */ | |
1345 if (FD_ISSET (i, &temp_mask) && FD_ISSET (i, &tty_only_mask)) | |
1346 { | |
1347 struct console *c = tty_find_console_from_fd (i); | |
1348 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil); | |
1349 struct Lisp_Event* event = XEVENT (emacs_event); | |
1350 | |
1351 assert (c); | |
1352 if (read_event_from_tty_or_stream_desc (event, c, i)) | |
1353 { | |
1354 mswindows_enqueue_dispatch_event (emacs_event); | |
1355 return; | |
1356 } | |
1357 } | |
1358 } | |
1359 #endif | |
1360 /* Look for a process event */ | 1360 /* Look for a process event */ |
1361 for (i = 0; i < MAXDESC-1; i++) | 1361 for (i = 0; i < MAXDESC-1; i++) |
1362 { | 1362 { |
1363 if (FD_ISSET (i, &temp_mask)) | 1363 if (FD_ISSET (i, &temp_mask)) |
1364 { | 1364 { |
1366 { | 1366 { |
1367 struct Lisp_Process *p = | 1367 struct Lisp_Process *p = |
1368 get_process_from_usid (FD_TO_USID(i)); | 1368 get_process_from_usid (FD_TO_USID(i)); |
1369 | 1369 |
1370 mswindows_enqueue_process_event (p); | 1370 mswindows_enqueue_process_event (p); |
1371 } | |
1372 else if (FD_ISSET (i, &tty_only_mask)) | |
1373 { | |
1374 /* do we care about tty events? Do we | |
1375 ever get tty events? */ | |
1376 } | 1371 } |
1377 else | 1372 else |
1378 { | 1373 { |
1379 /* We might get here when a fake event came | 1374 /* We might get here when a fake event came |
1380 through a signal. Return a dummy event, so | 1375 through a signal. Return a dummy event, so |
2672 #endif /* HAVE_MSG_SELECT */ | 2667 #endif /* HAVE_MSG_SELECT */ |
2673 | 2668 |
2674 static void | 2669 static void |
2675 emacs_mswindows_select_console (struct console *con) | 2670 emacs_mswindows_select_console (struct console *con) |
2676 { | 2671 { |
2672 #ifdef HAVE_MSG_SELECT | |
2673 if (CONSOLE_MSWINDOWS_P (con)) | |
2674 return; /* mswindows consoles are automatically selected */ | |
2675 | |
2676 event_stream_unixoid_select_console (con); | |
2677 #endif | |
2677 } | 2678 } |
2678 | 2679 |
2679 static void | 2680 static void |
2680 emacs_mswindows_unselect_console (struct console *con) | 2681 emacs_mswindows_unselect_console (struct console *con) |
2681 { | 2682 { |
2683 #ifdef HAVE_MSG_SELECT | |
2684 if (CONSOLE_MSWINDOWS_P (con)) | |
2685 return; /* mswindows consoles are automatically selected */ | |
2686 | |
2687 event_stream_unixoid_unselect_console (con); | |
2688 #endif | |
2682 } | 2689 } |
2683 | 2690 |
2684 static void | 2691 static void |
2685 emacs_mswindows_quit_p (void) | 2692 emacs_mswindows_quit_p (void) |
2686 { | 2693 { |