aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1995-04-14 18:26:53 +0000
committerRichard M. Stallman1995-04-14 18:26:53 +0000
commit410d4de9ab0b9d087d59ee99b2d5899c8c04a2aa (patch)
treeb0e7ff08b7cee17ad77f14d800b992b365c9993d /src
parentf82aff7c94ffcf2465177b48986bafe06de201c6 (diff)
downloademacs-410d4de9ab0b9d087d59ee99b2d5899c8c04a2aa.tar.gz
emacs-410d4de9ab0b9d087d59ee99b2d5899c8c04a2aa.zip
(kbd_buffer_get_event): Don't use prototype.
(read_char): Rearrange code so that getcjmp is set only around sit_for and kbd_buffer_get_event, and and polling is stopped only around the kbd_buffer_get_event call. (Ftrack_mouse, tracking_off, read_char): Don't call prepare_menu_bars.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c153
1 files changed, 79 insertions, 74 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 12badd943ec..04beecb93fc 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1614,6 +1614,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1614{ 1614{
1615 register Lisp_Object c; 1615 register Lisp_Object c;
1616 int count; 1616 int count;
1617 jmp_buf local_getcjmp;
1617 jmp_buf save_jump; 1618 jmp_buf save_jump;
1618 int key_already_recorded = 0; 1619 int key_already_recorded = 0;
1619 Lisp_Object also_record; 1620 Lisp_Object also_record;
@@ -1687,21 +1688,45 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1687 goto reread_first; 1688 goto reread_first;
1688 } 1689 }
1689 1690
1690 /* Don't bother updating menu bars while doing mouse tracking. 1691 if (commandflag >= 0 && !input_pending && !detect_input_pending ())
1691 We get events very rapidly then, and the menu bar won't be changing. 1692 redisplay ();
1692 We do update the menu bar once on entry to Ftrack_mouse. */
1693 if (commandflag > 0 && !input_pending && !detect_input_pending ())
1694 prepare_menu_bars ();
1695 1693
1696 /* Save outer setjmp data, in case called recursively. */ 1694 /* Message turns off echoing unless more keystrokes turn it on again. */
1697 save_getcjmp (save_jump); 1695 if (echo_area_glyphs && *echo_area_glyphs
1696 && echo_area_glyphs != current_kboard->echobuf)
1697 cancel_echoing ();
1698 else
1699 /* If already echoing, continue. */
1700 echo_dash ();
1698 1701
1699 stop_polling (); 1702 /* Try reading a character via menu prompting in the minibuf.
1703 Try this before the sit-for, because the sit-for
1704 would do the wrong thing if we are supposed to do
1705 menu prompting. If EVENT_HAS_PARAMETERS then we are reading
1706 after a mouse event so don't try a minibuf menu. */
1707 c = Qnil;
1708 if (nmaps > 0 && INTERACTIVE
1709 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event)
1710 /* Don't bring up a menu if we already have another event. */
1711 && NILP (Vunread_command_events)
1712 && unread_command_char < 0
1713 && !detect_input_pending ())
1714 {
1715 c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps);
1716 if (! NILP (c))
1717 {
1718 key_already_recorded = 1;
1719 goto non_reread_1;
1720 }
1721 }
1700 1722
1701 if (commandflag >= 0 && !input_pending && !detect_input_pending ()) 1723 /* Make a longjmp point for quits to use, but don't alter getcjmp just yet.
1702 redisplay (); 1724 We will do that below, temporarily for short sections of code,
1725 when appropriate. local_getcjmp must be in effect
1726 around any call to sit_for or kbd_buffer_get_event;
1727 it *must not* be in effect when we call redisplay. */
1703 1728
1704 if (_setjmp (getcjmp)) 1729 if (_setjmp (local_getcjmp))
1705 { 1730 {
1706 XSETINT (c, quit_char); 1731 XSETINT (c, quit_char);
1707#ifdef MULTI_FRAME 1732#ifdef MULTI_FRAME
@@ -1736,37 +1761,9 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1736 goto non_reread; 1761 goto non_reread;
1737 } 1762 }
1738 1763
1739 /* Message turns off echoing unless more keystrokes turn it on again. */
1740 if (echo_area_glyphs && *echo_area_glyphs
1741 && echo_area_glyphs != current_kboard->echobuf)
1742 cancel_echoing ();
1743 else
1744 /* If already echoing, continue. */
1745 echo_dash ();
1746
1747 /* Try reading a character via menu prompting in the minibuf.
1748 Try this before the sit-for, because the sit-for
1749 would do the wrong thing if we are supposed to do
1750 menu prompting. If EVENT_HAS_PARAMETERS then we are reading
1751 after a mouse event so don't try a minibuf menu. */
1752 c = Qnil;
1753 if (nmaps > 0 && INTERACTIVE
1754 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event)
1755 /* Don't bring up a menu if we already have another event. */
1756 && NILP (Vunread_command_events)
1757 && unread_command_char < 0
1758 && !detect_input_pending ())
1759 {
1760 c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps);
1761 if (! NILP (c))
1762 {
1763 key_already_recorded = 1;
1764 goto non_reread;
1765 }
1766 }
1767
1768 /* If in middle of key sequence and minibuffer not active, 1764 /* If in middle of key sequence and minibuffer not active,
1769 start echoing if enough time elapses. */ 1765 start echoing if enough time elapses. */
1766
1770 if (minibuf_level == 0 && !current_kboard->immediate_echo 1767 if (minibuf_level == 0 && !current_kboard->immediate_echo
1771 && this_command_key_count > 0 1768 && this_command_key_count > 0
1772 && ! noninteractive 1769 && ! noninteractive
@@ -1782,31 +1779,32 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1782 echo (); 1779 echo ();
1783 else 1780 else
1784 { 1781 {
1782 save_getcjmp (save_jump);
1783 restore_getcjmp (local_getcjmp);
1785 tem0 = sit_for (echo_keystrokes, 0, 1, 1); 1784 tem0 = sit_for (echo_keystrokes, 0, 1, 1);
1785 restore_getcjmp (save_jump);
1786 if (EQ (tem0, Qt)) 1786 if (EQ (tem0, Qt))
1787 echo (); 1787 echo ();
1788 } 1788 }
1789 } 1789 }
1790 1790
1791 /* Maybe auto save due to number of keystrokes or idle time. */ 1791 /* Maybe auto save due to number of keystrokes. */
1792 1792
1793 if (commandflag != 0 1793 if (commandflag != 0
1794 && auto_save_interval > 0 1794 && auto_save_interval > 0
1795 && num_nonmacro_input_chars - last_auto_save > max (auto_save_interval, 20) 1795 && num_nonmacro_input_chars - last_auto_save > max (auto_save_interval, 20)
1796 && !detect_input_pending ()) 1796 && !detect_input_pending ())
1797 { 1797 {
1798 jmp_buf temp;
1799 save_getcjmp (temp);
1800 Fdo_auto_save (Qnil, Qnil); 1798 Fdo_auto_save (Qnil, Qnil);
1801 /* Hooks can actually change some buffers in auto save. */ 1799 /* Hooks can actually change some buffers in auto save. */
1802 redisplay (); 1800 redisplay ();
1803 restore_getcjmp (temp);
1804 } 1801 }
1805 1802
1806 /* Try reading using an X menu. 1803 /* Try reading using an X menu.
1807 This is never confused with reading using the minibuf 1804 This is never confused with reading using the minibuf
1808 because the recursive call of read_char in read_char_minibuf_menu_prompt 1805 because the recursive call of read_char in read_char_minibuf_menu_prompt
1809 does not pass on any keymaps. */ 1806 does not pass on any keymaps. */
1807
1810 if (nmaps > 0 && INTERACTIVE 1808 if (nmaps > 0 && INTERACTIVE
1811 && !NILP (prev_event) && EVENT_HAS_PARAMETERS (prev_event) 1809 && !NILP (prev_event) && EVENT_HAS_PARAMETERS (prev_event)
1812 /* Don't bring up a menu if we already have another event. */ 1810 /* Don't bring up a menu if we already have another event. */
@@ -1814,12 +1812,14 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1814 && unread_command_char < 0) 1812 && unread_command_char < 0)
1815 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); 1813 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu);
1816 1814
1817 /* Slow down auto saves logarithmically in size of current buffer, 1815 /* Maybe autosave and/or garbage collect due to idleness. */
1818 and garbage collect while we're at it. */ 1816
1819 if (INTERACTIVE && NILP (c)) 1817 if (INTERACTIVE && NILP (c))
1820 { 1818 {
1821 int delay_level, buffer_size; 1819 int delay_level, buffer_size;
1822 1820
1821 /* Slow down auto saves logarithmically in size of current buffer,
1822 and garbage collect while we're at it. */
1823 if (! MINI_WINDOW_P (XWINDOW (selected_window))) 1823 if (! MINI_WINDOW_P (XWINDOW (selected_window)))
1824 last_non_minibuf_size = Z - BEG; 1824 last_non_minibuf_size = Z - BEG;
1825 buffer_size = (last_non_minibuf_size >> 8) + 1; 1825 buffer_size = (last_non_minibuf_size >> 8) + 1;
@@ -1838,13 +1838,15 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1838 { 1838 {
1839 Lisp_Object tem0; 1839 Lisp_Object tem0;
1840 int delay = delay_level * XFASTINT (Vauto_save_timeout) / 4; 1840 int delay = delay_level * XFASTINT (Vauto_save_timeout) / 4;
1841
1842 save_getcjmp (save_jump);
1843 restore_getcjmp (local_getcjmp);
1841 tem0 = sit_for (delay, 0, 1, 1); 1844 tem0 = sit_for (delay, 0, 1, 1);
1845 restore_getcjmp (save_jump);
1846
1842 if (EQ (tem0, Qt)) 1847 if (EQ (tem0, Qt))
1843 { 1848 {
1844 jmp_buf temp;
1845 save_getcjmp (temp);
1846 Fdo_auto_save (Qnil, Qnil); 1849 Fdo_auto_save (Qnil, Qnil);
1847 restore_getcjmp (temp);
1848 1850
1849 /* If we have auto-saved and there is still no input 1851 /* If we have auto-saved and there is still no input
1850 available, garbage collect if there has been enough 1852 available, garbage collect if there has been enough
@@ -1852,17 +1854,16 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1852 if (!detect_input_pending () 1854 if (!detect_input_pending ()
1853 && consing_since_gc > gc_cons_threshold / 2) 1855 && consing_since_gc > gc_cons_threshold / 2)
1854 Fgarbage_collect (); 1856 Fgarbage_collect ();
1855 /* prepare_menu_bars isn't safe here, but it should 1857
1856 also be unnecessary. */
1857 redisplay (); 1858 redisplay ();
1858 } 1859 }
1859 } 1860 }
1860 } 1861 }
1861 1862
1863 /* Read something from current KBOARD's side queue, if possible. */
1864
1862 if (NILP (c)) 1865 if (NILP (c))
1863 { 1866 {
1864 /* Primary consideration goes to current_kboard's side queue. */
1865
1866 if (current_kboard->kbd_queue_has_data) 1867 if (current_kboard->kbd_queue_has_data)
1867 { 1868 {
1868 if (!CONSP (current_kboard->kbd_queue)) 1869 if (!CONSP (current_kboard->kbd_queue))
@@ -1903,27 +1904,26 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1903 } 1904 }
1904#endif 1905#endif
1905 1906
1907 wrong_kboard:
1908
1909 stop_polling ();
1910
1906 /* Finally, we read from the main queue, 1911 /* Finally, we read from the main queue,
1907 and if that gives us something we can't use yet, we put it on the 1912 and if that gives us something we can't use yet, we put it on the
1908 appropriate side queue and try again. */ 1913 appropriate side queue and try again. */
1914
1909 if (NILP (c)) 1915 if (NILP (c))
1910 { 1916 {
1911 KBOARD *kb; 1917 KBOARD *kb;
1912 1918
1913 wrong_kboard:
1914
1915 /* Actually read a character, waiting if necessary. */ 1919 /* Actually read a character, waiting if necessary. */
1916 while (c = kbd_buffer_get_event (&kb), NILP (c)) 1920 save_getcjmp (save_jump);
1917 { 1921 restore_getcjmp (local_getcjmp);
1918 if (commandflag >= 0 1922 c = kbd_buffer_get_event (&kb);
1919 && !input_pending && !detect_input_pending ()) 1923 restore_getcjmp (save_jump);
1920 { 1924
1921 prepare_menu_bars ();
1922 redisplay ();
1923 }
1924 }
1925#ifdef MULTI_KBOARD 1925#ifdef MULTI_KBOARD
1926 if (kb != current_kboard) 1926 if (! NILP (c) && (kb != current_kboard))
1927 { 1927 {
1928 Lisp_Object *tailp = &kb->kbd_queue; 1928 Lisp_Object *tailp = &kb->kbd_queue;
1929 while (CONSP (*tailp)) 1929 while (CONSP (*tailp))
@@ -1960,10 +1960,19 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1960 1960
1961 non_reread: 1961 non_reread:
1962 1962
1963 restore_getcjmp (save_jump);
1964
1965 start_polling (); 1963 start_polling ();
1966 1964
1965 if (NILP (c))
1966 {
1967 if (commandflag >= 0
1968 && !input_pending && !detect_input_pending ())
1969 redisplay ();
1970
1971 goto wrong_kboard;
1972 }
1973
1974 non_reread_1:
1975
1967 /* Buffer switch events are only for internal wakeups 1976 /* Buffer switch events are only for internal wakeups
1968 so don't show them to the user. */ 1977 so don't show them to the user. */
1969 if (BUFFERP (c)) 1978 if (BUFFERP (c))
@@ -2057,7 +2066,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
2057 while (BUFFERP (c)); 2066 while (BUFFERP (c));
2058 /* Remove the help from the frame */ 2067 /* Remove the help from the frame */
2059 unbind_to (count, Qnil); 2068 unbind_to (count, Qnil);
2060 prepare_menu_bars (); 2069
2061 redisplay (); 2070 redisplay ();
2062 if (EQ (c, make_number (040))) 2071 if (EQ (c, make_number (040)))
2063 { 2072 {
@@ -2147,7 +2156,6 @@ restore_getcjmp (temp)
2147{ 2156{
2148 bcopy (temp, getcjmp, sizeof getcjmp); 2157 bcopy (temp, getcjmp, sizeof getcjmp);
2149} 2158}
2150
2151 2159
2152#ifdef HAVE_MOUSE 2160#ifdef HAVE_MOUSE
2153 2161
@@ -2168,7 +2176,6 @@ tracking_off (old_value)
2168 redisplay. */ 2176 redisplay. */
2169 if (!readable_events ()) 2177 if (!readable_events ())
2170 { 2178 {
2171 prepare_menu_bars ();
2172 redisplay_preserve_echo_area (); 2179 redisplay_preserve_echo_area ();
2173 get_input_pending (&input_pending); 2180 get_input_pending (&input_pending);
2174 } 2181 }
@@ -2188,9 +2195,6 @@ Normally, mouse motion is ignored.")
2188 2195
2189 record_unwind_protect (tracking_off, do_mouse_tracking); 2196 record_unwind_protect (tracking_off, do_mouse_tracking);
2190 2197
2191 if (!input_pending && !detect_input_pending ())
2192 prepare_menu_bars ();
2193
2194 XSETFRAME (do_mouse_tracking, selected_frame); 2198 XSETFRAME (do_mouse_tracking, selected_frame);
2195 2199
2196 val = Fprogn (args); 2200 val = Fprogn (args);
@@ -2377,7 +2381,8 @@ kbd_buffer_store_event (event)
2377 We always read and discard one event. */ 2381 We always read and discard one event. */
2378 2382
2379static Lisp_Object 2383static Lisp_Object
2380kbd_buffer_get_event (KBOARD **kbp) 2384kbd_buffer_get_event (kbp)
2385 KBOARD **kbp;
2381{ 2386{
2382 register int c; 2387 register int c;
2383 Lisp_Object obj; 2388 Lisp_Object obj;