comparison src/event-stream.c @ 479:52626a2f02ef

[xemacs-hg @ 2001-04-20 11:31:53 by ben] about/news changes, already in 21.4
author ben
date Fri, 20 Apr 2001 11:32:27 +0000
parents 0784d089fdc9
children 7039e6323819
comparison
equal deleted inserted replaced
478:09855058eefc 479:52626a2f02ef
2008 2008
2009 static void push_this_command_keys (Lisp_Object event); 2009 static void push_this_command_keys (Lisp_Object event);
2010 static void push_recent_keys (Lisp_Object event); 2010 static void push_recent_keys (Lisp_Object event);
2011 static void dribble_out_event (Lisp_Object event); 2011 static void dribble_out_event (Lisp_Object event);
2012 static void execute_internal_event (Lisp_Object event); 2012 static void execute_internal_event (Lisp_Object event);
2013 static int is_scrollbar_event (Lisp_Object event);
2013 2014
2014 DEFUN ("next-event", Fnext_event, 0, 2, 0, /* 2015 DEFUN ("next-event", Fnext_event, 0, 2, 0, /*
2015 Return the next available event. 2016 Return the next available event.
2016 Pass this object to `dispatch-event' to handle it. 2017 Pass this object to `dispatch-event' to handle it.
2017 In most cases, you will want to use `next-command-event', which returns 2018 In most cases, you will want to use `next-command-event', which returns
2268 If this key came from the keyboard, and we're defining a keyboard 2269 If this key came from the keyboard, and we're defining a keyboard
2269 macro, then it goes into the macro. 2270 macro, then it goes into the macro.
2270 */ 2271 */
2271 if (store_this_key) 2272 if (store_this_key)
2272 { 2273 {
2273 push_this_command_keys (event); 2274 if (!is_scrollbar_event (event)) /* #### not quite right, see
2275 comment in execute_command_event */
2276 push_this_command_keys (event);
2274 if (!inhibit_input_event_recording) 2277 if (!inhibit_input_event_recording)
2275 push_recent_keys (event); 2278 push_recent_keys (event);
2276 dribble_out_event (event); 2279 dribble_out_event (event);
2277 if (!NILP (con->defining_kbd_macro) && NILP (Vexecuting_macro)) 2280 if (!NILP (con->defining_kbd_macro) && NILP (Vexecuting_macro))
2278 { 2281 {
3755 } 3758 }
3756 RETURN_UNGCPRO (leaf); 3759 RETURN_UNGCPRO (leaf);
3757 } 3760 }
3758 } 3761 }
3759 3762
3763 static int
3764 is_scrollbar_event (Lisp_Object event)
3765 {
3766 Lisp_Object fun;
3767
3768 if (XEVENT (event)->event_type != misc_user_event)
3769 return 0;
3770 fun = XEVENT (event)->event.misc.function;
3771
3772 return (EQ (fun, Qscrollbar_line_up) ||
3773 EQ (fun, Qscrollbar_line_down) ||
3774 EQ (fun, Qscrollbar_page_up) ||
3775 EQ (fun, Qscrollbar_page_down) ||
3776 EQ (fun, Qscrollbar_to_top) ||
3777 EQ (fun, Qscrollbar_to_bottom) ||
3778 EQ (fun, Qscrollbar_vertical_drag) ||
3779 EQ (fun, Qscrollbar_char_left) ||
3780 EQ (fun, Qscrollbar_char_right) ||
3781 EQ (fun, Qscrollbar_page_left) ||
3782 EQ (fun, Qscrollbar_page_right) ||
3783 EQ (fun, Qscrollbar_to_left) ||
3784 EQ (fun, Qscrollbar_to_right) ||
3785 EQ (fun, Qscrollbar_horizontal_drag));
3786 }
3787
3760 static void 3788 static void
3761 execute_command_event (struct command_builder *command_builder, 3789 execute_command_event (struct command_builder *command_builder,
3762 Lisp_Object event) 3790 Lisp_Object event)
3763 { 3791 {
3764 /* This function can GC */ 3792 /* This function can GC */
3765 struct console *con = XCONSOLE (command_builder->console); 3793 struct console *con = XCONSOLE (command_builder->console);
3766 struct gcpro gcpro1; 3794 struct gcpro gcpro1;
3767 3795
3768 GCPRO1 (event); /* event may be freshly created */ 3796 GCPRO1 (event); /* event may be freshly created */
3769 3797
3770 /* To fix C-x @ h <scrollbar-drag> x crash. */ 3798 /* #### This call to is_scrollbar_event() isn't quite right, but
3771 if (XEVENT (event)->event_type != misc_user_event) 3799 fixing properly it requires more work than can go into 21.4.
3800 (We really need to split out menu, scrollbar, dialog, and other
3801 types of events from misc-user, and put the remaining ones in a
3802 new `user-eval' type that behaves like an eval event but is a
3803 user event and thus has all of its semantics -- e.g. being
3804 delayed during `accept-process-output' and similar wait states.)
3805
3806 The real issue here is that "user events" and "command events"
3807 are not the same thing, but are very much confused in
3808 event-stream.c. User events are, essentially, any event that
3809 should be delayed by accept-process-output, should terminate a
3810 sit-for, etc. -- basically, any event that needs to be processed
3811 synchronously with key and mouse events. Command events are
3812 those that participate in command building; scrollbar events
3813 clearly don't belong because they should be transparent in a
3814 sequence like C-x @ h <scrollbar-drag> x, which used to cause a
3815 crash before checks similar to the is_scrollbar_event() call were
3816 added. Do other events belong with scrollbar events? I'm not
3817 sure; we need to categorize all misc-user events and see what
3818 their semantics are.
3819
3820 (You might ask, why do scrollbar events need to be user events?
3821 That's a good question. The answer seems to be that they can
3822 change point, and having this happen asynchronously would be a
3823 very bad idea. According to the "proper" functioning of
3824 scrollbars, this should not happen, but XEmacs does not allow
3825 point to go outside of the window.)
3826
3827 Scrollbar events and similar non-command events should obviously
3828 not be recorded in this-command-keys, so we need to check for
3829 this in next-event.
3830
3831 #### We call reset_current_events() twice in this function --
3832 #### here, and later as a result of reset_this_command_keys().
3833 #### This is almost certainly wrong; need to figure out what's
3834 #### correct.
3835
3836 #### We need to figure out what's really correct w.r.t. scrollbar
3837 #### events. With these new fixes in, it actually works to do
3838 #### C-x <scrollbar-drag> 5 2, but the key echo gets messed up
3839 #### (starts over at 5). We really need to be special-casing
3840 #### scrollbar events at a lower level, and not really passing
3841 #### them through the command builder at all. (e.g. do scrollbar
3842 #### events belong in macros??? doubtful; probably only the
3843 #### point movement, if any, belongs, special-cased as a
3844 #### pseudo-issued M-x goto-char command). #### Need more work
3845 #### here. Do this when separating out scrollbar events.
3846 */
3847
3848 if (!is_scrollbar_event (event))
3772 reset_current_events (command_builder); 3849 reset_current_events (command_builder);
3773 3850
3774 switch (XEVENT (event)->event_type) 3851 switch (XEVENT (event)->event_type)
3775 { 3852 {
3776 case key_press_event: 3853 case key_press_event:
3861 Vlast_command_properties = Vthis_command_properties; 3938 Vlast_command_properties = Vthis_command_properties;
3862 Vthis_command_properties = Qnil; 3939 Vthis_command_properties = Qnil;
3863 3940
3864 /* Emacs 18 doesn't unconditionally clear the echoed keystrokes, 3941 /* Emacs 18 doesn't unconditionally clear the echoed keystrokes,
3865 so we don't either */ 3942 so we don't either */
3866 if (XEVENT (event)->event_type != misc_user_event) 3943
3944 if (!is_scrollbar_event (event))
3867 reset_this_command_keys (make_console (con), 0); 3945 reset_this_command_keys (make_console (con), 0);
3868 } 3946 }
3869 } 3947 }
3870 3948
3871 UNGCPRO; 3949 UNGCPRO;