aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-03-15 05:46:58 +0000
committerRichard M. Stallman1993-03-15 05:46:58 +0000
commit48e416d4fd79a60052ff114709ccd8293e058b07 (patch)
tree882a6bdeb6b11dca2fed84fb09d2fa054d21785c
parentedfa9106ca7c5ebf374129fa1dc96b69dddbcc51 (diff)
downloademacs-48e416d4fd79a60052ff114709ccd8293e058b07.tar.gz
emacs-48e416d4fd79a60052ff114709ccd8293e058b07.zip
(command_loop_1): Set FRAME_MENU_BAR_ITEMS here.
(menu_bar_items): Reverse the list when done. (command_loop_1): Typo calling Qrecompute_lucid_menubar. (read_key_sequence): Likewise. Also fix call to Vrun_hooks. (kbd_buffer_get_event): Handle selection_clear_event and selection_request_event events. (read_key_sequence): Support Vcurrent_menubar and Qactivate_menubar_hook. Call Qrecompute_lucid_menubar. (syms_of_keyboard): Set up Vcurrent_menubar, Vprevious_lucid_menubar, Qactivate_menubar_hook, and Qrecompute_lucid_menubar.
-rw-r--r--src/keyboard.c92
1 files changed, 80 insertions, 12 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index c942e16c265..904257ad912 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -245,6 +245,11 @@ extern Lisp_Object Vfunction_key_map;
245/* Non-nil means deactivate the mark at end of this command. */ 245/* Non-nil means deactivate the mark at end of this command. */
246Lisp_Object Vdeactivate_mark; 246Lisp_Object Vdeactivate_mark;
247 247
248/* Menu bar specified in Lucid Emacs fashion. */
249
250Lisp_Object Vlucid_menu_bar_dirty_flag;
251Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
252
248/* Hooks to run before and after each command. */ 253/* Hooks to run before and after each command. */
249Lisp_Object Qpre_command_hook, Qpost_command_hook; 254Lisp_Object Qpre_command_hook, Qpost_command_hook;
250Lisp_Object Vpre_command_hook, Vpost_command_hook; 255Lisp_Object Vpre_command_hook, Vpost_command_hook;
@@ -835,7 +840,7 @@ static int read_key_sequence ();
835Lisp_Object 840Lisp_Object
836command_loop_1 () 841command_loop_1 ()
837{ 842{
838 Lisp_Object cmd; 843 Lisp_Object cmd, tem;
839 int lose; 844 int lose;
840 int nonundocount; 845 int nonundocount;
841 Lisp_Object keybuf[30]; 846 Lisp_Object keybuf[30];
@@ -916,6 +921,28 @@ command_loop_1 ()
916 Fselect_frame (internal_last_event_frame, Qnil); 921 Fselect_frame (internal_last_event_frame, Qnil);
917#endif 922#endif
918#endif 923#endif
924 /* If it has changed current-menubar from previous value,
925 really recompute the menubar from the value. */
926 if (! NILP (Vlucid_menu_bar_dirty_flag))
927 call0 (Qrecompute_lucid_menubar);
928
929#ifdef MULTI_FRAME
930 for (tem = Vframe_list; CONSP (tem); tem = XCONS (tem)->cdr)
931 {
932 struct frame *f = XFRAME (XCONS (tem)->car);
933 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
934 if (windows_or_buffers_changed
935 || (XFASTINT (w->last_modified) < MODIFF
936 && (XFASTINT (w->last_modified)
937 <= XBUFFER (w->buffer)->save_modified)))
938 {
939 struct buffer *prev = current_buffer;
940 current_buffer = XBUFFER (w->buffer);
941 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items ();
942 current_buffer = prev;
943 }
944 }
945#endif /* MULTI_FRAME */
919 946
920 /* Read next key sequence; i gets its length. */ 947 /* Read next key sequence; i gets its length. */
921 i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), 0); 948 i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), 0);
@@ -1678,6 +1705,7 @@ kbd_buffer_get_event ()
1678 return obj; 1705 return obj;
1679 } 1706 }
1680 1707
1708 retry:
1681 /* Wait until there is input available. */ 1709 /* Wait until there is input available. */
1682 for (;;) 1710 for (;;)
1683 { 1711 {
@@ -1729,6 +1757,22 @@ kbd_buffer_get_event ()
1729 1757
1730 obj = Qnil; 1758 obj = Qnil;
1731 1759
1760 /* These two kinds of events get special handling
1761 and don't actually appear to the command loop. */
1762 if (event->kind == selection_request_event)
1763 {
1764 x_handle_selection_request (event);
1765 kbd_fetch_ptr = event + 1;
1766 goto retry;
1767 }
1768
1769 if (event->kind == selection_clear_event)
1770 {
1771 x_handle_selection_clear (event);
1772 kbd_fetch_ptr = event + 1;
1773 goto retry;
1774 }
1775
1732#ifdef MULTI_FRAME 1776#ifdef MULTI_FRAME
1733 /* If this event is on a different frame, return a switch-frame this 1777 /* If this event is on a different frame, return a switch-frame this
1734 time, and leave the event in the queue for next time. */ 1778 time, and leave the event in the queue for next time. */
@@ -1806,6 +1850,11 @@ kbd_buffer_get_event ()
1806 something for us to read! */ 1850 something for us to read! */
1807 abort (); 1851 abort ();
1808 1852
1853 /* If something gave back nil as the Lispy event,
1854 it means the event was discarded, so try again. */
1855 if (NILP (obj))
1856 goto retry;
1857
1809 input_pending = readable_events (); 1858 input_pending = readable_events ();
1810 1859
1811#ifdef MULTI_FRAME 1860#ifdef MULTI_FRAME
@@ -2096,19 +2145,22 @@ make_lispy_event (event)
2096 see if this was a click or a drag. */ 2145 see if this was a click or a drag. */
2097 else if (event->modifiers & up_modifier) 2146 else if (event->modifiers & up_modifier)
2098 { 2147 {
2099 /* Is there a start position stored at all for this 2148 /* If we did not see a down before this up,
2100 button? 2149 ignore the up. Probably this happened because
2101 2150 the down event chose a menu item.
2102 It would be nice if we could assume that if we're 2151 It would be an annoyance to treat the release
2103 getting a button release, we must therefore have gotten 2152 of the button that chose the menu item
2104 a button press. Unfortunately, the X menu code thwarts 2153 as a separate event. */
2105 this assumption, so we'll have to be more robust. We 2154
2106 treat a button release with no stored start position as 2155 if (XTYPE (start_pos) != Lisp_Cons)
2107 a click. */ 2156 return Qnil;
2157
2108 event->modifiers &= ~up_modifier; 2158 event->modifiers &= ~up_modifier;
2159#if 0 /* Formerly we treated an up with no down as a click event. */
2109 if (XTYPE (start_pos) != Lisp_Cons) 2160 if (XTYPE (start_pos) != Lisp_Cons)
2110 event->modifiers |= click_modifier; 2161 event->modifiers |= click_modifier;
2111 else 2162 else
2163#endif
2112 { 2164 {
2113 /* The third element of every position should be the (x,y) 2165 /* The third element of every position should be the (x,y)
2114 pair. */ 2166 pair. */
@@ -2149,7 +2201,7 @@ make_lispy_event (event)
2149 2201
2150 /* The 'kind' field of the event is something we don't recognize. */ 2202 /* The 'kind' field of the event is something we don't recognize. */
2151 default: 2203 default:
2152 abort(); 2204 abort ();
2153 } 2205 }
2154} 2206}
2155 2207
@@ -2879,7 +2931,7 @@ menu_bar_items ()
2879 result = menu_bar_one_keymap (def, result); 2931 result = menu_bar_one_keymap (def, result);
2880 } 2932 }
2881 2933
2882 return result; 2934 return Fnreverse (result);
2883} 2935}
2884 2936
2885/* Scan one map KEYMAP, accumulating any menu items it defines 2937/* Scan one map KEYMAP, accumulating any menu items it defines
@@ -3286,6 +3338,7 @@ follow_key (key, nmaps, current, defs, next)
3286 If the user switches frames in the midst of a key sequence, we put 3338 If the user switches frames in the midst of a key sequence, we put
3287 off the switch-frame event until later; the next call to 3339 off the switch-frame event until later; the next call to
3288 read_char will return it. */ 3340 read_char will return it. */
3341
3289static int 3342static int
3290read_key_sequence (keybuf, bufsize, prompt) 3343read_key_sequence (keybuf, bufsize, prompt)
3291 Lisp_Object *keybuf; 3344 Lisp_Object *keybuf;
@@ -3568,6 +3621,12 @@ read_key_sequence (keybuf, bufsize, prompt)
3568 { 3621 {
3569 if (t + 1 >= bufsize) 3622 if (t + 1 >= bufsize)
3570 error ("key sequence too long"); 3623 error ("key sequence too long");
3624 /* Run the Lucid hook. */
3625 call1 (Vrun_hooks, Qactivate_menubar_hook);
3626 /* If it has changed current-menubar from previous value,
3627 really recompute the menubar from the value. */
3628 if (! NILP (Vlucid_menu_bar_dirty_flag))
3629 call0 (Qrecompute_lucid_menubar);
3571 keybuf[t] = posn; 3630 keybuf[t] = posn;
3572 keybuf[t+1] = key; 3631 keybuf[t+1] = key;
3573 mock_input = t + 2; 3632 mock_input = t + 2;
@@ -4489,6 +4548,11 @@ syms_of_keyboard ()
4489 Qmodifier_cache = intern ("modifier-cache"); 4548 Qmodifier_cache = intern ("modifier-cache");
4490 staticpro (&Qmodifier_cache); 4549 staticpro (&Qmodifier_cache);
4491 4550
4551 Qrecompute_lucid_menubar = intern ("recompute-lucid-menubar");
4552 staticpro (&Qrecompute_lucid_menubar);
4553 Qactivate_menubar_hook = intern ("activate-menubar-hook");
4554 staticpro (&Qactivate_menubar_hook);
4555
4492 { 4556 {
4493 struct event_head *p; 4557 struct event_head *p;
4494 4558
@@ -4692,6 +4756,10 @@ Buffer modification stores t in this variable.");
4692 DEFVAR_LISP ("post-command-hook", &Vpost_command_hook, 4756 DEFVAR_LISP ("post-command-hook", &Vpost_command_hook,
4693 "Normal hook run before each command is executed."); 4757 "Normal hook run before each command is executed.");
4694 Vpost_command_hook = Qnil; 4758 Vpost_command_hook = Qnil;
4759
4760 DEFVAR_LISP ("lucid-menu-bar-dirty-flag", &Vlucid_menu_bar_dirty_flag,
4761 "t means menu bar, specified Lucid style, needs to be recomputed.");
4762 Vlucid_menu_bar_dirty_flag = Qnil;
4695} 4763}
4696 4764
4697keys_of_keyboard () 4765keys_of_keyboard ()