aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c232
1 files changed, 126 insertions, 106 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 0740632c58d..ef958592aff 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -525,7 +525,7 @@ echo_prompt (str)
525 echo (); 525 echo ();
526} 526}
527 527
528/* Add C to the echo string, if echoing is going on. 528/* Add C to the echo string, if echoing is going on.
529 C can be a character, which is printed prettily ("M-C-x" and all that 529 C can be a character, which is printed prettily ("M-C-x" and all that
530 jazz), or a symbol, whose name is printed. */ 530 jazz), or a symbol, whose name is printed. */
531 531
@@ -537,7 +537,7 @@ echo_char (c)
537 if (current_perdisplay->immediate_echo) 537 if (current_perdisplay->immediate_echo)
538 { 538 {
539 char *ptr = current_perdisplay->echoptr; 539 char *ptr = current_perdisplay->echoptr;
540 540
541 if (ptr != current_perdisplay->echobuf) 541 if (ptr != current_perdisplay->echobuf)
542 *ptr++ = ' '; 542 *ptr++ = ' ';
543 543
@@ -762,7 +762,6 @@ unlock_display ()
762 current_perdisplay->kbd_queue_has_data = 1; 762 current_perdisplay->kbd_queue_has_data = 1;
763 } 763 }
764 Vunread_command_events = Qnil; 764 Vunread_command_events = Qnil;
765 current_perdisplay = 0;
766 display_locked = 0; 765 display_locked = 0;
767} 766}
768#endif 767#endif
@@ -776,11 +775,8 @@ cmd_error (data)
776 Vstandard_output = Qt; 775 Vstandard_output = Qt;
777 Vstandard_input = Qt; 776 Vstandard_input = Qt;
778 Vexecuting_macro = Qnil; 777 Vexecuting_macro = Qnil;
779 if (current_perdisplay) 778 clear_prefix_arg ();
780 { 779 cancel_echoing ();
781 clear_prefix_arg ();
782 cancel_echoing ();
783 }
784 780
785 /* Avoid unquittable loop if data contains a circular list. */ 781 /* Avoid unquittable loop if data contains a circular list. */
786 old_level = Vprint_level; 782 old_level = Vprint_level;
@@ -795,8 +791,7 @@ cmd_error (data)
795 791
796 Vinhibit_quit = Qnil; 792 Vinhibit_quit = Qnil;
797#ifdef MULTI_PERDISPLAY 793#ifdef MULTI_PERDISPLAY
798 if (current_perdisplay) 794 unlock_display ();
799 unlock_display ();
800#endif 795#endif
801 796
802 return make_number (0); 797 return make_number (0);
@@ -905,7 +900,7 @@ command_loop ()
905 { 900 {
906 internal_catch (Qtop_level, top_level_1, Qnil); 901 internal_catch (Qtop_level, top_level_1, Qnil);
907 internal_catch (Qtop_level, command_loop_2, Qnil); 902 internal_catch (Qtop_level, command_loop_2, Qnil);
908 903
909 /* End of file in -batch run causes exit here. */ 904 /* End of file in -batch run causes exit here. */
910 if (noninteractive) 905 if (noninteractive)
911 Fkill_emacs (Qt); 906 Fkill_emacs (Qt);
@@ -1001,8 +996,7 @@ command_loop_1 ()
1001 996
1002 Vdeactivate_mark = Qnil; 997 Vdeactivate_mark = Qnil;
1003 waiting_for_input = 0; 998 waiting_for_input = 0;
1004 if (current_perdisplay) 999 cancel_echoing ();
1005 cancel_echoing ();
1006 1000
1007 nonundocount = 0; 1001 nonundocount = 0;
1008 no_redisplay = 0; 1002 no_redisplay = 0;
@@ -1606,7 +1600,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1606 XSETINT (c, -1); 1600 XSETINT (c, -1);
1607 return c; 1601 return c;
1608 } 1602 }
1609 1603
1610 c = Faref (Vexecuting_macro, make_number (executing_macro_index)); 1604 c = Faref (Vexecuting_macro, make_number (executing_macro_index));
1611 if (STRINGP (Vexecuting_macro) 1605 if (STRINGP (Vexecuting_macro)
1612 && (XINT (c) & 0x80)) 1606 && (XINT (c) & 0x80))
@@ -1653,19 +1647,36 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1653 if (!NILP (Vinhibit_quit)) 1647 if (!NILP (Vinhibit_quit))
1654 Vquit_flag = Qnil; 1648 Vquit_flag = Qnil;
1655 1649
1650#ifdef MULTI_PERDISPLAY
1651 {
1652 PERDISPLAY *perd = get_perdisplay (selected_frame);
1653 if (perd != current_perdisplay)
1654 {
1655 Lisp_Object *tailp = &perd->kbd_queue;
1656 /* We shouldn't get here if we were locked onto one display! */
1657 if (display_locked)
1658 abort ();
1659 while (CONSP (*tailp))
1660 tailp = &XCONS (*tailp)->cdr;
1661 if (!NILP (*tailp))
1662 abort ();
1663 *tailp = Fcons (c, Qnil);
1664 perd->kbd_queue_has_data = 1;
1665 current_perdisplay = perd;
1666 longjmp (wrong_display_jmpbuf, 1);
1667 }
1668 }
1669#endif
1656 goto non_reread; 1670 goto non_reread;
1657 } 1671 }
1658 1672
1659 if (current_perdisplay) 1673 /* Message turns off echoing unless more keystrokes turn it on again. */
1660 { 1674 if (echo_area_glyphs && *echo_area_glyphs
1661 /* Message turns off echoing unless more keystrokes turn it on again. */ 1675 && echo_area_glyphs != current_perdisplay->echobuf)
1662 if (echo_area_glyphs && *echo_area_glyphs 1676 cancel_echoing ();
1663 && echo_area_glyphs != current_perdisplay->echobuf) 1677 else
1664 cancel_echoing (); 1678 /* If already echoing, continue. */
1665 else 1679 echo_dash ();
1666 /* If already echoing, continue. */
1667 echo_dash ();
1668 }
1669 1680
1670 /* Try reading a character via menu prompting in the minibuf. 1681 /* Try reading a character via menu prompting in the minibuf.
1671 Try this before the sit-for, because the sit-for 1682 Try this before the sit-for, because the sit-for
@@ -1690,9 +1701,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1690 1701
1691 /* If in middle of key sequence and minibuffer not active, 1702 /* If in middle of key sequence and minibuffer not active,
1692 start echoing if enough time elapses. */ 1703 start echoing if enough time elapses. */
1693 if (current_perdisplay 1704 if (minibuf_level == 0 && !current_perdisplay->immediate_echo
1694 && minibuf_level == 0
1695 && !current_perdisplay->immediate_echo
1696 && this_command_key_count > 0 1705 && this_command_key_count > 0
1697 && ! noninteractive 1706 && ! noninteractive
1698 && echo_keystrokes > 0 1707 && echo_keystrokes > 0
@@ -1786,33 +1795,20 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1786 1795
1787 if (NILP (c)) 1796 if (NILP (c))
1788 { 1797 {
1789 PERDISPLAY *perd; 1798 /* Primary consideration goes to current_perdisplay's side queue.
1790 /* Check for something on one of the side queues. Give priority to 1799 If that's empty, then we check the other side queues and throw
1791 the current display, but if we're not locked, then check the other 1800 if we find something there. Finally, we read from the main queue,
1792 displays as well. */ 1801 and if that gives us something we can't use yet, we put it on the
1793 if (current_perdisplay && current_perdisplay->kbd_queue_has_data) 1802 appropriate side queue and try again. */
1794 perd = current_perdisplay; 1803 if (current_perdisplay->kbd_queue_has_data)
1795 else if (!display_locked)
1796 {
1797 for (perd = all_perdisplays; perd; perd = perd->next_perdisplay)
1798 if (perd->kbd_queue_has_data)
1799 break;
1800 }
1801 else
1802 perd = 0;
1803
1804 /* If we found something on a side queue, use that.
1805 Otherwise, read from the main queue, and if that gives us
1806 something we can't use yet, put it on the side queue and
1807 try again. */
1808 if (perd)
1809 { 1804 {
1810 if (!CONSP (perd->kbd_queue)) 1805 if (!CONSP (current_perdisplay->kbd_queue))
1811 abort (); 1806 abort ();
1812 c = XCONS (perd->kbd_queue)->car; 1807 c = XCONS (current_perdisplay->kbd_queue)->car;
1813 perd->kbd_queue = XCONS (perd->kbd_queue)->cdr; 1808 current_perdisplay->kbd_queue
1814 if (NILP (perd->kbd_queue)) 1809 = XCONS (current_perdisplay->kbd_queue)->cdr;
1815 perd->kbd_queue_has_data = 0; 1810 if (NILP (current_perdisplay->kbd_queue))
1811 current_perdisplay->kbd_queue_has_data = 0;
1816 input_pending = readable_events (); 1812 input_pending = readable_events ();
1817#ifdef MULTI_FRAME 1813#ifdef MULTI_FRAME
1818 if (EVENT_HAS_PARAMETERS (c) 1814 if (EVENT_HAS_PARAMETERS (c)
@@ -1823,6 +1819,19 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1823 } 1819 }
1824 else 1820 else
1825 { 1821 {
1822 PERDISPLAY *perd;
1823#ifdef MULTI_PERDISPLAY
1824 if (!display_locked)
1825 {
1826 for (perd = all_perdisplays; perd; perd = perd->next_perdisplay)
1827 if (perd->kbd_queue_has_data)
1828 {
1829 current_perdisplay = perd;
1830 longjmp (wrong_display_jmpbuf, 1);
1831 }
1832 }
1833#endif
1834
1826 wrong_display: 1835 wrong_display:
1827 /* Actually read a character, waiting if necessary. */ 1836 /* Actually read a character, waiting if necessary. */
1828 while (c = kbd_buffer_get_event (&perd), NILP (c)) 1837 while (c = kbd_buffer_get_event (&perd), NILP (c))
@@ -1834,7 +1843,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1834 redisplay (); 1843 redisplay ();
1835 } 1844 }
1836 } 1845 }
1837 if (display_locked && perd != current_perdisplay) 1846#ifdef MULTI_PERDISPLAY
1847 if (perd != current_perdisplay)
1838 { 1848 {
1839 Lisp_Object *tailp = &perd->kbd_queue; 1849 Lisp_Object *tailp = &perd->kbd_queue;
1840 while (CONSP (*tailp)) 1850 while (CONSP (*tailp))
@@ -1843,21 +1853,13 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1843 abort (); 1853 abort ();
1844 *tailp = Fcons (c, Qnil); 1854 *tailp = Fcons (c, Qnil);
1845 perd->kbd_queue_has_data = 1; 1855 perd->kbd_queue_has_data = 1;
1846 goto wrong_display; 1856 if (display_locked)
1857 goto wrong_display;
1858 current_perdisplay = perd;
1859 longjmp (wrong_display_jmpbuf, 1);
1847 } 1860 }
1848 }
1849#ifdef MULTI_PERDISPLAY
1850 if (perd != current_perdisplay)
1851 {
1852 /* We shouldn't get here if we were locked onto one display! */
1853 if (display_locked)
1854 abort ();
1855 perd->kbd_queue = Fcons (c, perd->kbd_queue);
1856 perd->kbd_queue_has_data = 1;
1857 current_perdisplay = perd;
1858 longjmp (wrong_display_jmpbuf, 1);
1859 }
1860#endif 1861#endif
1862 }
1861 } 1863 }
1862 /* Terminate Emacs in batch mode if at eof. */ 1864 /* Terminate Emacs in batch mode if at eof. */
1863 if (noninteractive && INTEGERP (c) && XINT (c) < 0) 1865 if (noninteractive && INTEGERP (c) && XINT (c) < 0)
@@ -2111,7 +2113,7 @@ Normally, mouse motion is ignored.")
2111 prepare_menu_bars (); 2113 prepare_menu_bars ();
2112 2114
2113 XSETFRAME (do_mouse_tracking, selected_frame); 2115 XSETFRAME (do_mouse_tracking, selected_frame);
2114 2116
2115 val = Fprogn (args); 2117 val = Fprogn (args);
2116 return unbind_to (count, val); 2118 return unbind_to (count, val);
2117} 2119}
@@ -2455,9 +2457,6 @@ kbd_buffer_get_event (PERDISPLAY **perdp)
2455 Lisp_Object x, y; 2457 Lisp_Object x, y;
2456 unsigned long time; 2458 unsigned long time;
2457 2459
2458 if (!current_perdisplay)
2459 abort ();
2460
2461 *perdp = current_perdisplay; 2460 *perdp = current_perdisplay;
2462 /* Note that this uses F to determine which display to look at. 2461 /* Note that this uses F to determine which display to look at.
2463 If there is no valid info, it does not store anything 2462 If there is no valid info, it does not store anything
@@ -2486,7 +2485,7 @@ kbd_buffer_get_event (PERDISPLAY **perdp)
2486 } 2485 }
2487#endif 2486#endif
2488 2487
2489 /* If we didn't decide to make a switch-frame event, go ahead and 2488 /* If we didn't decide to make a switch-frame event, go ahead and
2490 return a mouse-motion event. */ 2489 return a mouse-motion event. */
2491 if (!NILP (x) && NILP (obj)) 2490 if (!NILP (x) && NILP (obj))
2492 obj = make_lispy_movement (f, bar_window, part, x, y, time); 2491 obj = make_lispy_movement (f, bar_window, part, x, y, time);
@@ -2752,7 +2751,7 @@ static char *lispy_function_keys[] =
2752 0, 0, 0, 0, 0, 0, 0, "delete" 2751 0, 0, 0, 0, 0, 0, 0, "delete"
2753 }; 2752 };
2754 2753
2755static char *lispy_mouse_names[] = 2754static char *lispy_mouse_names[] =
2756{ 2755{
2757 "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5" 2756 "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5"
2758}; 2757};
@@ -2873,7 +2872,7 @@ make_lispy_event (event)
2873 break; 2872 break;
2874 2873
2875#if defined (MULTI_FRAME) || defined (HAVE_MOUSE) 2874#if defined (MULTI_FRAME) || defined (HAVE_MOUSE)
2876 /* A mouse click. Figure out where it is, decide whether it's 2875 /* A mouse click. Figure out where it is, decide whether it's
2877 a press, click or drag, and build the appropriate structure. */ 2876 a press, click or drag, and build the appropriate structure. */
2878 case mouse_click: 2877 case mouse_click:
2879 case scroll_bar_click: 2878 case scroll_bar_click:
@@ -3241,7 +3240,7 @@ parse_modifiers_uncached (symbol, modifier_end)
3241 int modifiers; 3240 int modifiers;
3242 3241
3243 CHECK_SYMBOL (symbol, 1); 3242 CHECK_SYMBOL (symbol, 1);
3244 3243
3245 modifiers = 0; 3244 modifiers = 0;
3246 name = XSYMBOL (symbol)->name; 3245 name = XSYMBOL (symbol)->name;
3247 3246
@@ -3357,7 +3356,7 @@ apply_modifiers_uncached (modifiers, base, base_len)
3357 3356
3358 { 3357 {
3359 Lisp_Object new_name; 3358 Lisp_Object new_name;
3360 3359
3361 new_name = make_uninit_string (mod_len + base_len); 3360 new_name = make_uninit_string (mod_len + base_len);
3362 bcopy (new_mods, XSTRING (new_name)->data, mod_len); 3361 bcopy (new_mods, XSTRING (new_name)->data, mod_len);
3363 bcopy (base, XSTRING (new_name)->data + mod_len, base_len); 3362 bcopy (base, XSTRING (new_name)->data + mod_len, base_len);
@@ -3470,7 +3469,7 @@ apply_modifiers (modifiers, base)
3470 new_symbol = XCONS (entry)->cdr; 3469 new_symbol = XCONS (entry)->cdr;
3471 else 3470 else
3472 { 3471 {
3473 /* We have to create the symbol ourselves. */ 3472 /* We have to create the symbol ourselves. */
3474 new_symbol = apply_modifiers_uncached (modifiers, 3473 new_symbol = apply_modifiers_uncached (modifiers,
3475 XSYMBOL (base)->name->data, 3474 XSYMBOL (base)->name->data,
3476 XSYMBOL (base)->name->size); 3475 XSYMBOL (base)->name->size);
@@ -3487,7 +3486,7 @@ apply_modifiers (modifiers, base)
3487 Fcons (base, lispy_modifier_list (modifiers))); 3486 Fcons (base, lispy_modifier_list (modifiers)));
3488 } 3487 }
3489 3488
3490 /* Make sure this symbol is of the same kind as BASE. 3489 /* Make sure this symbol is of the same kind as BASE.
3491 3490
3492 You'd think we could just set this once and for all when we 3491 You'd think we could just set this once and for all when we
3493 intern the symbol above, but reorder_modifiers may call us when 3492 intern the symbol above, but reorder_modifiers may call us when
@@ -3547,12 +3546,12 @@ reorder_modifiers (symbol)
3547 before. The object stored there may be a vector or an alist. 3546 before. The object stored there may be a vector or an alist.
3548 3547
3549 SYMBOL_NUM is the number of the base name we want from NAME_TABLE. 3548 SYMBOL_NUM is the number of the base name we want from NAME_TABLE.
3550 3549
3551 MODIFIERS is a set of modifier bits (as given in struct input_events) 3550 MODIFIERS is a set of modifier bits (as given in struct input_events)
3552 whose prefixes should be applied to the symbol name. 3551 whose prefixes should be applied to the symbol name.
3553 3552
3554 SYMBOL_KIND is the value to be placed in the event_kind property of 3553 SYMBOL_KIND is the value to be placed in the event_kind property of
3555 the returned symbol. 3554 the returned symbol.
3556 3555
3557 The symbols we create are supposed to have an 3556 The symbols we create are supposed to have an
3558 `event-symbol-elements' property, which lists the modifiers present 3557 `event-symbol-elements' property, which lists the modifiers present
@@ -3620,7 +3619,7 @@ modify_event_symbol (symbol_num, modifiers, symbol_kind, name_alist,
3620 else 3619 else
3621 XVECTOR (*symbol_table)->contents[symbol_num] = value; 3620 XVECTOR (*symbol_table)->contents[symbol_num] = value;
3622 3621
3623 /* Fill in the cache entries for this symbol; this also 3622 /* Fill in the cache entries for this symbol; this also
3624 builds the Qevent_symbol_elements property, which the user 3623 builds the Qevent_symbol_elements property, which the user
3625 cares about. */ 3624 cares about. */
3626 apply_modifiers (modifiers & click_modifier, value); 3625 apply_modifiers (modifiers & click_modifier, value);
@@ -4093,7 +4092,7 @@ input_available_signal (signo)
4093void 4092void
4094reinvoke_input_signal () 4093reinvoke_input_signal ()
4095{ 4094{
4096#ifdef SIGIO 4095#ifdef SIGIO
4097 kill (0, SIGIO); 4096 kill (0, SIGIO);
4098#endif 4097#endif
4099} 4098}
@@ -4164,7 +4163,7 @@ menu_bar_items (old)
4164 We do this instead of specbind because (1) errors will clear it anyway 4163 We do this instead of specbind because (1) errors will clear it anyway
4165 and (2) this avoids risk of specpdl overflow. */ 4164 and (2) this avoids risk of specpdl overflow. */
4166 oquit = Vinhibit_quit; 4165 oquit = Vinhibit_quit;
4167 Vinhibit_quit = Qt; 4166 Vinhibit_quit = Qt;
4168 4167
4169 if (!NILP (old)) 4168 if (!NILP (old))
4170 menu_bar_items_vector = old; 4169 menu_bar_items_vector = old;
@@ -4179,7 +4178,7 @@ menu_bar_items (old)
4179 keybuf with its symbol, or if the sequence starts with a mouse 4178 keybuf with its symbol, or if the sequence starts with a mouse
4180 click and we need to switch buffers, we jump back here to rebuild 4179 click and we need to switch buffers, we jump back here to rebuild
4181 the initial keymaps from the current buffer. */ 4180 the initial keymaps from the current buffer. */
4182 { 4181 {
4183 Lisp_Object *tmaps; 4182 Lisp_Object *tmaps;
4184 4183
4185 /* Should overriding-local-map apply, here? */ 4184 /* Should overriding-local-map apply, here? */
@@ -4433,7 +4432,7 @@ menu_bar_item (key, item_string, def)
4433 USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone. 4432 USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone.
4434 4433
4435 The prompting is done based on the prompt-string of the map 4434 The prompting is done based on the prompt-string of the map
4436 and the strings associated with various map elements. 4435 and the strings associated with various map elements.
4437 4436
4438 This can be done with X menus or with menus put in the minibuf. 4437 This can be done with X menus or with menus put in the minibuf.
4439 These are done in different ways, depending on how the input will be read. 4438 These are done in different ways, depending on how the input will be read.
@@ -4654,7 +4653,7 @@ read_char_minibuf_menu_prompt (commandflag, nmaps, maps)
4654 /* Prompt with that and read response. */ 4653 /* Prompt with that and read response. */
4655 message1 (menu); 4654 message1 (menu);
4656 4655
4657 /* Make believe its not a keyboard macro in case the help char 4656 /* Make believe its not a keyboard macro in case the help char
4658 is pressed. Help characters are not recorded because menu prompting 4657 is pressed. Help characters are not recorded because menu prompting
4659 is not used on replay. 4658 is not used on replay.
4660 */ 4659 */
@@ -4750,7 +4749,7 @@ follow_key (key, nmaps, current, defs, next)
4750 return first_binding; 4749 return first_binding;
4751} 4750}
4752 4751
4753/* Read a sequence of keys that ends with a non prefix character, 4752/* Read a sequence of keys that ends with a non prefix character,
4754 storing it in KEYBUF, a buffer of size BUFSIZE. 4753 storing it in KEYBUF, a buffer of size BUFSIZE.
4755 Prompt with PROMPT. 4754 Prompt with PROMPT.
4756 Return the length of the key sequence stored. 4755 Return the length of the key sequence stored.
@@ -4909,13 +4908,13 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
4909 /* Record the initial state of the echo area and this_command_keys; 4908 /* Record the initial state of the echo area and this_command_keys;
4910 we will need to restore them if we replay a key sequence. */ 4909 we will need to restore them if we replay a key sequence. */
4911 if (INTERACTIVE) 4910 if (INTERACTIVE)
4912 echo_start = (current_perdisplay ? echo_length () : 0); 4911 echo_start = echo_length ();
4913 keys_start = this_command_key_count; 4912 keys_start = this_command_key_count;
4914 4913
4915#if defined (GOBBLE_FIRST_EVENT) 4914#if defined (GOBBLE_FIRST_EVENT)
4916 /* This doesn't quite work, because some of the things that read_char 4915 /* This doesn't quite work, because some of the things that read_char
4917 does cannot safely be bypassed. It seems too risky to try to make 4916 does cannot safely be bypassed. It seems too risky to try to make
4918 this work right. */ 4917 this work right. */
4919 4918
4920 /* Read the first char of the sequence specially, before setting 4919 /* Read the first char of the sequence specially, before setting
4921 up any keymaps, in case a filter runs and switches buffers on us. */ 4920 up any keymaps, in case a filter runs and switches buffers on us. */
@@ -4939,7 +4938,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
4939 keybuf with its symbol, or if the sequence starts with a mouse 4938 keybuf with its symbol, or if the sequence starts with a mouse
4940 click and we need to switch buffers, we jump back here to rebuild 4939 click and we need to switch buffers, we jump back here to rebuild
4941 the initial keymaps from the current buffer. */ 4940 the initial keymaps from the current buffer. */
4942 { 4941 {
4943 Lisp_Object *maps; 4942 Lisp_Object *maps;
4944 4943
4945 if (!NILP (Voverriding_local_map)) 4944 if (!NILP (Voverriding_local_map))
@@ -4983,7 +4982,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
4983 /* These are no-ops the first time through, but if we restart, they 4982 /* These are no-ops the first time through, but if we restart, they
4984 revert the echo area and this_command_keys to their original state. */ 4983 revert the echo area and this_command_keys to their original state. */
4985 this_command_key_count = keys_start; 4984 this_command_key_count = keys_start;
4986 if (INTERACTIVE && t < mock_input && current_perdisplay) 4985 if (INTERACTIVE && t < mock_input)
4987 echo_truncate (echo_start); 4986 echo_truncate (echo_start);
4988 4987
4989 /* If the best binding for the current key sequence is a keymap, or 4988 /* If the best binding for the current key sequence is a keymap, or
@@ -5026,7 +5025,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
5026 echo_local_start = echo_length (); 5025 echo_local_start = echo_length ();
5027 keys_local_start = this_command_key_count; 5026 keys_local_start = this_command_key_count;
5028 local_first_binding = first_binding; 5027 local_first_binding = first_binding;
5029 5028
5030 replay_key: 5029 replay_key:
5031 /* These are no-ops, unless we throw away a keystroke below and 5030 /* These are no-ops, unless we throw away a keystroke below and
5032 jumped back up to replay_key; in that case, these restore the 5031 jumped back up to replay_key; in that case, these restore the
@@ -5057,11 +5056,26 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
5057 { 5056 {
5058#ifdef MULTI_PERDISPLAY 5057#ifdef MULTI_PERDISPLAY
5059 PERDISPLAY *interrupted_perdisplay = current_perdisplay; 5058 PERDISPLAY *interrupted_perdisplay = current_perdisplay;
5059 struct frame *interrupted_frame = selected_frame;
5060 if (setjmp (wrong_display_jmpbuf)) 5060 if (setjmp (wrong_display_jmpbuf))
5061 { 5061 {
5062 while (t > 0) 5062 while (t > 0)
5063 interrupted_perdisplay->kbd_queue 5063 interrupted_perdisplay->kbd_queue
5064 = Fcons (keybuf[--t], interrupted_perdisplay->kbd_queue); 5064 = Fcons (keybuf[--t], interrupted_perdisplay->kbd_queue);
5065 /* Ensure that the side queue begins with a switch-frame, so
5066 we'll be in the right context when we replay it later. */
5067 if (!(CONSP (interrupted_perdisplay->kbd_queue)
5068 && (key = XCONS (interrupted_perdisplay->kbd_queue)->car,
5069 EVENT_HAS_PARAMETERS (key))
5070 && EQ (EVENT_HEAD_KIND (EVENT_HEAD (key)),
5071 Qswitch_frame)))
5072 {
5073 Lisp_Object frame;
5074 XSETFRAME (frame, interrupted_frame);
5075 interrupted_perdisplay->kbd_queue
5076 = Fcons (make_lispy_switch_frame (frame),
5077 interrupted_perdisplay->kbd_queue);
5078 }
5065 mock_input = 0; 5079 mock_input = 0;
5066 orig_local_map = get_local_map (PT, current_buffer); 5080 orig_local_map = get_local_map (PT, current_buffer);
5067 goto replay_sequence; 5081 goto replay_sequence;
@@ -5087,7 +5101,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
5087 dummyflag = 1; 5101 dummyflag = 1;
5088 break; 5102 break;
5089 } 5103 }
5090 5104
5091 /* If the current buffer has been changed from under us, the 5105 /* If the current buffer has been changed from under us, the
5092 keymap may have changed, so replay the sequence. */ 5106 keymap may have changed, so replay the sequence. */
5093 if (BUFFERP (key)) 5107 if (BUFFERP (key))
@@ -5112,7 +5126,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
5112 Vquit_flag = Qnil; 5126 Vquit_flag = Qnil;
5113 } 5127 }
5114 5128
5115 /* Clicks in non-text areas get prefixed by the symbol 5129 /* Clicks in non-text areas get prefixed by the symbol
5116 in their CHAR-ADDRESS field. For example, a click on 5130 in their CHAR-ADDRESS field. For example, a click on
5117 the mode line is prefixed by the symbol `mode-line'. 5131 the mode line is prefixed by the symbol `mode-line'.
5118 5132
@@ -5464,7 +5478,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
5464 UNGCPRO; 5478 UNGCPRO;
5465 /* If the function returned something invalid, 5479 /* If the function returned something invalid,
5466 barf--don't ignore it. 5480 barf--don't ignore it.
5467 (To ignore it safely, we would need to gcpro a bunch of 5481 (To ignore it safely, we would need to gcpro a bunch of
5468 other variables.) */ 5482 other variables.) */
5469 if (! (VECTORP (fkey_next) || STRINGP (fkey_next))) 5483 if (! (VECTORP (fkey_next) || STRINGP (fkey_next)))
5470 error ("Function in function-key-map returns invalid key sequence"); 5484 error ("Function in function-key-map returns invalid key sequence");
@@ -5497,7 +5511,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
5497 XSETFASTINT (keybuf[fkey_start + i], 5511 XSETFASTINT (keybuf[fkey_start + i],
5498 XSTRING (fkey_next)->data[i]); 5512 XSTRING (fkey_next)->data[i]);
5499 } 5513 }
5500 5514
5501 mock_input = t; 5515 mock_input = t;
5502 fkey_start = fkey_end = t; 5516 fkey_start = fkey_end = t;
5503 fkey_map = Vfunction_key_map; 5517 fkey_map = Vfunction_key_map;
@@ -5508,10 +5522,10 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
5508 5522
5509 goto replay_sequence; 5523 goto replay_sequence;
5510 } 5524 }
5511 5525
5512 fkey_map = get_keymap_1 (fkey_next, 0, 1); 5526 fkey_map = get_keymap_1 (fkey_next, 0, 1);
5513 5527
5514 /* If we no longer have a bound suffix, try a new positions for 5528 /* If we no longer have a bound suffix, try a new positions for
5515 fkey_start. */ 5529 fkey_start. */
5516 if (NILP (fkey_map)) 5530 if (NILP (fkey_map))
5517 { 5531 {
@@ -5564,7 +5578,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
5564 UNGCPRO; 5578 UNGCPRO;
5565 /* If the function returned something invalid, 5579 /* If the function returned something invalid,
5566 barf--don't ignore it. 5580 barf--don't ignore it.
5567 (To ignore it safely, we would need to gcpro a bunch of 5581 (To ignore it safely, we would need to gcpro a bunch of
5568 other variables.) */ 5582 other variables.) */
5569 if (! (VECTORP (keytran_next) || STRINGP (keytran_next))) 5583 if (! (VECTORP (keytran_next) || STRINGP (keytran_next)))
5570 error ("Function in key-translation-map returns invalid key sequence"); 5584 error ("Function in key-translation-map returns invalid key sequence");
@@ -5612,7 +5626,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
5612 5626
5613 keytran_map = get_keymap_1 (keytran_next, 0, 1); 5627 keytran_map = get_keymap_1 (keytran_next, 0, 1);
5614 5628
5615 /* If we no longer have a bound suffix, try a new positions for 5629 /* If we no longer have a bound suffix, try a new positions for
5616 keytran_start. */ 5630 keytran_start. */
5617 if (NILP (keytran_map)) 5631 if (NILP (keytran_map))
5618 { 5632 {
@@ -6093,7 +6107,7 @@ On such systems, Emacs starts a subshell instead of suspending.")
6093 /* Run suspend-resume-hook. */ 6107 /* Run suspend-resume-hook. */
6094 if (!NILP (Vrun_hooks)) 6108 if (!NILP (Vrun_hooks))
6095 call1 (Vrun_hooks, intern ("suspend-resume-hook")); 6109 call1 (Vrun_hooks, intern ("suspend-resume-hook"));
6096 6110
6097 UNGCPRO; 6111 UNGCPRO;
6098 return Qnil; 6112 return Qnil;
6099} 6113}
@@ -6453,11 +6467,17 @@ init_keyboard ()
6453 Vlast_event_frame = internal_last_event_frame; 6467 Vlast_event_frame = internal_last_event_frame;
6454#endif 6468#endif
6455 6469
6456#ifndef MULTI_PERDISPLAY 6470 if (!initialized)
6457 if (initialized) 6471 {
6458 wipe_perdisplay (&the_only_perdisplay); 6472#ifdef MULTI_PERDISPLAY
6459 init_perdisplay (&the_only_perdisplay); 6473 current_perdisplay = (PERDISPLAY *)xmalloc (sizeof (PERDISPLAY));
6474 all_perdisplays = current_perdisplay;
6460#endif 6475#endif
6476 current_perdisplay->next_perdisplay = 0;
6477 }
6478 if (initialized)
6479 wipe_perdisplay (current_perdisplay);
6480 init_perdisplay (current_perdisplay);
6461 6481
6462 if (initialized) 6482 if (initialized)
6463 Ffillarray (kbd_buffer_frame_or_window, Qnil); 6483 Ffillarray (kbd_buffer_frame_or_window, Qnil);
@@ -6505,7 +6525,7 @@ init_keyboard ()
6505#endif 6525#endif
6506} 6526}
6507 6527
6508/* This type's only use is in syms_of_keyboard, to initialize the 6528/* This type's only use is in syms_of_keyboard, to initialize the
6509 event header symbols and put properties on them. */ 6529 event header symbols and put properties on them. */
6510struct event_head { 6530struct event_head {
6511 Lisp_Object *var; 6531 Lisp_Object *var;
@@ -6749,7 +6769,7 @@ The reason for polling is to make C-g work to stop a running program.\n\
6749Polling is needed only when using X windows and SIGIO does not work.\n\ 6769Polling is needed only when using X windows and SIGIO does not work.\n\
6750Polling is automatically disabled in all other cases."); 6770Polling is automatically disabled in all other cases.");
6751 polling_period = 2; 6771 polling_period = 2;
6752 6772
6753 DEFVAR_LISP ("double-click-time", &Vdouble_click_time, 6773 DEFVAR_LISP ("double-click-time", &Vdouble_click_time,
6754 "*Maximum time between mouse clicks to make a double-click.\n\ 6774 "*Maximum time between mouse clicks to make a double-click.\n\
6755Measured in milliseconds. nil means disable double-click recognition;\n\ 6775Measured in milliseconds. nil means disable double-click recognition;\n\