Mercurial > hg > xemacs-beta
comparison src/event-stream.c @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | 966663fcf606 |
children | 6330739388db |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
68 #include "../lwlib/lwlib.h" | 68 #include "../lwlib/lwlib.h" |
69 #else | 69 #else |
70 #define lw_menu_active 0 | 70 #define lw_menu_active 0 |
71 #endif | 71 #endif |
72 | 72 |
73 #include "blocktype.h" | |
73 #include "buffer.h" | 74 #include "buffer.h" |
74 #include "commands.h" | 75 #include "commands.h" |
75 #include "device.h" | 76 #include "device.h" |
76 #include "elhash.h" | 77 #include "elhash.h" |
77 #include "events.h" | 78 #include "events.h" |
134 #endif /* DEFERRED_ACTION_CRAP */ | 135 #endif /* DEFERRED_ACTION_CRAP */ |
135 | 136 |
136 /* Non-nil disable property on a command means | 137 /* Non-nil disable property on a command means |
137 do not execute it; call disabled-command-hook's value instead. */ | 138 do not execute it; call disabled-command-hook's value instead. */ |
138 Lisp_Object Qdisabled, Vdisabled_command_hook; | 139 Lisp_Object Qdisabled, Vdisabled_command_hook; |
140 | |
141 EXFUN (Fnext_command_event, 2); | |
139 | 142 |
140 static void pre_command_hook (void); | 143 static void pre_command_hook (void); |
141 static void post_command_hook (void); | 144 static void post_command_hook (void); |
142 | 145 |
143 /* Last keyboard or mouse input event read as a command. */ | 146 /* Last keyboard or mouse input event read as a command. */ |
380 #define XSETCOMMAND_BUILDER(x, p) XSETRECORD (x, p, command_builder) | 383 #define XSETCOMMAND_BUILDER(x, p) XSETRECORD (x, p, command_builder) |
381 #define COMMAND_BUILDERP(x) RECORDP (x, command_builder) | 384 #define COMMAND_BUILDERP(x) RECORDP (x, command_builder) |
382 #define GC_COMMAND_BUILDERP(x) GC_RECORDP (x, command_builder) | 385 #define GC_COMMAND_BUILDERP(x) GC_RECORDP (x, command_builder) |
383 #define CHECK_COMMAND_BUILDER(x) CHECK_RECORD (x, command_builder) | 386 #define CHECK_COMMAND_BUILDER(x) CHECK_RECORD (x, command_builder) |
384 | 387 |
385 static Lisp_Object mark_command_builder (Lisp_Object obj, | |
386 void (*markobj) (Lisp_Object)); | |
387 static void finalize_command_builder (void *header, int for_disksave); | |
388 DEFINE_LRECORD_IMPLEMENTATION ("command-builder", command_builder, | |
389 mark_command_builder, internal_object_printer, | |
390 finalize_command_builder, 0, 0, | |
391 struct command_builder); | |
392 | |
393 static Lisp_Object | 388 static Lisp_Object |
394 mark_command_builder (Lisp_Object obj, void (*markobj) (Lisp_Object)) | 389 mark_command_builder (Lisp_Object obj, void (*markobj) (Lisp_Object)) |
395 { | 390 { |
396 struct command_builder *builder = XCOMMAND_BUILDER (obj); | 391 struct command_builder *builder = XCOMMAND_BUILDER (obj); |
397 (markobj) (builder->prefix_events); | 392 (markobj) (builder->prefix_events); |
411 xfree (((struct command_builder *) header)->echo_buf); | 406 xfree (((struct command_builder *) header)->echo_buf); |
412 ((struct command_builder *) header)->echo_buf = 0; | 407 ((struct command_builder *) header)->echo_buf = 0; |
413 } | 408 } |
414 } | 409 } |
415 | 410 |
411 DEFINE_LRECORD_IMPLEMENTATION ("command-builder", command_builder, | |
412 mark_command_builder, internal_object_printer, | |
413 finalize_command_builder, 0, 0, | |
414 struct command_builder); | |
415 | |
416 static void | 416 static void |
417 reset_command_builder_event_chain (struct command_builder *builder) | 417 reset_command_builder_event_chain (struct command_builder *builder) |
418 { | 418 { |
419 builder->prefix_events = Qnil; | 419 builder->prefix_events = Qnil; |
420 builder->current_events = Qnil; | 420 builder->current_events = Qnil; |
425 } | 425 } |
426 | 426 |
427 Lisp_Object | 427 Lisp_Object |
428 allocate_command_builder (Lisp_Object console) | 428 allocate_command_builder (Lisp_Object console) |
429 { | 429 { |
430 Lisp_Object builder_obj = Qnil; | 430 Lisp_Object builder_obj; |
431 struct command_builder *builder = | 431 struct command_builder *builder = |
432 alloc_lcrecord_type (struct command_builder, lrecord_command_builder); | 432 alloc_lcrecord_type (struct command_builder, lrecord_command_builder); |
433 | 433 |
434 builder->console = console; | 434 builder->console = console; |
435 reset_command_builder_event_chain (builder); | 435 reset_command_builder_event_chain (builder); |
498 { | 498 { |
499 error ("event-stream callbacks not initialized (internal error?)"); | 499 error ("event-stream callbacks not initialized (internal error?)"); |
500 } | 500 } |
501 } | 501 } |
502 | 502 |
503 int | 503 static int |
504 event_stream_event_pending_p (int user) | 504 event_stream_event_pending_p (int user) |
505 { | 505 { |
506 if (!event_stream) | 506 return event_stream && event_stream->event_pending_p (user); |
507 return 0; | |
508 return event_stream->event_pending_p (user); | |
509 } | 507 } |
510 | 508 |
511 static int | 509 static int |
512 maybe_read_quit_event (struct Lisp_Event *event) | 510 maybe_read_quit_event (struct Lisp_Event *event) |
513 { | 511 { |
536 } | 534 } |
537 | 535 |
538 void | 536 void |
539 event_stream_next_event (struct Lisp_Event *event) | 537 event_stream_next_event (struct Lisp_Event *event) |
540 { | 538 { |
541 Lisp_Object event_obj = Qnil; | 539 Lisp_Object event_obj; |
542 | 540 |
543 check_event_stream_ok (EVENT_STREAM_READ); | 541 check_event_stream_ok (EVENT_STREAM_READ); |
544 | 542 |
545 XSETEVENT (event_obj, event); | 543 XSETEVENT (event_obj, event); |
546 zero_event (event); | 544 zero_event (event); |
907 new redisplay is fully in place. */ | 905 new redisplay is fully in place. */ |
908 { | 906 { |
909 Lisp_Object frmcons, devcons, concons; | 907 Lisp_Object frmcons, devcons, concons; |
910 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons) | 908 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons) |
911 { | 909 { |
912 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (XFRAME (XCAR (frmcons))); | 910 struct frame *f = XFRAME (XCAR (frmcons)); |
911 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f); | |
913 } | 912 } |
914 } | 913 } |
915 | 914 |
916 redisplay (); | 915 redisplay (); |
917 if (event_matches_key_specifier_p (XEVENT (event), make_char (' '))) | 916 if (event_matches_key_specifier_p (XEVENT (event), make_char (' '))) |
957 } | 956 } |
958 return 0; | 957 return 0; |
959 } | 958 } |
960 | 959 |
961 DEFUN ("input-pending-p", Finput_pending_p, 0, 0, 0, /* | 960 DEFUN ("input-pending-p", Finput_pending_p, 0, 0, 0, /* |
962 T if command input is currently available with no waiting. | 961 Return t if command input is currently available with no waiting. |
963 Actually, the value is nil only if we can be sure that no input is available. | 962 Actually, the value is nil only if we can be sure that no input is available. |
964 */ | 963 */ |
965 ()) | 964 ()) |
966 { | 965 { |
967 return detect_input_pending () ? Qt : Qnil; | 966 return detect_input_pending () ? Qt : Qnil; |
1261 | 1260 |
1262 void | 1261 void |
1263 event_stream_disable_wakeup (int id, int async_p) | 1262 event_stream_disable_wakeup (int id, int async_p) |
1264 { | 1263 { |
1265 struct timeout *timeout = 0; | 1264 struct timeout *timeout = 0; |
1266 Lisp_Object rest = Qnil; | 1265 Lisp_Object rest; |
1267 Lisp_Object *timeout_list; | 1266 Lisp_Object *timeout_list; |
1268 | 1267 |
1269 if (async_p) | 1268 if (async_p) |
1270 timeout_list = &pending_async_timeout_list; | 1269 timeout_list = &pending_async_timeout_list; |
1271 else | 1270 else |
1296 | 1295 |
1297 static int | 1296 static int |
1298 event_stream_wakeup_pending_p (int id, int async_p) | 1297 event_stream_wakeup_pending_p (int id, int async_p) |
1299 { | 1298 { |
1300 struct timeout *timeout; | 1299 struct timeout *timeout; |
1301 Lisp_Object rest = Qnil; | 1300 Lisp_Object rest; |
1302 Lisp_Object timeout_list; | 1301 Lisp_Object timeout_list; |
1303 int found = 0; | 1302 int found = 0; |
1304 | 1303 |
1305 | 1304 |
1306 if (async_p) | 1305 if (async_p) |
1369 /**** Lisp-level timeout functions. ****/ | 1368 /**** Lisp-level timeout functions. ****/ |
1370 | 1369 |
1371 static unsigned long | 1370 static unsigned long |
1372 lisp_number_to_milliseconds (Lisp_Object secs, int allow_0) | 1371 lisp_number_to_milliseconds (Lisp_Object secs, int allow_0) |
1373 { | 1372 { |
1374 unsigned long msecs; | |
1375 #ifdef LISP_FLOAT_TYPE | 1373 #ifdef LISP_FLOAT_TYPE |
1376 double fsecs; | 1374 double fsecs; |
1377 CHECK_INT_OR_FLOAT (secs); | 1375 CHECK_INT_OR_FLOAT (secs); |
1378 fsecs = XFLOATINT (secs); | 1376 fsecs = XFLOATINT (secs); |
1379 #else | 1377 #else |
1380 long fsecs; | 1378 long fsecs; |
1381 CHECK_INT_OR_FLOAT (secs); | 1379 CHECK_INT (secs); |
1382 fsecs = XINT (secs); | 1380 fsecs = XINT (secs); |
1383 #endif | 1381 #endif |
1384 msecs = 1000 * fsecs; | |
1385 if (fsecs < 0) | 1382 if (fsecs < 0) |
1386 signal_simple_error ("timeout is negative", secs); | 1383 signal_simple_error ("timeout is negative", secs); |
1387 if (!allow_0 && fsecs == 0) | 1384 if (!allow_0 && fsecs == 0) |
1388 signal_simple_error ("timeout is non-positive", secs); | 1385 signal_simple_error ("timeout is non-positive", secs); |
1389 if (fsecs >= (((unsigned int) 0xFFFFFFFF) / 1000)) | 1386 if (fsecs >= (((unsigned int) 0xFFFFFFFF) / 1000)) |
1390 signal_simple_error | 1387 signal_simple_error |
1391 ("timeout would exceed 32 bits when represented in milliseconds", secs); | 1388 ("timeout would exceed 32 bits when represented in milliseconds", secs); |
1392 return msecs; | 1389 |
1390 return (unsigned long) (1000 * fsecs); | |
1393 } | 1391 } |
1394 | 1392 |
1395 DEFUN ("add-timeout", Fadd_timeout, 3, 4, 0, /* | 1393 DEFUN ("add-timeout", Fadd_timeout, 3, 4, 0, /* |
1396 Add a timeout, to be signaled after the timeout period has elapsed. | 1394 Add a timeout, to be signaled after the timeout period has elapsed. |
1397 SECS is a number of seconds, expressed as an integer or a float. | 1395 SECS is a number of seconds, expressed as an integer or a float. |
1541 | 1539 |
1542 /* Add an event to the back of the command-event queue: it will be the next | 1540 /* Add an event to the back of the command-event queue: it will be the next |
1543 event read after all pending events. This only works on keyboard, | 1541 event read after all pending events. This only works on keyboard, |
1544 mouse-click, misc-user, and eval events. | 1542 mouse-click, misc-user, and eval events. |
1545 */ | 1543 */ |
1546 void | 1544 static void |
1547 enqueue_command_event (Lisp_Object event) | 1545 enqueue_command_event (Lisp_Object event) |
1548 { | 1546 { |
1549 enqueue_event (event, &command_event_queue, &command_event_queue_tail); | 1547 enqueue_event (event, &command_event_queue, &command_event_queue_tail); |
1550 } | 1548 } |
1551 | 1549 |
1552 Lisp_Object | 1550 static Lisp_Object |
1553 dequeue_command_event (void) | 1551 dequeue_command_event (void) |
1554 { | 1552 { |
1555 return dequeue_event (&command_event_queue, &command_event_queue_tail); | 1553 return dequeue_event (&command_event_queue, &command_event_queue_tail); |
1556 } | 1554 } |
1557 | 1555 |
1797 else | 1795 else |
1798 focus_frame = DEVICE_FRAME_WITH_FOCUS_REAL (d); | 1796 focus_frame = DEVICE_FRAME_WITH_FOCUS_REAL (d); |
1799 | 1797 |
1800 /* Mark the minibuffer as changed to make sure it gets updated | 1798 /* Mark the minibuffer as changed to make sure it gets updated |
1801 properly if the echo area is active. */ | 1799 properly if the echo area is active. */ |
1802 MARK_WINDOWS_CHANGED (XWINDOW (FRAME_MINIBUF_WINDOW (XFRAME (frame)))); | 1800 { |
1801 struct window *w = XWINDOW (FRAME_MINIBUF_WINDOW (XFRAME (frame))); | |
1802 MARK_WINDOWS_CHANGED (w); | |
1803 } | |
1803 | 1804 |
1804 if (FRAMEP (focus_frame) && !EQ (frame, focus_frame)) | 1805 if (FRAMEP (focus_frame) && !EQ (frame, focus_frame)) |
1805 { | 1806 { |
1806 /* Oops, we missed a focus-out event. */ | 1807 /* Oops, we missed a focus-out event. */ |
1807 DEVICE_FRAME_WITH_FOCUS_REAL (d) = Qnil; | 1808 DEVICE_FRAME_WITH_FOCUS_REAL (d) = Qnil; |
3514 LWLIB_ID id; | 3515 LWLIB_ID id; |
3515 widget_value *val; | 3516 widget_value *val; |
3516 | 3517 |
3517 if (NILP (f->menubar_data)) | 3518 if (NILP (f->menubar_data)) |
3518 error ("Frame has no menubar."); | 3519 error ("Frame has no menubar."); |
3519 | 3520 |
3520 id = XPOPUP_DATA (f->menubar_data)->id; | 3521 id = XPOPUP_DATA (f->menubar_data)->id; |
3521 val = lw_get_all_values (id); | 3522 val = lw_get_all_values (id); |
3522 val = val->contents; | 3523 val = val->contents; |
3523 lw_set_menu (FRAME_X_MENUBAR_WIDGET (f), val); | 3524 lw_set_menu (FRAME_X_MENUBAR_WIDGET (f), val); |
3524 lw_map_menu (CurrentTime); | 3525 lw_map_menu (CurrentTime); |
5181 you should *bind* this, not set it. | 5182 you should *bind* this, not set it. |
5182 */ ); | 5183 */ ); |
5183 Vretry_undefined_key_binding_unshifted = Qt; | 5184 Vretry_undefined_key_binding_unshifted = Qt; |
5184 | 5185 |
5185 #ifdef HAVE_XIM | 5186 #ifdef HAVE_XIM |
5186 DEFVAR_LISP ("Vcomposed_character_default_binding", | 5187 DEFVAR_LISP ("composed-character-default-binding", |
5187 &Vretry_undefined_key_binding_unshifted /* | 5188 &Vcomposed_character_default_binding /* |
5188 The default keybinding to use for key events from composed input. | 5189 The default keybinding to use for key events from composed input. |
5189 Window systems frequently have ways to allow the user to compose | 5190 Window systems frequently have ways to allow the user to compose |
5190 single characters in a language using multiple keystrokes. | 5191 single characters in a language using multiple keystrokes. |
5191 XEmacs sees these as single character keypress events. | 5192 XEmacs sees these as single character keypress events. |
5192 */ ); | 5193 */ ); |