comparison src/event-stream.c @ 189:489f57a838ef r20-3b21

Import from CVS: tag r20-3b21
author cvs
date Mon, 13 Aug 2007 09:57:07 +0200
parents b405438285a2
children a2f645c6b9f8
comparison
equal deleted inserted replaced
188:e29a8e7498d9 189:489f57a838ef
1545 } 1545 }
1546 1546
1547 void 1547 void
1548 enqueue_magic_eval_event (void (*fun) (Lisp_Object), Lisp_Object object) 1548 enqueue_magic_eval_event (void (*fun) (Lisp_Object), Lisp_Object object)
1549 { 1549 {
1550 Lisp_Object event = Fmake_event (); 1550 Lisp_Object event = Fmake_event (Qnil, Qnil);
1551 1551
1552 XEVENT (event)->event_type = magic_eval_event; 1552 XEVENT (event)->event_type = magic_eval_event;
1553 /* channel for magic_eval events is nil */ 1553 /* channel for magic_eval events is nil */
1554 XEVENT (event)->event.magic_eval.internal_function = fun; 1554 XEVENT (event)->event.magic_eval.internal_function = fun;
1555 XEVENT (event)->event.magic_eval.object = object; 1555 XEVENT (event)->event.magic_eval.object = object;
1563 See `next-event' for a description of event types and how events 1563 See `next-event' for a description of event types and how events
1564 are received. 1564 are received.
1565 */ 1565 */
1566 (function, object)) 1566 (function, object))
1567 { 1567 {
1568 Lisp_Object event = Fmake_event (); 1568 Lisp_Object event = Fmake_event (Qnil, Qnil);
1569 1569
1570 XEVENT (event)->event_type = eval_event; 1570 XEVENT (event)->event_type = eval_event;
1571 /* channel for eval events is nil */ 1571 /* channel for eval events is nil */
1572 XEVENT (event)->event.eval.function = function; 1572 XEVENT (event)->event.eval.function = function;
1573 XEVENT (event)->event.eval.object = object; 1573 XEVENT (event)->event.eval.object = object;
1578 1578
1579 Lisp_Object 1579 Lisp_Object
1580 enqueue_misc_user_event (Lisp_Object channel, Lisp_Object function, 1580 enqueue_misc_user_event (Lisp_Object channel, Lisp_Object function,
1581 Lisp_Object object) 1581 Lisp_Object object)
1582 { 1582 {
1583 Lisp_Object event = Fmake_event (); 1583 Lisp_Object event = Fmake_event (Qnil, Qnil);
1584 1584
1585 XEVENT (event)->event_type = misc_user_event; 1585 XEVENT (event)->event_type = misc_user_event;
1586 XEVENT (event)->channel = channel; 1586 XEVENT (event)->channel = channel;
1587 XEVENT (event)->event.eval.function = function; 1587 XEVENT (event)->event.eval.function = function;
1588 XEVENT (event)->event.eval.object = object; 1588 XEVENT (event)->event.eval.object = object;
2043 if (in_menu_callback) 2043 if (in_menu_callback)
2044 error ("Attempt to call next-event inside menu callback"); 2044 error ("Attempt to call next-event inside menu callback");
2045 #endif /* LWLIB_MENUBARS_LUCID */ 2045 #endif /* LWLIB_MENUBARS_LUCID */
2046 2046
2047 if (NILP (event)) 2047 if (NILP (event))
2048 event = Fmake_event (); 2048 event = Fmake_event (Qnil, Qnil);
2049 else 2049 else
2050 CHECK_LIVE_EVENT (event); 2050 CHECK_LIVE_EVENT (event);
2051 2051
2052 if (!NILP (prompt)) 2052 if (!NILP (prompt))
2053 { 2053 {
2189 not have come from the keyboard or a keyboard macro, it may have 2189 not have come from the keyboard or a keyboard macro, it may have
2190 come from unread-command-events. It's always a command-event (a 2190 come from unread-command-events. It's always a command-event (a
2191 key, click, or menu selection), never a motion or process event. 2191 key, click, or menu selection), never a motion or process event.
2192 */ 2192 */
2193 if (!EVENTP (Vlast_input_event)) 2193 if (!EVENTP (Vlast_input_event))
2194 Vlast_input_event = Fmake_event (); 2194 Vlast_input_event = Fmake_event (Qnil, Qnil);
2195 if (XEVENT_TYPE (Vlast_input_event) == dead_event) 2195 if (XEVENT_TYPE (Vlast_input_event) == dead_event)
2196 { 2196 {
2197 Vlast_input_event = Fmake_event (); 2197 Vlast_input_event = Fmake_event (Qnil, Qnil);
2198 error ("Someone deallocated last-input-event!"); 2198 error ("Someone deallocated last-input-event!");
2199 } 2199 }
2200 if (! EQ (event, Vlast_input_event)) 2200 if (! EQ (event, Vlast_input_event))
2201 Fcopy_event (event, Vlast_input_event); 2201 Fcopy_event (event, Vlast_input_event);
2202 2202
2310 ()) 2310 ())
2311 { 2311 {
2312 /* This throws away user-input on the queue, but doesn't process any 2312 /* This throws away user-input on the queue, but doesn't process any
2313 events. Calling dispatch_event() here leads to a race condition. 2313 events. Calling dispatch_event() here leads to a race condition.
2314 */ 2314 */
2315 Lisp_Object event = Fmake_event (); 2315 Lisp_Object event = Fmake_event (Qnil, Qnil);
2316 Lisp_Object head = Qnil, tail = Qnil; 2316 Lisp_Object head = Qnil, tail = Qnil;
2317 Lisp_Object oiq = Vinhibit_quit; 2317 Lisp_Object oiq = Vinhibit_quit;
2318 struct gcpro gcpro1, gcpro2; 2318 struct gcpro gcpro1, gcpro2;
2319 /* #### not correct here with Vselected_console? Should 2319 /* #### not correct here with Vselected_console? Should
2320 discard-input take a console argument, or maybe map over 2320 discard-input take a console argument, or maybe map over
2469 timeout_id = event_stream_generate_wakeup (msecs, 0, Qnil, Qnil, 0); 2469 timeout_id = event_stream_generate_wakeup (msecs, 0, Qnil, Qnil, 0);
2470 timeout_enabled = 1; 2470 timeout_enabled = 1;
2471 } 2471 }
2472 } 2472 }
2473 2473
2474 event = Fmake_event (); 2474 event = Fmake_event (Qnil, Qnil);
2475 2475
2476 count = specpdl_depth (); 2476 count = specpdl_depth ();
2477 record_unwind_protect (sit_for_unwind, 2477 record_unwind_protect (sit_for_unwind,
2478 timeout_enabled ? make_int (timeout_id) : Qnil); 2478 timeout_enabled ? make_int (timeout_id) : Qnil);
2479 recursive_sit_for = Qt; 2479 recursive_sit_for = Qt;
2573 struct gcpro gcpro1; 2573 struct gcpro gcpro1;
2574 2574
2575 GCPRO1 (event); 2575 GCPRO1 (event);
2576 2576
2577 id = event_stream_generate_wakeup (msecs, 0, Qnil, Qnil, 0); 2577 id = event_stream_generate_wakeup (msecs, 0, Qnil, Qnil, 0);
2578 event = Fmake_event (); 2578 event = Fmake_event (Qnil, Qnil);
2579 2579
2580 count = specpdl_depth (); 2580 count = specpdl_depth ();
2581 record_unwind_protect (sit_for_unwind, make_int (id)); 2581 record_unwind_protect (sit_for_unwind, make_int (id));
2582 recursive_sit_for = Qt; 2582 recursive_sit_for = Qt;
2583 2583
2679 /* Otherwise, start reading events from the event_stream. 2679 /* Otherwise, start reading events from the event_stream.
2680 Do this loop at least once even if (sit-for 0) so that we 2680 Do this loop at least once even if (sit-for 0) so that we
2681 redisplay when no input pending. 2681 redisplay when no input pending.
2682 */ 2682 */
2683 GCPRO1 (event); 2683 GCPRO1 (event);
2684 event = Fmake_event (); 2684 event = Fmake_event (Qnil, Qnil);
2685 2685
2686 /* Generate the wakeup even if MSECS is 0, so that existing timeout/etc. 2686 /* Generate the wakeup even if MSECS is 0, so that existing timeout/etc.
2687 events get processed. The old (pre-19.12) code special-cased this 2687 events get processed. The old (pre-19.12) code special-cased this
2688 and didn't generate a wakeup, but the resulting behavior was less than 2688 and didn't generate a wakeup, but the resulting behavior was less than
2689 ideal; viz. the occurrence of (sit-for 0.001) scattered throughout 2689 ideal; viz. the occurrence of (sit-for 0.001) scattered throughout
2778 */ 2778 */
2779 void 2779 void
2780 wait_delaying_user_input (int (*predicate) (void *arg), void *predicate_arg) 2780 wait_delaying_user_input (int (*predicate) (void *arg), void *predicate_arg)
2781 { 2781 {
2782 /* This function can GC */ 2782 /* This function can GC */
2783 Lisp_Object event = Fmake_event (); 2783 Lisp_Object event = Fmake_event (Qnil, Qnil);
2784 struct gcpro gcpro1; 2784 struct gcpro gcpro1;
2785 GCPRO1 (event); 2785 GCPRO1 (event);
2786 2786
2787 while (!(*predicate) (predicate_arg)) 2787 while (!(*predicate) (predicate_arg))
2788 { 2788 {
3919 } 3919 }
3920 3920
3921 static void 3921 static void
3922 push_this_command_keys (Lisp_Object event) 3922 push_this_command_keys (Lisp_Object event)
3923 { 3923 {
3924 Lisp_Object new = Fmake_event (); 3924 Lisp_Object new = Fmake_event (Qnil, Qnil);
3925 3925
3926 Fcopy_event (event, new); 3926 Fcopy_event (event, new);
3927 enqueue_event (new, &Vthis_command_keys, &Vthis_command_keys_tail); 3927 enqueue_event (new, &Vthis_command_keys, &Vthis_command_keys_tail);
3928 } 3928 }
3929 3929
3996 3996
3997 e = XVECTOR_DATA (Vrecent_keys_ring) [recent_keys_ring_index]; 3997 e = XVECTOR_DATA (Vrecent_keys_ring) [recent_keys_ring_index];
3998 3998
3999 if (NILP (e)) 3999 if (NILP (e))
4000 { 4000 {
4001 e = Fmake_event (); 4001 e = Fmake_event (Qnil, Qnil);
4002 XVECTOR_DATA (Vrecent_keys_ring) [recent_keys_ring_index] = e; 4002 XVECTOR_DATA (Vrecent_keys_ring) [recent_keys_ring_index] = e;
4003 } 4003 }
4004 Fcopy_event (event, e); 4004 Fcopy_event (event, e);
4005 if (++recent_keys_ring_index == recent_keys_ring_size) 4005 if (++recent_keys_ring_index == recent_keys_ring_size)
4006 recent_keys_ring_index = 0; 4006 recent_keys_ring_index = 0;
4090 4090
4091 regenerate_echo_keys_from_this_command_keys (command_builder); 4091 regenerate_echo_keys_from_this_command_keys (command_builder);
4092 } 4092 }
4093 else 4093 else
4094 { 4094 {
4095 event = Fcopy_event (event, Fmake_event ()); 4095 event = Fcopy_event (event, Fmake_event (Qnil, Qnil));
4096 4096
4097 command_builder_append_event (command_builder, event); 4097 command_builder_append_event (command_builder, event);
4098 } 4098 }
4099 } 4099 }
4100 4100
4125 } 4125 }
4126 else 4126 else
4127 maybe_echo_keys (command_builder, 0); 4127 maybe_echo_keys (command_builder, 0);
4128 } 4128 }
4129 else if (!NILP (Vquit_flag)) { 4129 else if (!NILP (Vquit_flag)) {
4130 Lisp_Object quit_event = Fmake_event(); 4130 Lisp_Object quit_event = Fmake_event(Qnil, Qnil);
4131 struct Lisp_Event *e = XEVENT (quit_event); 4131 struct Lisp_Event *e = XEVENT (quit_event);
4132 /* if quit happened during menu acceleration, pretend we read it */ 4132 /* if quit happened during menu acceleration, pretend we read it */
4133 struct console *con = XCONSOLE (Fselected_console ()); 4133 struct console *con = XCONSOLE (Fselected_console ());
4134 int ch = CONSOLE_QUIT_CHAR (con); 4134 int ch = CONSOLE_QUIT_CHAR (con);
4135 4135
4182 } 4182 }
4183 4183
4184 /* Store the last-command-event. The semantics of this is that it 4184 /* Store the last-command-event. The semantics of this is that it
4185 is the last event most recently involved in command-lookup. */ 4185 is the last event most recently involved in command-lookup. */
4186 if (!EVENTP (Vlast_command_event)) 4186 if (!EVENTP (Vlast_command_event))
4187 Vlast_command_event = Fmake_event (); 4187 Vlast_command_event = Fmake_event (Qnil, Qnil);
4188 if (XEVENT (Vlast_command_event)->event_type == dead_event) 4188 if (XEVENT (Vlast_command_event)->event_type == dead_event)
4189 { 4189 {
4190 Vlast_command_event = Fmake_event (); 4190 Vlast_command_event = Fmake_event (Qnil, Qnil);
4191 error ("Someone deallocated the last-command-event!"); 4191 error ("Someone deallocated the last-command-event!");
4192 } 4192 }
4193 4193
4194 if (! EQ (event, Vlast_command_event)) 4194 if (! EQ (event, Vlast_command_event))
4195 Fcopy_event (event, Vlast_command_event); 4195 Fcopy_event (event, Vlast_command_event);
4621 comment in 4621 comment in
4622 next-event */ 4622 next-event */
4623 struct command_builder *command_builder = 4623 struct command_builder *command_builder =
4624 XCOMMAND_BUILDER (con->command_builder); 4624 XCOMMAND_BUILDER (con->command_builder);
4625 Lisp_Object result; 4625 Lisp_Object result;
4626 Lisp_Object event = Fmake_event (); 4626 Lisp_Object event = Fmake_event (Qnil, Qnil);
4627 int speccount = specpdl_depth (); 4627 int speccount = specpdl_depth ();
4628 struct gcpro gcpro1; 4628 struct gcpro gcpro1;
4629 GCPRO1 (event); 4629 GCPRO1 (event);
4630 4630
4631 if (!NILP (prompt)) 4631 if (!NILP (prompt))