Mercurial > emacs
changeset 1988:1709282a3413
* keyboard.c (kbd_buffer_get_event): Protect assignment to
Vlast_event_frame in a "#ifdef MULTI_FRAME" clause.
Use the term `scroll bar', instead of `scrollbar'.
* alloc.c, frame.c, frame.h, indent.c, keyboard.c, keyboard.h,
lisp.h, term.c, termhooks.h, window.c, window.h, xdisp.c, xfns.c,
xterm.c, xterm.h: Terminology changed.
Don't generate switch-frame events by checking Vlast_event_frame;
use a separate variable for that bookkeeping. In order to
generate them properly, we may need to fiddle with it.
* keyboard.c (internal_last_event_frame): New variable.
(command_loop_1): Check internal_last_event_frame, not
Vlast_event_frame.
(read_char, kbd_buffer_store_event): Set both Vlast_event_frame and
internal_last_event_frame.
(kbd_buffer_get_event): Check internal_last_event_frame to decide
whether to generate a switch-frame event. Set Vlast_event_frame
after each event.
(init_keyboard): Initialize both Vlast_event_frame and
internal_last_event_frame.
* keyboard.h (internal_last_event_frame): Add extern declaration
for this.
* frame.c (Vlast_event_frame): Remove external declaration for
this.
(Fselect_frame): Set internal_last_event_frame to Qnil to force a
switch-frame event, not Vlast_event_frame; the latter is supposed
to convey information to the user.
* keyboard.c (syms_of_keyboard): Doc fix for unread_command_events.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Tue, 02 Mar 1993 08:14:15 +0000 |
parents | cd893024d6b9 |
children | b1c1ab20f810 |
files | src/keyboard.c |
diffstat | 1 files changed, 59 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/src/keyboard.c Tue Mar 02 08:11:01 1993 +0000 +++ b/src/keyboard.c Tue Mar 02 08:14:15 1993 +0000 @@ -205,7 +205,15 @@ #ifdef MULTI_FRAME /* The frame in which the last input event occurred, or Qmacro if the - last event came from a macro. */ + last event came from a macro. We use this to determine when to + generate switch-frame events. This may be cleared by functions + like Fselect_frame, to make sure that a switch-frame event is + generated by the next character. */ +Lisp_Object internal_last_event_frame; + +/* A user-visible version of the above, intended to allow users to + figure out where the last event came from, if the event doesn't + carry that information itself (i.e. if it was a character). */ Lisp_Object Vlast_event_frame; #endif @@ -248,8 +256,8 @@ The interrupt-level event handlers will never enqueue an event on a frame which is not in Vframe_list, and once an event is dequeued, - Vlast_event_frame or the event itself points to the frame. So - that's all fine. + internal_last_event_frame or the event itself points to the frame. + So that's all fine. But while the event is sitting in the queue, it's completely unprotected. Suppose the user types one command which will run for @@ -260,7 +268,7 @@ have an event referring to a freed frame, which will crash Emacs when it is dequeued. - Similar things happen when an event on a scrollbar is enqueued; the + Similar things happen when an event on a scroll bar is enqueued; the window may be deleted while the event is in the queue. So, we use this vector to protect the frame_or_window field in the @@ -318,7 +326,7 @@ /* Symbols to head events. */ Lisp_Object Qmouse_movement; -Lisp_Object Qscrollbar_movement; +Lisp_Object Qscroll_bar_movement; Lisp_Object Qswitch_frame; @@ -347,7 +355,7 @@ /* Symbols to use for non-text mouse positions. */ Lisp_Object Qmode_line; Lisp_Object Qvertical_line; -Lisp_Object Qvertical_scrollbar; +Lisp_Object Qvertical_scroll_bar; Lisp_Object recursive_edit_unwind (), command_loop (); Lisp_Object Fthis_command_keys (); @@ -884,9 +892,9 @@ switch-frame events will take care of this, but if some lisp code swallows a switch-frame event, we'll fix things up here. Is this a good idea? */ - if (XTYPE (Vlast_event_frame) == Lisp_Frame - && XFRAME (Vlast_event_frame) != selected_frame) - Fselect_frame (Vlast_event_frame, Qnil); + if (XTYPE (internal_last_event_frame) == Lisp_Frame + && XFRAME (internal_last_event_frame) != selected_frame) + Fselect_frame (internal_last_event_frame, Qnil); #endif #endif @@ -1166,11 +1174,12 @@ remain unchanged. Since this event came from a macro, it would be misleading to - leave Vlast_event_frame set to whereever the last real event - came from. Normally, command_loop_1 selects - Vlast_event_frame after each command is read, but events read - from a macro should never cause a new frame to be selected. */ - Vlast_event_frame = Qmacro; + leave internal_last_event_frame set to whereever the last + real event came from. Normally, a switch-frame event selects + internal_last_event_frame after each command is read, but + events read from a macro should never cause a new frame to be + selected. */ + Vlast_event_frame = internal_last_event_frame = Qmacro; #endif if (executing_macro_index >= XFASTINT (Flength (Vexecuting_macro))) @@ -1207,7 +1216,8 @@ { XSET (c, Lisp_Int, quit_char); #ifdef MULTI_FRAME - XSET (Vlast_event_frame, Lisp_Frame, selected_frame); + XSET (internal_last_event_frame, Lisp_Frame, selected_frame); + Vlast_event_frame = internal_last_event_frame; #endif goto non_reread; @@ -1534,7 +1544,7 @@ #ifdef MULTI_FRAME /* If this results in a quit_char being returned to Emacs as - input, set last-event-frame properly. If this doesn't + input, set Vlast_event_frame properly. If this doesn't get returned to Emacs as an event, the next event read will set Vlast_event_frame again, so this is safe to do. */ { @@ -1542,9 +1552,10 @@ FRAME_FOCUS_FRAME (XFRAME (event->frame_or_window)); if (NILP (focus)) - Vlast_event_frame = event->frame_or_window; + internal_last_event_frame = event->frame_or_window; else - Vlast_event_frame = focus; + internal_last_event_frame = focus; + Vlast_event_frame = internal_last_event_frame; } #endif @@ -1670,9 +1681,9 @@ if (! NILP (focus)) frame = focus; - if (! EQ (frame, Vlast_event_frame)) + if (! EQ (frame, internal_last_event_frame)) { - Vlast_event_frame = frame; + internal_last_event_frame = frame; obj = make_lispy_switch_frame (frame); } } @@ -1698,7 +1709,7 @@ { FRAME_PTR f; Lisp_Object bar_window; - enum scrollbar_part part; + enum scroll_bar_part part; Lisp_Object x, y; unsigned long time; @@ -1717,10 +1728,10 @@ if (NILP (frame)) XSET (frame, Lisp_Frame, f); - if (! EQ (frame, Vlast_event_frame)) + if (! EQ (frame, internal_last_event_frame)) { - XSET (Vlast_event_frame, Lisp_Frame, frame); - obj = make_lispy_switch_frame (Vlast_event_frame); + XSET (internal_last_event_frame, Lisp_Frame, frame); + obj = make_lispy_switch_frame (internal_last_event_frame); } } #endif @@ -1737,6 +1748,10 @@ input_pending = readable_events (); +#ifdef MULTI_FRAME + Vlast_event_frame = internal_last_event_frame; +#endif + return (obj); } @@ -1826,17 +1841,17 @@ "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5" }; -/* Scrollbar parts. */ +/* Scroll bar parts. */ Lisp_Object Qabove_handle, Qhandle, Qbelow_handle; -/* An array of scrollbar parts, indexed by an enum scrollbar_part value. */ -Lisp_Object *scrollbar_parts[] = { +/* An array of scroll bar parts, indexed by an enum scroll_bar_part value. */ +Lisp_Object *scroll_bar_parts[] = { &Qabove_handle, &Qhandle, &Qbelow_handle }; /* A vector, indexed by button number, giving the down-going location - of currently depressed buttons, both scrollbar and non-scrollbar. + of currently depressed buttons, both scroll bar and non-scroll bar. The elements have the form (BUTTON-NUMBER MODIFIER-MASK . REST) @@ -1884,7 +1899,7 @@ /* A mouse click. Figure out where it is, decide whether it's a press, click or drag, and build the appropriate structure. */ case mouse_click: - case scrollbar_click: + case scroll_bar_click: { int button = XFASTINT (event->code); Lisp_Object position; @@ -1935,11 +1950,11 @@ { Lisp_Object window = event->frame_or_window; Lisp_Object portion_whole = Fcons (event->x, event->y); - Lisp_Object part = *scrollbar_parts[(int) event->part]; + Lisp_Object part = *scroll_bar_parts[(int) event->part]; position = Fcons (window, - Fcons (Qvertical_scrollbar, + Fcons (Qvertical_scroll_bar, Fcons (portion_whole, Fcons (make_number (event->timestamp), Fcons (part, @@ -2021,18 +2036,18 @@ make_lispy_movement (frame, bar_window, part, x, y, time) FRAME_PTR frame; Lisp_Object bar_window; - enum scrollbar_part part; + enum scroll_bar_part part; Lisp_Object x, y; unsigned long time; { - /* Is it a scrollbar movement? */ + /* Is it a scroll bar movement? */ if (frame && ! NILP (bar_window)) { - Lisp_Object part_sym = *scrollbar_parts[(int) part]; - - return Fcons (Qscrollbar_movement, + Lisp_Object part_sym = *scroll_bar_parts[(int) part]; + + return Fcons (Qscroll_bar_movement, (Fcons (Fcons (bar_window, - Fcons (Qvertical_scrollbar, + Fcons (Qvertical_scroll_bar, Fcons (Fcons (x, y), Fcons (make_number (time), Fcons (part_sym, @@ -3483,8 +3498,8 @@ between click and drag events unless you want to.\n\ \n\ `read-key-sequence' prefixes mouse events on mode lines, the vertical\n\ -lines separating windows, and scrollbars with imaginary keys\n\ -`mode-line', `vertical-line', and `vertical-scrollbar'.\n\ +lines separating windows, and scroll bars with imaginary keys\n\ +`mode-line', `vertical-line', and `vertical-scroll-bar'.\n\ \n\ If the user switches frames in the middle of a key sequence, the\n\ frame-switch event is put off until after the current key sequence.\n\ @@ -4071,7 +4086,8 @@ #ifdef MULTI_FRAME /* This means that command_loop_1 won't try to select anything the first time through. */ - Vlast_event_frame = Qnil; + internal_last_event_frame = Qnil; + Vlast_event_frame = internal_last_event_frame; #endif /* If we're running a dumped Emacs, we need to clear out @@ -4133,7 +4149,7 @@ struct event_head head_table[] = { &Qmouse_movement, "mouse-movement", &Qmouse_movement, - &Qscrollbar_movement, "scrollbar-movement", &Qmouse_movement, + &Qscroll_bar_movement, "scroll-bar-movement", &Qmouse_movement, &Qswitch_frame, "switch-frame", &Qswitch_frame, }; @@ -4160,8 +4176,8 @@ staticpro (&Qmode_line); Qvertical_line = intern ("vertical-line"); staticpro (&Qvertical_line); - Qvertical_scrollbar = intern ("vertical-scrollbar"); - staticpro (&Qvertical_scrollbar); + Qvertical_scroll_bar = intern ("vertical-scroll-bar"); + staticpro (&Qvertical_scroll_bar); Qabove_handle = intern ("above-handle"); staticpro (&Qabove_handle);