aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1993-03-02 08:14:15 +0000
committerJim Blandy1993-03-02 08:14:15 +0000
commit3c37094348fddcd44941e7c65acd0ab19a5e131d (patch)
tree6d4b5010fb21ccd53c96410fab6899ef77ee8f67 /src
parent0a3e4d653cb1655c33528824aa604a7cb6033fd2 (diff)
downloademacs-3c37094348fddcd44941e7c65acd0ab19a5e131d.tar.gz
emacs-3c37094348fddcd44941e7c65acd0ab19a5e131d.zip
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c100
1 files changed, 58 insertions, 42 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 73be93a0d69..61c57fe4c7e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -205,7 +205,15 @@ Lisp_Object this_command;
205 205
206#ifdef MULTI_FRAME 206#ifdef MULTI_FRAME
207/* The frame in which the last input event occurred, or Qmacro if the 207/* The frame in which the last input event occurred, or Qmacro if the
208 last event came from a macro. */ 208 last event came from a macro. We use this to determine when to
209 generate switch-frame events. This may be cleared by functions
210 like Fselect_frame, to make sure that a switch-frame event is
211 generated by the next character. */
212Lisp_Object internal_last_event_frame;
213
214/* A user-visible version of the above, intended to allow users to
215 figure out where the last event came from, if the event doesn't
216 carry that information itself (i.e. if it was a character). */
209Lisp_Object Vlast_event_frame; 217Lisp_Object Vlast_event_frame;
210#endif 218#endif
211 219
@@ -248,8 +256,8 @@ static struct input_event kbd_buffer[KBD_BUFFER_SIZE];
248 256
249 The interrupt-level event handlers will never enqueue an event on a 257 The interrupt-level event handlers will never enqueue an event on a
250 frame which is not in Vframe_list, and once an event is dequeued, 258 frame which is not in Vframe_list, and once an event is dequeued,
251 Vlast_event_frame or the event itself points to the frame. So 259 internal_last_event_frame or the event itself points to the frame.
252 that's all fine. 260 So that's all fine.
253 261
254 But while the event is sitting in the queue, it's completely 262 But while the event is sitting in the queue, it's completely
255 unprotected. Suppose the user types one command which will run for 263 unprotected. Suppose the user types one command which will run for
@@ -260,7 +268,7 @@ static struct input_event kbd_buffer[KBD_BUFFER_SIZE];
260 have an event referring to a freed frame, which will crash Emacs 268 have an event referring to a freed frame, which will crash Emacs
261 when it is dequeued. 269 when it is dequeued.
262 270
263 Similar things happen when an event on a scrollbar is enqueued; the 271 Similar things happen when an event on a scroll bar is enqueued; the
264 window may be deleted while the event is in the queue. 272 window may be deleted while the event is in the queue.
265 273
266 So, we use this vector to protect the frame_or_window field in the 274 So, we use this vector to protect the frame_or_window field in the
@@ -318,7 +326,7 @@ int mouse_moved;
318 326
319/* Symbols to head events. */ 327/* Symbols to head events. */
320Lisp_Object Qmouse_movement; 328Lisp_Object Qmouse_movement;
321Lisp_Object Qscrollbar_movement; 329Lisp_Object Qscroll_bar_movement;
322 330
323Lisp_Object Qswitch_frame; 331Lisp_Object Qswitch_frame;
324 332
@@ -347,7 +355,7 @@ Lisp_Object Qmodifier_cache;
347/* Symbols to use for non-text mouse positions. */ 355/* Symbols to use for non-text mouse positions. */
348Lisp_Object Qmode_line; 356Lisp_Object Qmode_line;
349Lisp_Object Qvertical_line; 357Lisp_Object Qvertical_line;
350Lisp_Object Qvertical_scrollbar; 358Lisp_Object Qvertical_scroll_bar;
351 359
352Lisp_Object recursive_edit_unwind (), command_loop (); 360Lisp_Object recursive_edit_unwind (), command_loop ();
353Lisp_Object Fthis_command_keys (); 361Lisp_Object Fthis_command_keys ();
@@ -884,9 +892,9 @@ command_loop_1 ()
884 switch-frame events will take care of this, but if some lisp 892 switch-frame events will take care of this, but if some lisp
885 code swallows a switch-frame event, we'll fix things up here. 893 code swallows a switch-frame event, we'll fix things up here.
886 Is this a good idea? */ 894 Is this a good idea? */
887 if (XTYPE (Vlast_event_frame) == Lisp_Frame 895 if (XTYPE (internal_last_event_frame) == Lisp_Frame
888 && XFRAME (Vlast_event_frame) != selected_frame) 896 && XFRAME (internal_last_event_frame) != selected_frame)
889 Fselect_frame (Vlast_event_frame, Qnil); 897 Fselect_frame (internal_last_event_frame, Qnil);
890#endif 898#endif
891#endif 899#endif
892 900
@@ -1166,11 +1174,12 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1166 remain unchanged. 1174 remain unchanged.
1167 1175
1168 Since this event came from a macro, it would be misleading to 1176 Since this event came from a macro, it would be misleading to
1169 leave Vlast_event_frame set to whereever the last real event 1177 leave internal_last_event_frame set to whereever the last
1170 came from. Normally, command_loop_1 selects 1178 real event came from. Normally, a switch-frame event selects
1171 Vlast_event_frame after each command is read, but events read 1179 internal_last_event_frame after each command is read, but
1172 from a macro should never cause a new frame to be selected. */ 1180 events read from a macro should never cause a new frame to be
1173 Vlast_event_frame = Qmacro; 1181 selected. */
1182 Vlast_event_frame = internal_last_event_frame = Qmacro;
1174#endif 1183#endif
1175 1184
1176 if (executing_macro_index >= XFASTINT (Flength (Vexecuting_macro))) 1185 if (executing_macro_index >= XFASTINT (Flength (Vexecuting_macro)))
@@ -1207,7 +1216,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1207 { 1216 {
1208 XSET (c, Lisp_Int, quit_char); 1217 XSET (c, Lisp_Int, quit_char);
1209#ifdef MULTI_FRAME 1218#ifdef MULTI_FRAME
1210 XSET (Vlast_event_frame, Lisp_Frame, selected_frame); 1219 XSET (internal_last_event_frame, Lisp_Frame, selected_frame);
1220 Vlast_event_frame = internal_last_event_frame;
1211#endif 1221#endif
1212 1222
1213 goto non_reread; 1223 goto non_reread;
@@ -1534,7 +1544,7 @@ kbd_buffer_store_event (event)
1534 1544
1535#ifdef MULTI_FRAME 1545#ifdef MULTI_FRAME
1536 /* If this results in a quit_char being returned to Emacs as 1546 /* If this results in a quit_char being returned to Emacs as
1537 input, set last-event-frame properly. If this doesn't 1547 input, set Vlast_event_frame properly. If this doesn't
1538 get returned to Emacs as an event, the next event read 1548 get returned to Emacs as an event, the next event read
1539 will set Vlast_event_frame again, so this is safe to do. */ 1549 will set Vlast_event_frame again, so this is safe to do. */
1540 { 1550 {
@@ -1542,9 +1552,10 @@ kbd_buffer_store_event (event)
1542 FRAME_FOCUS_FRAME (XFRAME (event->frame_or_window)); 1552 FRAME_FOCUS_FRAME (XFRAME (event->frame_or_window));
1543 1553
1544 if (NILP (focus)) 1554 if (NILP (focus))
1545 Vlast_event_frame = event->frame_or_window; 1555 internal_last_event_frame = event->frame_or_window;
1546 else 1556 else
1547 Vlast_event_frame = focus; 1557 internal_last_event_frame = focus;
1558 Vlast_event_frame = internal_last_event_frame;
1548 } 1559 }
1549#endif 1560#endif
1550 1561
@@ -1670,9 +1681,9 @@ kbd_buffer_get_event ()
1670 if (! NILP (focus)) 1681 if (! NILP (focus))
1671 frame = focus; 1682 frame = focus;
1672 1683
1673 if (! EQ (frame, Vlast_event_frame)) 1684 if (! EQ (frame, internal_last_event_frame))
1674 { 1685 {
1675 Vlast_event_frame = frame; 1686 internal_last_event_frame = frame;
1676 obj = make_lispy_switch_frame (frame); 1687 obj = make_lispy_switch_frame (frame);
1677 } 1688 }
1678 } 1689 }
@@ -1698,7 +1709,7 @@ kbd_buffer_get_event ()
1698 { 1709 {
1699 FRAME_PTR f; 1710 FRAME_PTR f;
1700 Lisp_Object bar_window; 1711 Lisp_Object bar_window;
1701 enum scrollbar_part part; 1712 enum scroll_bar_part part;
1702 Lisp_Object x, y; 1713 Lisp_Object x, y;
1703 unsigned long time; 1714 unsigned long time;
1704 1715
@@ -1717,10 +1728,10 @@ kbd_buffer_get_event ()
1717 if (NILP (frame)) 1728 if (NILP (frame))
1718 XSET (frame, Lisp_Frame, f); 1729 XSET (frame, Lisp_Frame, f);
1719 1730
1720 if (! EQ (frame, Vlast_event_frame)) 1731 if (! EQ (frame, internal_last_event_frame))
1721 { 1732 {
1722 XSET (Vlast_event_frame, Lisp_Frame, frame); 1733 XSET (internal_last_event_frame, Lisp_Frame, frame);
1723 obj = make_lispy_switch_frame (Vlast_event_frame); 1734 obj = make_lispy_switch_frame (internal_last_event_frame);
1724 } 1735 }
1725 } 1736 }
1726#endif 1737#endif
@@ -1737,6 +1748,10 @@ kbd_buffer_get_event ()
1737 1748
1738 input_pending = readable_events (); 1749 input_pending = readable_events ();
1739 1750
1751#ifdef MULTI_FRAME
1752 Vlast_event_frame = internal_last_event_frame;
1753#endif
1754
1740 return (obj); 1755 return (obj);
1741} 1756}
1742 1757
@@ -1826,17 +1841,17 @@ static char *lispy_mouse_names[] =
1826 "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5" 1841 "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5"
1827}; 1842};
1828 1843
1829/* Scrollbar parts. */ 1844/* Scroll bar parts. */
1830Lisp_Object Qabove_handle, Qhandle, Qbelow_handle; 1845Lisp_Object Qabove_handle, Qhandle, Qbelow_handle;
1831 1846
1832/* An array of scrollbar parts, indexed by an enum scrollbar_part value. */ 1847/* An array of scroll bar parts, indexed by an enum scroll_bar_part value. */
1833Lisp_Object *scrollbar_parts[] = { 1848Lisp_Object *scroll_bar_parts[] = {
1834 &Qabove_handle, &Qhandle, &Qbelow_handle 1849 &Qabove_handle, &Qhandle, &Qbelow_handle
1835}; 1850};
1836 1851
1837 1852
1838/* A vector, indexed by button number, giving the down-going location 1853/* A vector, indexed by button number, giving the down-going location
1839 of currently depressed buttons, both scrollbar and non-scrollbar. 1854 of currently depressed buttons, both scroll bar and non-scroll bar.
1840 1855
1841 The elements have the form 1856 The elements have the form
1842 (BUTTON-NUMBER MODIFIER-MASK . REST) 1857 (BUTTON-NUMBER MODIFIER-MASK . REST)
@@ -1884,7 +1899,7 @@ make_lispy_event (event)
1884 /* A mouse click. Figure out where it is, decide whether it's 1899 /* A mouse click. Figure out where it is, decide whether it's
1885 a press, click or drag, and build the appropriate structure. */ 1900 a press, click or drag, and build the appropriate structure. */
1886 case mouse_click: 1901 case mouse_click:
1887 case scrollbar_click: 1902 case scroll_bar_click:
1888 { 1903 {
1889 int button = XFASTINT (event->code); 1904 int button = XFASTINT (event->code);
1890 Lisp_Object position; 1905 Lisp_Object position;
@@ -1935,11 +1950,11 @@ make_lispy_event (event)
1935 { 1950 {
1936 Lisp_Object window = event->frame_or_window; 1951 Lisp_Object window = event->frame_or_window;
1937 Lisp_Object portion_whole = Fcons (event->x, event->y); 1952 Lisp_Object portion_whole = Fcons (event->x, event->y);
1938 Lisp_Object part = *scrollbar_parts[(int) event->part]; 1953 Lisp_Object part = *scroll_bar_parts[(int) event->part];
1939 1954
1940 position = 1955 position =
1941 Fcons (window, 1956 Fcons (window,
1942 Fcons (Qvertical_scrollbar, 1957 Fcons (Qvertical_scroll_bar,
1943 Fcons (portion_whole, 1958 Fcons (portion_whole,
1944 Fcons (make_number (event->timestamp), 1959 Fcons (make_number (event->timestamp),
1945 Fcons (part, 1960 Fcons (part,
@@ -2021,18 +2036,18 @@ static Lisp_Object
2021make_lispy_movement (frame, bar_window, part, x, y, time) 2036make_lispy_movement (frame, bar_window, part, x, y, time)
2022 FRAME_PTR frame; 2037 FRAME_PTR frame;
2023 Lisp_Object bar_window; 2038 Lisp_Object bar_window;
2024 enum scrollbar_part part; 2039 enum scroll_bar_part part;
2025 Lisp_Object x, y; 2040 Lisp_Object x, y;
2026 unsigned long time; 2041 unsigned long time;
2027{ 2042{
2028 /* Is it a scrollbar movement? */ 2043 /* Is it a scroll bar movement? */
2029 if (frame && ! NILP (bar_window)) 2044 if (frame && ! NILP (bar_window))
2030 { 2045 {
2031 Lisp_Object part_sym = *scrollbar_parts[(int) part]; 2046 Lisp_Object part_sym = *scroll_bar_parts[(int) part];
2032 2047
2033 return Fcons (Qscrollbar_movement, 2048 return Fcons (Qscroll_bar_movement,
2034 (Fcons (Fcons (bar_window, 2049 (Fcons (Fcons (bar_window,
2035 Fcons (Qvertical_scrollbar, 2050 Fcons (Qvertical_scroll_bar,
2036 Fcons (Fcons (x, y), 2051 Fcons (Fcons (x, y),
2037 Fcons (make_number (time), 2052 Fcons (make_number (time),
2038 Fcons (part_sym, 2053 Fcons (part_sym,
@@ -3483,8 +3498,8 @@ drag's starting position. This means that you don't have to distinguish\n\
3483between click and drag events unless you want to.\n\ 3498between click and drag events unless you want to.\n\
3484\n\ 3499\n\
3485`read-key-sequence' prefixes mouse events on mode lines, the vertical\n\ 3500`read-key-sequence' prefixes mouse events on mode lines, the vertical\n\
3486lines separating windows, and scrollbars with imaginary keys\n\ 3501lines separating windows, and scroll bars with imaginary keys\n\
3487`mode-line', `vertical-line', and `vertical-scrollbar'.\n\ 3502`mode-line', `vertical-line', and `vertical-scroll-bar'.\n\
3488\n\ 3503\n\
3489If the user switches frames in the middle of a key sequence, the\n\ 3504If the user switches frames in the middle of a key sequence, the\n\
3490frame-switch event is put off until after the current key sequence.\n\ 3505frame-switch event is put off until after the current key sequence.\n\
@@ -4071,7 +4086,8 @@ init_keyboard ()
4071#ifdef MULTI_FRAME 4086#ifdef MULTI_FRAME
4072 /* This means that command_loop_1 won't try to select anything the first 4087 /* This means that command_loop_1 won't try to select anything the first
4073 time through. */ 4088 time through. */
4074 Vlast_event_frame = Qnil; 4089 internal_last_event_frame = Qnil;
4090 Vlast_event_frame = internal_last_event_frame;
4075#endif 4091#endif
4076 4092
4077 /* If we're running a dumped Emacs, we need to clear out 4093 /* If we're running a dumped Emacs, we need to clear out
@@ -4133,7 +4149,7 @@ struct event_head {
4133 4149
4134struct event_head head_table[] = { 4150struct event_head head_table[] = {
4135 &Qmouse_movement, "mouse-movement", &Qmouse_movement, 4151 &Qmouse_movement, "mouse-movement", &Qmouse_movement,
4136 &Qscrollbar_movement, "scrollbar-movement", &Qmouse_movement, 4152 &Qscroll_bar_movement, "scroll-bar-movement", &Qmouse_movement,
4137 &Qswitch_frame, "switch-frame", &Qswitch_frame, 4153 &Qswitch_frame, "switch-frame", &Qswitch_frame,
4138}; 4154};
4139 4155
@@ -4160,8 +4176,8 @@ syms_of_keyboard ()
4160 staticpro (&Qmode_line); 4176 staticpro (&Qmode_line);
4161 Qvertical_line = intern ("vertical-line"); 4177 Qvertical_line = intern ("vertical-line");
4162 staticpro (&Qvertical_line); 4178 staticpro (&Qvertical_line);
4163 Qvertical_scrollbar = intern ("vertical-scrollbar"); 4179 Qvertical_scroll_bar = intern ("vertical-scroll-bar");
4164 staticpro (&Qvertical_scrollbar); 4180 staticpro (&Qvertical_scroll_bar);
4165 4181
4166 Qabove_handle = intern ("above-handle"); 4182 Qabove_handle = intern ("above-handle");
4167 staticpro (&Qabove_handle); 4183 staticpro (&Qabove_handle);