Mercurial > emacs
annotate src/xmenu.c @ 11322:518a5db7f4f0
(ALL_CFLAGS): Add -I${srcdir}/../src.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 09 Apr 1995 04:58:29 +0000 |
parents | 3e93d8b99b05 |
children | fca5a32f7806 |
rev | line source |
---|---|
118 | 1 /* X Communication module for terminals which understand the X protocol. |
6018
51d9a0c72a29
(single_keymap_panes): Properly skip help-string if any.
Richard M. Stallman <rms@gnu.org>
parents:
6007
diff
changeset
|
2 Copyright (C) 1986, 1988, 1993, 1994 Free Software Foundation, Inc. |
118 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
1437
36ef55ecb265
* frame.c (make_frame_without_minibuffer, Fwindow_frame): Use
Jim Blandy <jimb@redhat.com>
parents:
1304
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
118 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 /* X pop-up deck-of-cards menu facility for gnuemacs. | |
21 * | |
22 * Written by Jon Arnold and Roman Budzianowski | |
23 * Mods and rewrite by Robert Krawitz | |
24 * | |
25 */ | |
26 | |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
27 /* Modified by Fred Pierresteguy on December 93 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
28 to make the popup menus and menubar use the Xt. */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
29 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
30 /* Rewritten for clarity and GC protection by rms in Feb 94. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
31 |
118 | 32 /* On 4.3 this loses if it comes after xterm.h. */ |
33 #include <signal.h> | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4627
diff
changeset
|
34 #include <config.h> |
7900
60795e826dad
Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7871
diff
changeset
|
35 |
60795e826dad
Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents:
7871
diff
changeset
|
36 #include <stdio.h> |
118 | 37 #include "lisp.h" |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
38 #include "termhooks.h" |
770 | 39 #include "frame.h" |
118 | 40 #include "window.h" |
1304
93d55019750e
* xmenu.c: #include "keyboard.h".
Jim Blandy <jimb@redhat.com>
parents:
1213
diff
changeset
|
41 #include "keyboard.h" |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2209
diff
changeset
|
42 #include "blockinput.h" |
8746 | 43 #include "puresize.h" |
118 | 44 |
10502
1b08df5c5e4a
[MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents:
10167
diff
changeset
|
45 #ifdef MSDOS |
1b08df5c5e4a
[MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents:
10167
diff
changeset
|
46 #include "msdos.h" |
1b08df5c5e4a
[MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents:
10167
diff
changeset
|
47 #endif |
1b08df5c5e4a
[MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents:
10167
diff
changeset
|
48 |
9572 | 49 #ifdef HAVE_X_WINDOWS |
118 | 50 /* This may include sys/types.h, and that somehow loses |
51 if this is not done before the other system files. */ | |
52 #include "xterm.h" | |
9572 | 53 #endif |
118 | 54 |
55 /* Load sys/types.h if not already loaded. | |
56 In some systems loading it twice is suicidal. */ | |
57 #ifndef makedev | |
58 #include <sys/types.h> | |
59 #endif | |
60 | |
61 #include "dispextern.h" | |
62 | |
9572 | 63 #ifdef HAVE_X_WINDOWS |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
64 #ifdef USE_X_TOOLKIT |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
65 #include <X11/Xlib.h> |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
66 #include <X11/IntrinsicP.h> |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
67 #include <X11/CoreP.h> |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
68 #include <X11/StringDefs.h> |
8414
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
69 #include <X11/Shell.h> |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
70 #include "../lwlib/lwlib.h" |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
71 #else /* not USE_X_TOOLKIT */ |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
72 #include "../oldXMenu/XMenu.h" |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
73 #endif /* not USE_X_TOOLKIT */ |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
74 #endif /* HAVE_X_WINDOWS */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
75 |
118 | 76 #define min(x,y) (((x) < (y)) ? (x) : (y)) |
77 #define max(x,y) (((x) > (y)) ? (x) : (y)) | |
78 | |
79 #ifndef TRUE | |
80 #define TRUE 1 | |
81 #define FALSE 0 | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
82 #endif /* no TRUE */ |
118 | 83 |
2514
6700e25af205
Since Qmenu_enable is used by non-X-specific code, it shouldn't be
Jim Blandy <jimb@redhat.com>
parents:
2439
diff
changeset
|
84 extern Lisp_Object Qmenu_enable; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
85 extern Lisp_Object Qmenu_bar; |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
86 extern Lisp_Object Qmouse_click, Qevent_kind; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
87 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
88 #ifdef USE_X_TOOLKIT |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
89 extern void process_expose_from_menu (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
90 extern XtAppContext Xt_app_con; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
91 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
92 static Lisp_Object xdialog_show (); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
93 void popup_get_selection (); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
94 #endif |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
95 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
96 static Lisp_Object xmenu_show (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
97 static void keymap_panes (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
98 static void single_keymap_panes (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
99 static void list_of_panes (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
100 static void list_of_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
101 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
102 /* This holds a Lisp vector that holds the results of decoding |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
103 the keymaps or alist-of-alists that specify a menu. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
104 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
105 It describes the panes and items within the panes. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
106 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
107 Each pane is described by 3 elements in the vector: |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
108 t, the pane name, the pane's prefix key. |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
109 Then follow the pane's items, with 5 elements per item: |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
110 the item string, the enable flag, the item's value, |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
111 the definition, and the equivalent keyboard key's description string. |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
112 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
113 In some cases, multiple levels of menus may be described. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
114 A single vector slot containing nil indicates the start of a submenu. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
115 A single vector slot containing lambda indicates the end of a submenu. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
116 The submenu follows a menu item which is the way to reach the submenu. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
117 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
118 A single vector slot containing quote indicates that the |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
119 following items should appear on the right of a dialog box. |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
120 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
121 Using a Lisp vector to hold this information while we decode it |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
122 takes care of protecting all the data from GC. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
123 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
124 #define MENU_ITEMS_PANE_NAME 1 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
125 #define MENU_ITEMS_PANE_PREFIX 2 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
126 #define MENU_ITEMS_PANE_LENGTH 3 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
127 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
128 #define MENU_ITEMS_ITEM_NAME 0 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
129 #define MENU_ITEMS_ITEM_ENABLE 1 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
130 #define MENU_ITEMS_ITEM_VALUE 2 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
131 #define MENU_ITEMS_ITEM_EQUIV_KEY 3 |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
132 #define MENU_ITEMS_ITEM_DEFINITION 4 |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
133 #define MENU_ITEMS_ITEM_LENGTH 5 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
134 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
135 static Lisp_Object menu_items; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
136 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
137 /* Number of slots currently allocated in menu_items. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
138 static int menu_items_allocated; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
139 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
140 /* This is the index in menu_items of the first empty slot. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
141 static int menu_items_used; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
142 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
143 /* The number of panes currently recorded in menu_items, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
144 excluding those within submenus. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
145 static int menu_items_n_panes; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
146 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
147 /* Current depth within submenus. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
148 static int menu_items_submenu_depth; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
149 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
150 /* Flag which when set indicates a dialog or menu has been posted by |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
151 Xt on behalf of one of the widget sets. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
152 static int popup_activated_flag; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
153 |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
154 /* This holds a Lisp vector |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
155 which contains frames that have menu bars. |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
156 Each frame that has a menu bar is found at some index in this vector |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
157 and the menu bar widget refers to the frame through that index. */ |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
158 static Lisp_Object frame_vector; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
159 |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
160 /* Return the index of FRAME in frame_vector. |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
161 If FRAME isn't in frame_vector yet, put it in, |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
162 lengthening the vector if necessary. */ |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
163 |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
164 static int |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
165 frame_vector_add_frame (f) |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
166 FRAME_PTR *f; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
167 { |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
168 int length = XVECTOR (frame_vector)->size; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
169 int i, empty = -1; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
170 Lisp_Object new, frame; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
171 |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
172 XSETFRAME (frame, f); |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
173 |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
174 for (i = 0; i < length; i++) |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
175 { |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
176 if (EQ (frame, XVECTOR (frame_vector)->contents[i])) |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
177 return i; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
178 if (NILP (XVECTOR (frame_vector)->contents[i])) |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
179 empty = i; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
180 } |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
181 |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
182 if (empty >= 0) |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
183 { |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
184 XVECTOR (frame_vector)->contents[empty] = frame; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
185 return empty; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
186 } |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
187 |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
188 new = Fmake_vector (make_number (length * 2), Qnil); |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
189 bcopy (XVECTOR (frame_vector)->contents, |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
190 XVECTOR (new)->contents, sizeof (Lisp_Object) * length); |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
191 |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
192 XVECTOR (frame_vector)->contents[length] = frame; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
193 return length; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
194 } |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
195 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
196 /* Initialize the menu_items structure if we haven't already done so. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
197 Also mark it as currently empty. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
198 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
199 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
200 init_menu_items () |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
201 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
202 if (NILP (menu_items)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
203 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
204 menu_items_allocated = 60; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
205 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
206 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
207 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
208 menu_items_used = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
209 menu_items_n_panes = 0; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
210 menu_items_submenu_depth = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
211 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
212 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
213 /* Call at the end of generating the data in menu_items. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
214 This fills in the number of items in the last pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
215 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
216 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
217 finish_menu_items () |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
218 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
219 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
220 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
221 /* Call when finished using the data for the current menu |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
222 in menu_items. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
223 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
224 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
225 discard_menu_items () |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
226 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
227 /* Free the structure if it is especially large. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
228 Otherwise, hold on to it, to save time. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
229 if (menu_items_allocated > 200) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
230 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
231 menu_items = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
232 menu_items_allocated = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
233 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
234 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
235 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
236 /* Make the menu_items vector twice as large. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
237 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
238 static void |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
239 grow_menu_items () |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
240 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
241 Lisp_Object old; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
242 int old_size = menu_items_allocated; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
243 old = menu_items; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
244 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
245 menu_items_allocated *= 2; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
246 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
247 bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
248 old_size * sizeof (Lisp_Object)); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
249 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
250 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
251 /* Begin a submenu. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
252 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
253 static void |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
254 push_submenu_start () |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
255 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
256 if (menu_items_used + 1 > menu_items_allocated) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
257 grow_menu_items (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
258 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
259 XVECTOR (menu_items)->contents[menu_items_used++] = Qnil; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
260 menu_items_submenu_depth++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
261 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
262 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
263 /* End a submenu. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
264 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
265 static void |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
266 push_submenu_end () |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
267 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
268 if (menu_items_used + 1 > menu_items_allocated) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
269 grow_menu_items (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
270 |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
271 XVECTOR (menu_items)->contents[menu_items_used++] = Qlambda; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
272 menu_items_submenu_depth--; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
273 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
274 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
275 /* Indicate boundary between left and right. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
276 |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
277 static void |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
278 push_left_right_boundary () |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
279 { |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
280 if (menu_items_used + 1 > menu_items_allocated) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
281 grow_menu_items (); |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
282 |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
283 XVECTOR (menu_items)->contents[menu_items_used++] = Qquote; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
284 } |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
285 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
286 /* Start a new menu pane in menu_items.. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
287 NAME is the pane name. PREFIX_VEC is a prefix key for this pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
288 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
289 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
290 push_menu_pane (name, prefix_vec) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
291 Lisp_Object name, prefix_vec; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
292 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
293 if (menu_items_used + MENU_ITEMS_PANE_LENGTH > menu_items_allocated) |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
294 grow_menu_items (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
295 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
296 if (menu_items_submenu_depth == 0) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
297 menu_items_n_panes++; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
298 XVECTOR (menu_items)->contents[menu_items_used++] = Qt; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
299 XVECTOR (menu_items)->contents[menu_items_used++] = name; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
300 XVECTOR (menu_items)->contents[menu_items_used++] = prefix_vec; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
301 } |
118 | 302 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
303 /* Push one menu item into the current pane. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
304 NAME is the string to display. ENABLE if non-nil means |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
305 this item can be selected. KEY is the key generated by |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
306 choosing this item, or nil if this item doesn't really have a definition. |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
307 DEF is the definition of this item. |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
308 EQUIV is the textual description of the keyboard equivalent for |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
309 this item (or nil if none). */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
310 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
311 static void |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
312 push_menu_item (name, enable, key, def, equiv) |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
313 Lisp_Object name, enable, key, def, equiv; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
314 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
315 if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated) |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
316 grow_menu_items (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
317 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
318 XVECTOR (menu_items)->contents[menu_items_used++] = name; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
319 XVECTOR (menu_items)->contents[menu_items_used++] = enable; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
320 XVECTOR (menu_items)->contents[menu_items_used++] = key; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
321 XVECTOR (menu_items)->contents[menu_items_used++] = equiv; |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
322 XVECTOR (menu_items)->contents[menu_items_used++] = def; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
323 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
324 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
325 /* Figure out the current keyboard equivalent of a menu item ITEM1. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
326 The item string for menu display should be ITEM_STRING. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
327 Store the equivalent keyboard key sequence's |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
328 textual description into *DESCRIP_PTR. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
329 Also cache them in the item itself. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
330 Return the real definition to execute. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
331 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
332 static Lisp_Object |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
333 menu_item_equiv_key (item_string, item1, descrip_ptr) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
334 Lisp_Object item_string; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
335 Lisp_Object item1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
336 Lisp_Object *descrip_ptr; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
337 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
338 /* This is the real definition--the function to run. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
339 Lisp_Object def; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
340 /* This is the sublist that records cached equiv key data |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
341 so we can save time. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
342 Lisp_Object cachelist; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
343 /* These are the saved equivalent keyboard key sequence |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
344 and its key-description. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
345 Lisp_Object savedkey, descrip; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
346 Lisp_Object def1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
347 int changed = 0; |
7997
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
348 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
349 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
350 /* If a help string follows the item string, skip it. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
351 if (CONSP (XCONS (item1)->cdr) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
352 && STRINGP (XCONS (XCONS (item1)->cdr)->car)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
353 item1 = XCONS (item1)->cdr; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
354 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
355 def = Fcdr (item1); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
356 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
357 /* Get out the saved equivalent-keyboard-key info. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
358 cachelist = savedkey = descrip = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
359 if (CONSP (def) && CONSP (XCONS (def)->car) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
360 && (NILP (XCONS (XCONS (def)->car)->car) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
361 || VECTORP (XCONS (XCONS (def)->car)->car))) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
362 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
363 cachelist = XCONS (def)->car; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
364 def = XCONS (def)->cdr; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
365 savedkey = XCONS (cachelist)->car; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
366 descrip = XCONS (cachelist)->cdr; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
367 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
368 |
7997
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
369 GCPRO4 (def, def1, savedkey, descrip); |
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
370 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
371 /* Is it still valid? */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
372 def1 = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
373 if (!NILP (savedkey)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
374 def1 = Fkey_binding (savedkey, Qnil); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
375 /* If not, update it. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
376 if (! EQ (def1, def) |
7832
44cfbd972edd
(menu_item_equiv_key): Check whether def1 matches
Richard M. Stallman <rms@gnu.org>
parents:
7770
diff
changeset
|
377 /* If the command is an alias for another |
44cfbd972edd
(menu_item_equiv_key): Check whether def1 matches
Richard M. Stallman <rms@gnu.org>
parents:
7770
diff
changeset
|
378 (such as easymenu.el and lmenu.el set it up), |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
379 check if the original command matches the cached command. */ |
7832
44cfbd972edd
(menu_item_equiv_key): Check whether def1 matches
Richard M. Stallman <rms@gnu.org>
parents:
7770
diff
changeset
|
380 && !(SYMBOLP (def) && SYMBOLP (XSYMBOL (def)->function) |
44cfbd972edd
(menu_item_equiv_key): Check whether def1 matches
Richard M. Stallman <rms@gnu.org>
parents:
7770
diff
changeset
|
381 && EQ (def1, XSYMBOL (def)->function)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
382 /* If something had no key binding before, don't recheck it-- |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
383 doing that takes too much time and makes menus too slow. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
384 && !(!NILP (cachelist) && NILP (savedkey))) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
385 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
386 changed = 1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
387 descrip = Qnil; |
7679
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
388 /* If the command is an alias for another |
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
389 (such as easymenu.el and lmenu.el set it up), |
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
390 see if the original command name has equivalent keys. */ |
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
391 if (SYMBOLP (def) && SYMBOLP (XSYMBOL (def)->function)) |
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
392 savedkey = Fwhere_is_internal (XSYMBOL (def)->function, |
5475c6144371
(menu_item_equiv_key): Look for equiv keys both before
Richard M. Stallman <rms@gnu.org>
parents:
7554
diff
changeset
|
393 Qnil, Qt, Qnil); |
10716
7418dce6e52a
(menu_item_equiv_key): If command is an alias,
Richard M. Stallman <rms@gnu.org>
parents:
10502
diff
changeset
|
394 else |
7418dce6e52a
(menu_item_equiv_key): If command is an alias,
Richard M. Stallman <rms@gnu.org>
parents:
10502
diff
changeset
|
395 /* Otherwise look up the specified command itself. |
7418dce6e52a
(menu_item_equiv_key): If command is an alias,
Richard M. Stallman <rms@gnu.org>
parents:
10502
diff
changeset
|
396 We don't try both, because that makes easymenu menus slow. */ |
7418dce6e52a
(menu_item_equiv_key): If command is an alias,
Richard M. Stallman <rms@gnu.org>
parents:
10502
diff
changeset
|
397 savedkey = Fwhere_is_internal (def, Qnil, Qt, Qnil); |
7418dce6e52a
(menu_item_equiv_key): If command is an alias,
Richard M. Stallman <rms@gnu.org>
parents:
10502
diff
changeset
|
398 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
399 if (!NILP (savedkey)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
400 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
401 descrip = Fkey_description (savedkey); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
402 descrip = concat2 (make_string (" (", 3), descrip); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
403 descrip = concat2 (descrip, make_string (")", 1)); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
404 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
405 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
406 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
407 /* Cache the data we just got in a sublist of the menu binding. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
408 if (NILP (cachelist)) |
8746 | 409 { |
410 CHECK_IMPURE (item1); | |
411 XCONS (item1)->cdr = Fcons (Fcons (savedkey, descrip), def); | |
412 } | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
413 else if (changed) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
414 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
415 XCONS (cachelist)->car = savedkey; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
416 XCONS (cachelist)->cdr = descrip; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
417 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
418 |
7997
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
419 UNGCPRO; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
420 *descrip_ptr = descrip; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
421 return def; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
422 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
423 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
424 /* This is used as the handler when calling internal_condition_case_1. */ |
118 | 425 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
426 static Lisp_Object |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
427 menu_item_enabled_p_1 (arg) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
428 Lisp_Object arg; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
429 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
430 return Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
431 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
432 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
433 /* Return non-nil if the command DEF is enabled when used as a menu item. |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
434 This is based on looking for a menu-enable property. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
435 If NOTREAL is set, don't bother really computing this. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
436 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
437 static Lisp_Object |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
438 menu_item_enabled_p (def, notreal) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
439 Lisp_Object def; |
8849
7e705163bde7
(menu_item_enabled_p): Fix declaration.
Karl Heuer <kwzh@gnu.org>
parents:
8746
diff
changeset
|
440 int notreal; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
441 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
442 Lisp_Object enabled, tem; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
443 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
444 enabled = Qt; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
445 if (notreal) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
446 return enabled; |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
447 if (SYMBOLP (def)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
448 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
449 /* No property, or nil, means enable. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
450 Otherwise, enable if value is not nil. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
451 tem = Fget (def, Qmenu_enable); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
452 if (!NILP (tem)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
453 /* (condition-case nil (eval tem) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
454 (error nil)) */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
455 enabled = internal_condition_case_1 (Feval, tem, Qerror, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
456 menu_item_enabled_p_1); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
457 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
458 return enabled; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
459 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
460 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
461 /* Look through KEYMAPS, a vector of keymaps that is NMAPS long, |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
462 and generate menu panes for them in menu_items. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
463 If NOTREAL is nonzero, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
464 don't bother really computing whether an item is enabled. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
465 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
466 static void |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
467 keymap_panes (keymaps, nmaps, notreal) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
468 Lisp_Object *keymaps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
469 int nmaps; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
470 int notreal; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
471 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
472 int mapno; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
473 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
474 init_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
475 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
476 /* Loop over the given keymaps, making a pane for each map. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
477 But don't make a pane that is empty--ignore that map instead. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
478 P is the number of panes we have made so far. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
479 for (mapno = 0; mapno < nmaps; mapno++) |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
480 single_keymap_panes (keymaps[mapno], Qnil, Qnil, notreal); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
481 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
482 finish_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
483 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
484 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
485 /* This is a recursive subroutine of keymap_panes. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
486 It handles one keymap, KEYMAP. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
487 The other arguments are passed along |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
488 or point to local variables of the previous function. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
489 If NOTREAL is nonzero, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
490 don't bother really computing whether an item is enabled. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
491 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
492 static void |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
493 single_keymap_panes (keymap, pane_name, prefix, notreal) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
494 Lisp_Object keymap; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
495 Lisp_Object pane_name; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
496 Lisp_Object prefix; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
497 int notreal; |
118 | 498 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
499 Lisp_Object pending_maps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
500 Lisp_Object tail, item, item1, item_string, table; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
501 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
502 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
503 pending_maps = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
504 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
505 push_menu_pane (pane_name, prefix); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
506 |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
507 for (tail = keymap; CONSP (tail); tail = XCONS (tail)->cdr) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
508 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
509 /* Look at each key binding, and if it has a menu string, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
510 make a menu item from it. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
511 item = XCONS (tail)->car; |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
512 if (CONSP (item)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
513 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
514 item1 = XCONS (item)->cdr; |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
515 if (CONSP (item1)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
516 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
517 item_string = XCONS (item1)->car; |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
518 if (STRINGP (item_string)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
519 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
520 /* This is the real definition--the function to run. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
521 Lisp_Object def; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
522 /* These are the saved equivalent keyboard key sequence |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
523 and its key-description. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
524 Lisp_Object descrip; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
525 Lisp_Object tem, enabled; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
526 |
7997
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
527 /* GCPRO because ...enabled_p will call eval |
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
528 and ..._equiv_key may autoload something. |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
529 Protecting KEYMAP preserves everything we use; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
530 aside from that, must protect whatever might be |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
531 a string. Since there's no GCPRO5, we refetch |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
532 item_string instead of protecting it. */ |
7997
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
533 descrip = def = Qnil; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
534 GCPRO4 (keymap, pending_maps, def, descrip); |
7997
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
535 |
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
536 def = menu_item_equiv_key (item_string, item1, &descrip); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
537 enabled = menu_item_enabled_p (def, notreal); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
538 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
539 UNGCPRO; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
540 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
541 item_string = XCONS (item1)->car; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
542 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
543 tem = Fkeymapp (def); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
544 if (XSTRING (item_string)->data[0] == '@' && !NILP (tem)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
545 pending_maps = Fcons (Fcons (def, Fcons (item_string, XCONS (item)->car)), |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
546 pending_maps); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
547 else |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
548 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
549 Lisp_Object submap; |
7871
11fae1619e42
(single_keymap_panes): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7854
diff
changeset
|
550 GCPRO4 (keymap, pending_maps, descrip, item_string); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
551 submap = get_keymap_1 (def, 0, 1); |
7871
11fae1619e42
(single_keymap_panes): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7854
diff
changeset
|
552 UNGCPRO; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
553 #ifndef USE_X_TOOLKIT |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
554 /* Indicate visually that this is a submenu. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
555 if (!NILP (submap)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
556 item_string = concat2 (item_string, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
557 build_string (" >")); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
558 #endif |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
559 /* If definition is nil, pass nil as the key. */ |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
560 push_menu_item (item_string, enabled, |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
561 XCONS (item)->car, def, |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
562 descrip); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
563 #ifdef USE_X_TOOLKIT |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
564 /* Display a submenu using the toolkit. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
565 if (! NILP (submap)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
566 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
567 push_submenu_start (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
568 single_keymap_panes (submap, Qnil, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
569 XCONS (item)->car, notreal); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
570 push_submenu_end (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
571 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
572 #endif |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
573 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
574 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
575 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
576 } |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
577 else if (VECTORP (item)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
578 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
579 /* Loop over the char values represented in the vector. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
580 int len = XVECTOR (item)->size; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
581 int c; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
582 for (c = 0; c < len; c++) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
583 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
584 Lisp_Object character; |
9341
e5ecfda9e730
(single_keymap_panes, Fx_popup_menu): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9339
diff
changeset
|
585 XSETFASTINT (character, c); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
586 item1 = XVECTOR (item)->contents[c]; |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
587 if (CONSP (item1)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
588 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
589 item_string = XCONS (item1)->car; |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
590 if (STRINGP (item_string)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
591 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
592 Lisp_Object def; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
593 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
594 /* These are the saved equivalent keyboard key sequence |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
595 and its key-description. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
596 Lisp_Object descrip; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
597 Lisp_Object tem, enabled; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
598 |
7997
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
599 /* GCPRO because ...enabled_p will call eval |
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
600 and ..._equiv_key may autoload something. |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
601 Protecting KEYMAP preserves everything we use; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
602 aside from that, must protect whatever might be |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
603 a string. Since there's no GCPRO5, we refetch |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
604 item_string instead of protecting it. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
605 GCPRO4 (keymap, pending_maps, def, descrip); |
7997
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
606 descrip = def = Qnil; |
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
607 |
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
608 def = menu_item_equiv_key (item_string, item1, &descrip); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
609 enabled = menu_item_enabled_p (def, notreal); |
7997
dda8e966edf5
(single_keymap_panes): Put menu_item_equiv_key in the gcpro.
Richard M. Stallman <rms@gnu.org>
parents:
7900
diff
changeset
|
610 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
611 UNGCPRO; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
612 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
613 item_string = XCONS (item1)->car; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
614 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
615 tem = Fkeymapp (def); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
616 if (XSTRING (item_string)->data[0] == '@' && !NILP (tem)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
617 pending_maps = Fcons (Fcons (def, Fcons (item_string, character)), |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
618 pending_maps); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
619 else |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
620 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
621 Lisp_Object submap; |
7871
11fae1619e42
(single_keymap_panes): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7854
diff
changeset
|
622 GCPRO4 (keymap, pending_maps, descrip, item_string); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
623 submap = get_keymap_1 (def, 0, 1); |
7871
11fae1619e42
(single_keymap_panes): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents:
7854
diff
changeset
|
624 UNGCPRO; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
625 #ifndef USE_X_TOOLKIT |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
626 if (!NILP (submap)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
627 item_string = concat2 (item_string, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
628 build_string (" >")); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
629 #endif |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
630 /* If definition is nil, pass nil as the key. */ |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
631 push_menu_item (item_string, enabled, character, |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
632 def, descrip); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
633 #ifdef USE_X_TOOLKIT |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
634 if (! NILP (submap)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
635 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
636 push_submenu_start (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
637 single_keymap_panes (submap, Qnil, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
638 character, notreal); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
639 push_submenu_end (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
640 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
641 #endif |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
642 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
643 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
644 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
645 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
646 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
647 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
648 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
649 /* Process now any submenus which want to be panes at this level. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
650 while (!NILP (pending_maps)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
651 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
652 Lisp_Object elt, eltcdr, string; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
653 elt = Fcar (pending_maps); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
654 eltcdr = XCONS (elt)->cdr; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
655 string = XCONS (eltcdr)->car; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
656 /* We no longer discard the @ from the beginning of the string here. |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
657 Instead, we do this in xmenu_show. */ |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
658 single_keymap_panes (Fcar (elt), string, |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
659 XCONS (eltcdr)->cdr, notreal); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
660 pending_maps = Fcdr (pending_maps); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
661 } |
118 | 662 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
663 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
664 /* Push all the panes and items of a menu decsribed by the |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
665 alist-of-alists MENU. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
666 This handles old-fashioned calls to x-popup-menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
667 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
668 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
669 list_of_panes (menu) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
670 Lisp_Object menu; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
671 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
672 Lisp_Object tail; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
673 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
674 init_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
675 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
676 for (tail = menu; !NILP (tail); tail = Fcdr (tail)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
677 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
678 Lisp_Object elt, pane_name, pane_data; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
679 elt = Fcar (tail); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
680 pane_name = Fcar (elt); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
681 CHECK_STRING (pane_name, 0); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
682 push_menu_pane (pane_name, Qnil); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
683 pane_data = Fcdr (elt); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
684 CHECK_CONS (pane_data, 0); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
685 list_of_items (pane_data); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
686 } |
118 | 687 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
688 finish_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
689 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
690 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
691 /* Push the items in a single pane defined by the alist PANE. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
692 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
693 static void |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
694 list_of_items (pane) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
695 Lisp_Object pane; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
696 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
697 Lisp_Object tail, item, item1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
698 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
699 for (tail = pane; !NILP (tail); tail = Fcdr (tail)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
700 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
701 item = Fcar (tail); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
702 if (STRINGP (item)) |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
703 push_menu_item (item, Qnil, Qnil, Qt, Qnil); |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
704 else if (NILP (item)) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
705 push_left_right_boundary (); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
706 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
707 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
708 CHECK_CONS (item, 0); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
709 item1 = Fcar (item); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
710 CHECK_STRING (item1, 1); |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
711 push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
712 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
713 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
714 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
715 |
6424
b3d22929b7c1
(Fx_popup_dialog, Fx_popup_menu): Require 2 args.
Richard M. Stallman <rms@gnu.org>
parents:
6406
diff
changeset
|
716 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, |
118 | 717 "Pop up a deck-of-cards menu and return user's selection.\n\ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
718 POSITION is a position specification. This is either a mouse button event\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
719 or a list ((XOFFSET YOFFSET) WINDOW)\n\ |
7175
5fa65268508b
(Fx_popup_menu): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7129
diff
changeset
|
720 where XOFFSET and YOFFSET are positions in pixels from the top left\n\ |
2147
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
721 corner of WINDOW's frame. (WINDOW may be a frame object instead of a window.)\n\ |
118 | 722 This controls the position of the center of the first line\n\ |
723 in the first pane of the menu, not the top left of the menu as a whole.\n\ | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
724 If POSITION is t, it means to use the current mouse position.\n\ |
118 | 725 \n\ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
726 MENU is a specifier for a menu. For the simplest case, MENU is a keymap.\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
727 The menu items come from key bindings that have a menu string as well as\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
728 a definition; actually, the \"definition\" in such a key binding looks like\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
729 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
730 the keymap as a top-level element.\n\n\ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
731 You can also use a list of keymaps as MENU.\n\ |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
732 Then each keymap makes a separate pane.\n\ |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
733 When MENU is a keymap or a list of keymaps, the return value\n\ |
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
734 is a list of events.\n\n\ |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
735 Alternatively, you can specify a menu of multiple panes\n\ |
2191
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
736 with a list of the form (TITLE PANE1 PANE2...),\n\ |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
737 where each pane is a list of form (TITLE ITEM1 ITEM2...).\n\ |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
738 Each ITEM is normally a cons cell (STRING . VALUE);\n\ |
12480fa04422
(list_of_items): Allow strings among the alist items;
Richard M. Stallman <rms@gnu.org>
parents:
2160
diff
changeset
|
739 but a string can appear as an item--that makes a nonselectable line\n\ |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
740 in the menu.\n\ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
741 With this form of menu, the return value is VALUE from the chosen item.\n\ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
742 \n\ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
743 If POSITION is nil, don't display the menu at all, just precalculate the\n\ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
744 cached information about equivalent key sequences.") |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
745 (position, menu) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
746 Lisp_Object position, menu; |
118 | 747 { |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
748 int number_of_panes, panes; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
749 Lisp_Object keymap, tem; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
750 int xpos, ypos; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
751 Lisp_Object title; |
118 | 752 char *error_name; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
753 Lisp_Object selection; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
754 int i, j; |
770 | 755 FRAME_PTR f; |
118 | 756 Lisp_Object x, y, window; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
757 int keymaps = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
758 int menubarp = 0; |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
759 int for_click = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
760 struct gcpro gcpro1; |
118 | 761 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
762 if (! NILP (position)) |
2147
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
763 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
764 check_x (); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
765 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
766 /* Decode the first argument: find the window and the coordinates. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
767 if (EQ (position, Qt)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
768 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
769 /* Use the mouse's current position. */ |
10835
cd9261d8d347
(Fx_popup_menu): Init f from selected_frame
Richard M. Stallman <rms@gnu.org>
parents:
10809
diff
changeset
|
770 FRAME_PTR new_f = selected_frame; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
771 Lisp_Object bar_window; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
772 int part; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
773 unsigned long time; |
2147
1b6e54507323
(Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents:
2135
diff
changeset
|
774 |
7334
fcea4173315d
(Fx_popup_menu): Restore accidentally-deleted call to mouse_position_hook.
Karl Heuer <kwzh@gnu.org>
parents:
7208
diff
changeset
|
775 if (mouse_position_hook) |
11125
dc78213dd2b3
(Fx_popup_menu): Pass 1 for `insist' arg.
Richard M. Stallman <rms@gnu.org>
parents:
10835
diff
changeset
|
776 (*mouse_position_hook) (&new_f, 1, &bar_window, |
dc78213dd2b3
(Fx_popup_menu): Pass 1 for `insist' arg.
Richard M. Stallman <rms@gnu.org>
parents:
10835
diff
changeset
|
777 &part, &x, &y, &time); |
6395
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
778 if (new_f != 0) |
9339
8a59acc95eea
(Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents:
9336
diff
changeset
|
779 XSETFRAME (window, new_f); |
6395
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
780 else |
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
781 { |
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
782 window = selected_window; |
9341
e5ecfda9e730
(single_keymap_panes, Fx_popup_menu): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9339
diff
changeset
|
783 XSETFASTINT (x, 0); |
e5ecfda9e730
(single_keymap_panes, Fx_popup_menu): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9339
diff
changeset
|
784 XSETFASTINT (y, 0); |
6395
6240067bfe33
(Fx_popup_dialog, Fx_popup_menu): Handle case where
Richard M. Stallman <rms@gnu.org>
parents:
6325
diff
changeset
|
785 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
786 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
787 else |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
788 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
789 tem = Fcar (position); |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
790 if (CONSP (tem)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
791 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
792 window = Fcar (Fcdr (position)); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
793 x = Fcar (tem); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
794 y = Fcar (Fcdr (tem)); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
795 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
796 else |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
797 { |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
798 for_click = 1; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
799 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
800 window = Fcar (tem); /* POSN_WINDOW (tem) */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
801 tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
802 x = Fcar (tem); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
803 y = Fcdr (tem); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
804 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
805 /* Determine whether this menu is handling a menu bar click. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
806 tem = Fcar (Fcdr (Fcar (Fcdr (position)))); |
7459
1a6156c8731e
(xmenu_show): New var mb_item. Use it to determine the menubar item that
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
7458
diff
changeset
|
807 if (CONSP (tem) && EQ (Fcar (tem), Qmenu_bar)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
808 menubarp = 1; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
809 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
810 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
811 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
812 CHECK_NUMBER (x, 0); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
813 CHECK_NUMBER (y, 0); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
814 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
815 /* Decode where to put the menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
816 |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
817 if (FRAMEP (window)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
818 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
819 f = XFRAME (window); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
820 xpos = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
821 ypos = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
822 } |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
823 else if (WINDOWP (window)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
824 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
825 CHECK_LIVE_WINDOW (window, 0); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
826 f = XFRAME (WINDOW_FRAME (XWINDOW (window))); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
827 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
828 xpos = (FONT_WIDTH (f->display.x->font) * XWINDOW (window)->left); |
6764
52b64d326287
(Fx_popup_menu): Use line_height field.
Richard M. Stallman <rms@gnu.org>
parents:
6746
diff
changeset
|
829 ypos = (f->display.x->line_height * XWINDOW (window)->top); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
830 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
831 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
832 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
833 but I don't want to make one now. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
834 CHECK_WINDOW (window, 0); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
835 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
836 xpos += XINT (x); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
837 ypos += XINT (y); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
838 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
839 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
840 title = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
841 GCPRO1 (title); |
4627
340c18d50337
(Fx_popup_menu): Adjust coords so they are relative to the inner window.
Richard M. Stallman <rms@gnu.org>
parents:
3747
diff
changeset
|
842 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
843 /* Decode the menu items from what was specified. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
844 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
845 keymap = Fkeymapp (menu); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
846 tem = Qnil; |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
847 if (CONSP (menu)) |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
848 tem = Fkeymapp (Fcar (menu)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
849 if (!NILP (keymap)) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
850 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
851 /* We were given a keymap. Extract menu info from the keymap. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
852 Lisp_Object prompt; |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
853 keymap = get_keymap (menu); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
854 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
855 /* Extract the detailed info to make one pane. */ |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
856 keymap_panes (&menu, 1, NILP (position)); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
857 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
858 /* Search for a string appearing directly as an element of the keymap. |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
859 That string is the title of the menu. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
860 prompt = map_prompt (keymap); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
861 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
862 /* Make that be the pane title of the first pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
863 if (!NILP (prompt) && menu_items_n_panes >= 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
864 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = prompt; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
865 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
866 keymaps = 1; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
867 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
868 else if (!NILP (tem)) |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
869 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
870 /* We were given a list of keymaps. */ |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
871 int nmaps = XFASTINT (Flength (menu)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
872 Lisp_Object *maps |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
873 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
874 int i; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
875 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
876 title = Qnil; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
877 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
878 /* The first keymap that has a prompt string |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
879 supplies the menu title. */ |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
880 for (tem = menu, i = 0; CONSP (tem); tem = Fcdr (tem)) |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
881 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
882 Lisp_Object prompt; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
883 |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
884 maps[i++] = keymap = get_keymap (Fcar (tem)); |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
885 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
886 prompt = map_prompt (keymap); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
887 if (NILP (title) && !NILP (prompt)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
888 title = prompt; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
889 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
890 |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
891 /* Extract the detailed info to make one pane. */ |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
892 keymap_panes (maps, nmaps, NILP (position)); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
893 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
894 /* Make the title be the pane title of the first pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
895 if (!NILP (title) && menu_items_n_panes >= 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
896 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = title; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
897 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
898 keymaps = 1; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
899 } |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
900 else |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
901 { |
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
902 /* We were given an old-fashioned menu. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
903 title = Fcar (menu); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
904 CHECK_STRING (title, 1); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
905 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
906 list_of_panes (Fcdr (menu)); |
1828
1463592a6463
* xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
907 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
908 keymaps = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
909 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
910 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
911 if (NILP (position)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
912 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
913 discard_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
914 UNGCPRO; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
915 return Qnil; |
118 | 916 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
917 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
918 /* Display them in a menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
919 BLOCK_INPUT; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
920 |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
921 selection = xmenu_show (f, xpos, ypos, menubarp, for_click, |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
922 keymaps, title, &error_name); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
923 UNBLOCK_INPUT; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
924 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
925 discard_menu_items (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
926 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
927 UNGCPRO; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
928 |
118 | 929 if (error_name) error (error_name); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
930 return selection; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
931 } |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
932 |
6424
b3d22929b7c1
(Fx_popup_dialog, Fx_popup_menu): Require 2 args.
Richard M. Stallman <rms@gnu.org>
parents:
6406
diff
changeset
|
933 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 2, 0, |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
934 "Pop up a dialog box and return user's selection.\n\ |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
935 POSITION specifies which frame to use.\n\ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
936 This is normally a mouse button event or a window or frame.\n\ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
937 If POSITION is t, it means to use the frame the mouse is on.\n\ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
938 The dialog box appears in the middle of the specified frame.\n\ |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
939 \n\ |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
940 CONTENTS specifies the alternatives to display in the dialog box.\n\ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
941 It is a list of the form (TITLE ITEM1 ITEM2...).\n\ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
942 Each ITEM is a cons cell (STRING . VALUE).\n\ |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
943 The return value is VALUE from the chosen item.\n\n\ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
944 An ITEM may also be just a string--that makes a nonselectable item.\n\ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
945 An ITEM may also be nil--that means to put all preceding items\n\ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
946 on the left of the dialog box and all following items on the right.\n\ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
947 \(By default, approximately half appear on each side.)") |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
948 (position, contents) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
949 Lisp_Object position, contents; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
950 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
951 FRAME_PTR f; |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
952 Lisp_Object window; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
953 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
954 check_x (); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
955 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
956 /* Decode the first argument: find the window or frame to use. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
957 if (EQ (position, Qt)) |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
958 { |
6653
14a0a3fe93fd
(Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents:
6625
diff
changeset
|
959 #if 0 /* Using the frame the mouse is on may not be right. */ |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
960 /* Use the mouse's current position. */ |
10835
cd9261d8d347
(Fx_popup_menu): Init f from selected_frame
Richard M. Stallman <rms@gnu.org>
parents:
10809
diff
changeset
|
961 FRAME_PTR new_f = selected_frame; |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
962 Lisp_Object bar_window; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
963 int part; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
964 unsigned long time; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
965 Lisp_Object x, y; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
966 |
11125
dc78213dd2b3
(Fx_popup_menu): Pass 1 for `insist' arg.
Richard M. Stallman <rms@gnu.org>
parents:
10835
diff
changeset
|
967 (*mouse_position_hook) (&new_f, 1, &bar_window, &part, &x, &y, &time); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
968 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
969 if (new_f != 0) |
9339
8a59acc95eea
(Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents:
9336
diff
changeset
|
970 XSETFRAME (window, new_f); |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
971 else |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
972 window = selected_window; |
6653
14a0a3fe93fd
(Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents:
6625
diff
changeset
|
973 #endif |
14a0a3fe93fd
(Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents:
6625
diff
changeset
|
974 /* Decode the first argument: find the window and the coordinates. */ |
14a0a3fe93fd
(Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents:
6625
diff
changeset
|
975 if (EQ (position, Qt)) |
6656
19bcf36f315e
(Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents:
6653
diff
changeset
|
976 window = selected_window; |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
977 } |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
978 else if (CONSP (position)) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
979 { |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
980 Lisp_Object tem; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
981 tem = Fcar (position); |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
982 if (CONSP (tem)) |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
983 window = Fcar (Fcdr (position)); |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
984 else |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
985 { |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
986 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
987 window = Fcar (tem); /* POSN_WINDOW (tem) */ |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
988 } |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
989 } |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
990 else if (WINDOWP (position) || FRAMEP (position)) |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
991 window = position; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
992 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
993 /* Decode where to put the menu. */ |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
994 |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
995 if (FRAMEP (window)) |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
996 f = XFRAME (window); |
9102
7a73653817de
(menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents:
8849
diff
changeset
|
997 else if (WINDOWP (window)) |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
998 { |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
999 CHECK_LIVE_WINDOW (window, 0); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1000 f = XFRAME (WINDOW_FRAME (XWINDOW (window))); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1001 } |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1002 else |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1003 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME, |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1004 but I don't want to make one now. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1005 CHECK_WINDOW (window, 0); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1006 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1007 #ifndef USE_X_TOOLKIT |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1008 /* Display a menu with these alternatives |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1009 in the middle of frame F. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1010 { |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1011 Lisp_Object x, y, frame, newpos; |
9339
8a59acc95eea
(Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents:
9336
diff
changeset
|
1012 XSETFRAME (frame, f); |
8a59acc95eea
(Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents:
9336
diff
changeset
|
1013 XSETINT (x, x_pixel_width (f) / 2); |
8a59acc95eea
(Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents:
9336
diff
changeset
|
1014 XSETINT (y, x_pixel_height (f) / 2); |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1015 newpos = Fcons (Fcons (x, Fcons (y, Qnil)), Fcons (frame, Qnil)); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1016 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1017 return Fx_popup_menu (newpos, |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1018 Fcons (Fcar (contents), Fcons (contents, Qnil))); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1019 } |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1020 #else |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1021 { |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1022 Lisp_Object title; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1023 char *error_name; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1024 Lisp_Object selection; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1025 |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1026 /* Decode the dialog items from what was specified. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1027 title = Fcar (contents); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1028 CHECK_STRING (title, 1); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1029 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1030 list_of_panes (Fcons (contents, Qnil)); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1031 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1032 /* Display them in a dialog box. */ |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1033 BLOCK_INPUT; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1034 selection = xdialog_show (f, 0, 0, title, &error_name); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1035 UNBLOCK_INPUT; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1036 |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1037 discard_menu_items (); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1038 |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1039 if (error_name) error (error_name); |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1040 return selection; |
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1041 } |
6325
d6817c9c0413
Undo previous change. Instead:
Richard M. Stallman <rms@gnu.org>
parents:
6324
diff
changeset
|
1042 #endif |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1043 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1044 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1045 #ifdef USE_X_TOOLKIT |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1046 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1047 /* Loop in Xt until the menu pulldown or dialog popup has been |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1048 popped down (deactivated). |
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1049 |
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1050 NOTE: All calls to popup_get_selection() should be protected |
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1051 with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1052 void |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1053 popup_get_selection (initial_event) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1054 XEvent *initial_event; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1055 { |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1056 XEvent event; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1057 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1058 if (initial_event) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1059 event = *initial_event; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1060 else |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1061 XtAppNextEvent (Xt_app_con, &event); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1062 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1063 while (1) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1064 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1065 XtDispatchEvent (&event); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1066 if (!popup_activated()) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1067 break; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1068 XtAppNextEvent (Xt_app_con, &event); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1069 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1070 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1071 |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1072 /* Detect if a dialog or menu has been posted. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1073 int |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1074 popup_activated () |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1075 { |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1076 return popup_activated_flag; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1077 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1078 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1079 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1080 /* This callback is invoked when the user selects a menubar cascade |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1081 pushbutton, but before the pulldown menu is posted. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1082 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1083 static void |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1084 popup_activate_callback (widget, id, client_data) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1085 Widget widget; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1086 LWLIB_ID id; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1087 XtPointer client_data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1088 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1089 popup_activated_flag = 1; |
118 | 1090 } |
1091 | |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1092 /* This callback is called from the menu bar pulldown menu |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1093 when the user makes a selection. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1094 Figure out what the user chose |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1095 and put the appropriate events into the keyboard buffer. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1096 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1097 static void |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1098 menubar_selection_callback (widget, id, client_data) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1099 Widget widget; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1100 LWLIB_ID id; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1101 XtPointer client_data; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1102 { |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1103 Lisp_Object prefix; |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
1104 FRAME_PTR f = XFRAME (XVECTOR (frame_vector)->contents[id]); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1105 Lisp_Object vector; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1106 Lisp_Object *subprefix_stack; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1107 int submenu_depth = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1108 int i; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1109 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1110 if (!f) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1111 return; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1112 subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object)); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1113 vector = f->menu_bar_vector; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1114 prefix = Qnil; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1115 i = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1116 while (i < f->menu_bar_items_used) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1117 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1118 Lisp_Object entry; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1119 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1120 if (EQ (XVECTOR (vector)->contents[i], Qnil)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1121 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1122 subprefix_stack[submenu_depth++] = prefix; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1123 prefix = entry; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1124 i++; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1125 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1126 else if (EQ (XVECTOR (vector)->contents[i], Qlambda)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1127 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1128 prefix = subprefix_stack[--submenu_depth]; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1129 i++; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1130 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1131 else if (EQ (XVECTOR (vector)->contents[i], Qt)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1132 { |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1133 prefix = XVECTOR (vector)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1134 i += MENU_ITEMS_PANE_LENGTH; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1135 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1136 else |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1137 { |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1138 entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
11266
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1139 /* The EMACS_INT cast avoids a warning. There's no problem |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1140 as long as pointers have enough bits to hold small integers. */ |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1141 if ((int) (EMACS_INT) client_data == i) |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1142 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1143 int j; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1144 struct input_event buf; |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1145 Lisp_Object frame; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1146 |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1147 XSETFRAME (frame, f); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1148 buf.kind = menu_bar_event; |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1149 buf.frame_or_window = Fcons (frame, Qmenu_bar); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1150 kbd_buffer_store_event (&buf); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1151 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1152 for (j = 0; j < submenu_depth; j++) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1153 if (!NILP (subprefix_stack[j])) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1154 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1155 buf.kind = menu_bar_event; |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1156 buf.frame_or_window = Fcons (frame, subprefix_stack[j]); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1157 kbd_buffer_store_event (&buf); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1158 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1159 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1160 if (!NILP (prefix)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1161 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1162 buf.kind = menu_bar_event; |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1163 buf.frame_or_window = Fcons (frame, prefix); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1164 kbd_buffer_store_event (&buf); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1165 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1166 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1167 buf.kind = menu_bar_event; |
10799
1745fca9370a
(menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents:
10757
diff
changeset
|
1168 buf.frame_or_window = Fcons (frame, entry); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1169 kbd_buffer_store_event (&buf); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1170 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1171 return; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1172 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1173 i += MENU_ITEMS_ITEM_LENGTH; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1174 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1175 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1176 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1177 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1178 /* This callback is invoked when a dialog or menu is finished being |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1179 used and has been unposted. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1180 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1181 static void |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1182 popup_deactivate_callback (widget, id, client_data) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1183 Widget widget; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1184 LWLIB_ID id; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1185 XtPointer client_data; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1186 { |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1187 popup_activated_flag = 0; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1188 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1189 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1190 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1191 /* This recursively calls free_widget_value on the tree of widgets. |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1192 It must free all data that was malloc'ed for these widget_values. |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1193 In Emacs, many slots are pointers into the data of Lisp_Strings, and |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1194 must be left alone. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1195 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1196 void |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1197 free_menubar_widget_value_tree (wv) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1198 widget_value *wv; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1199 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1200 if (! wv) return; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1201 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1202 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1203 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1204 if (wv->contents && (wv->contents != (widget_value*)1)) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1205 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1206 free_menubar_widget_value_tree (wv->contents); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1207 wv->contents = (widget_value *) 0xDEADBEEF; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1208 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1209 if (wv->next) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1210 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1211 free_menubar_widget_value_tree (wv->next); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1212 wv->next = (widget_value *) 0xDEADBEEF; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1213 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1214 BLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1215 free_widget_value (wv); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1216 UNBLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1217 } |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1218 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1219 /* Return a tree of widget_value structures for a menu bar item |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1220 whose event type is ITEM_KEY (with string ITEM_NAME) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1221 and whose contents come from the list of keymaps MAPS. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1222 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1223 static widget_value * |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1224 single_submenu (item_key, item_name, maps) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1225 Lisp_Object item_key, item_name, maps; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1226 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1227 widget_value *wv, *prev_wv, *save_wv, *first_wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1228 int i; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1229 int submenu_depth = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1230 Lisp_Object length; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1231 int len; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1232 Lisp_Object *mapvec; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1233 widget_value **submenu_stack; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1234 int mapno; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1235 int previous_items = menu_items_used; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1236 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1237 length = Flength (maps); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1238 len = XINT (length); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1239 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1240 /* Convert the list MAPS into a vector MAPVEC. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1241 mapvec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1242 for (i = 0; i < len; i++) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1243 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1244 mapvec[i] = Fcar (maps); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1245 maps = Fcdr (maps); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1246 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1247 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1248 menu_items_n_panes = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1249 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1250 /* Loop over the given keymaps, making a pane for each map. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1251 But don't make a pane that is empty--ignore that map instead. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1252 for (i = 0; i < len; i++) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1253 single_keymap_panes (mapvec[i], item_name, item_key, 0); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1254 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1255 /* Create a tree of widget_value objects |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1256 representing the panes and their items. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1257 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1258 submenu_stack |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1259 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1260 wv = malloc_widget_value (); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1261 wv->name = "menu"; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1262 wv->value = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1263 wv->enabled = 1; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1264 first_wv = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1265 save_wv = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1266 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1267 /* Loop over all panes and items made during this call |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1268 and construct a tree of widget_value objects. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1269 Ignore the panes and items made by previous calls to |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1270 single_submenu, even though those are also in menu_items. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1271 i = previous_items; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1272 while (i < menu_items_used) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1273 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1274 if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1275 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1276 submenu_stack[submenu_depth++] = save_wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1277 save_wv = prev_wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1278 prev_wv = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1279 i++; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1280 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1281 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1282 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1283 prev_wv = save_wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1284 save_wv = submenu_stack[--submenu_depth]; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1285 i++; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1286 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1287 else if (EQ (XVECTOR (menu_items)->contents[i], Qt) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1288 && submenu_depth != 0) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1289 i += MENU_ITEMS_PANE_LENGTH; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1290 /* Ignore a nil in the item list. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1291 It's meaningful only for dialog boxes. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1292 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1293 i += 1; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1294 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1295 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1296 /* Create a new pane. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1297 Lisp_Object pane_name, prefix; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1298 char *pane_string; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1299 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1300 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1301 pane_string = (NILP (pane_name) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1302 ? "" : (char *) XSTRING (pane_name)->data); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1303 /* If there is just one top-level pane, put all its items directly |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1304 under the top-level menu. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1305 if (menu_items_n_panes == 1) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1306 pane_string = ""; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1307 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1308 /* If the pane has a meaningful name, |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1309 make the pane a top-level menu item |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1310 with its items as a submenu beneath it. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1311 if (strcmp (pane_string, "")) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1312 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1313 wv = malloc_widget_value (); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1314 if (save_wv) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1315 save_wv->next = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1316 else |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1317 first_wv->contents = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1318 wv->name = pane_string; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1319 if (!NILP (prefix)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1320 wv->name++; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1321 wv->value = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1322 wv->enabled = 1; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1323 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1324 save_wv = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1325 prev_wv = 0; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1326 i += MENU_ITEMS_PANE_LENGTH; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1327 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1328 else |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1329 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1330 /* Create a new item within current pane. */ |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
1331 Lisp_Object item_name, enable, descrip, def; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1332 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1333 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1334 descrip |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1335 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
1336 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION]; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1337 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1338 wv = malloc_widget_value (); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1339 if (prev_wv) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1340 prev_wv->next = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1341 else |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1342 save_wv->contents = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1343 wv->name = (char *) XSTRING (item_name)->data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1344 if (!NILP (descrip)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1345 wv->key = (char *) XSTRING (descrip)->data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1346 wv->value = 0; |
11266
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1347 /* The EMACS_INT cast avoids a warning. There's no problem |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1348 as long as pointers have enough bits to hold small integers. */ |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1349 wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1350 wv->enabled = !NILP (enable); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1351 prev_wv = wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1352 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1353 i += MENU_ITEMS_ITEM_LENGTH; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1354 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1355 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1356 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1357 return first_wv; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1358 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1359 |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1360 extern void EmacsFrameSetCharSize (); |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1361 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1362 /* Recompute the menu bar of frame F. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1363 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1364 static void |
6481
55236c5bca7c
(update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6439
diff
changeset
|
1365 update_frame_menubar (f) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1366 FRAME_PTR f; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1367 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1368 struct x_display *x = f->display.x; |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1369 int columns, rows; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1370 int menubar_changed; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1371 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1372 Dimension shell_height; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1373 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1374 /* We assume the menubar contents has changed if the global flag is set, |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1375 or if the current buffer has changed, or if the menubar has never |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1376 been updated before. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1377 */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1378 menubar_changed = (x->menubar_widget |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1379 && !XtIsManaged (x->menubar_widget)); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1380 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1381 if (! (menubar_changed)) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1382 return; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1383 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1384 BLOCK_INPUT; |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1385 /* Save the size of the frame because the pane widget doesn't accept to |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1386 resize itself. So force it. */ |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1387 columns = f->width; |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1388 rows = f->height; |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1389 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1390 /* Do the voodoo which means "I'm changing lots of things, don't try to |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1391 refigure sizes until I'm done." */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1392 lw_refigure_widget (x->column_widget, False); |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1393 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1394 /* the order in which children are managed is the top to |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1395 bottom order in which they are displayed in the paned window. |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1396 First, remove the text-area widget. |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1397 */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1398 XtUnmanageChild (x->edit_widget); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1399 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1400 /* remove the menubar that is there now, and put up the menubar that |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1401 should be there. |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1402 */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1403 if (menubar_changed) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1404 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1405 XtManageChild (x->menubar_widget); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1406 XtMapWidget (x->menubar_widget); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1407 XtVaSetValues (x->menubar_widget, XtNmappedWhenManaged, 1, 0); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1408 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1409 |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1410 /* Re-manage the text-area widget, and then thrash the sizes. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1411 XtManageChild (x->edit_widget); |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1412 lw_refigure_widget (x->column_widget, True); |
6200
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1413 |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1414 /* Force the pane widget to resize itself with the right values. */ |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1415 EmacsFrameSetCharSize (x->edit_widget, columns, rows); |
01c57ae8ca57
(update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6198
diff
changeset
|
1416 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1417 UNBLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1418 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1419 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1420 void |
6605
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1421 set_frame_menubar (f, first_time) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1422 FRAME_PTR f; |
6605
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1423 int first_time; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1424 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1425 Widget menubar_widget = f->display.x->menubar_widget; |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
1426 Lisp_Object tail, items, frame; |
9725
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1427 widget_value *wv, *first_wv, *prev_wv = 0; |
6172
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1428 int i; |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
1429 int id; |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
1430 |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
1431 id = frame_vector_add_frame (f); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1432 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1433 BLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1434 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1435 wv = malloc_widget_value (); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1436 wv->name = "menubar"; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1437 wv->value = 0; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1438 wv->enabled = 1; |
9725
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1439 first_wv = wv; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1440 items = FRAME_MENU_BAR_ITEMS (f); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1441 menu_items = f->menu_bar_vector; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1442 menu_items_allocated = XVECTOR (menu_items)->size; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1443 init_menu_items (); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1444 |
6172
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1445 for (i = 0; i < XVECTOR (items)->size; i += 3) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1446 { |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1447 Lisp_Object key, string, maps; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1448 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1449 key = XVECTOR (items)->contents[i]; |
6172
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1450 string = XVECTOR (items)->contents[i + 1]; |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1451 maps = XVECTOR (items)->contents[i + 2]; |
6172
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1452 if (NILP (string)) |
57d031171fa2
(map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents:
6115
diff
changeset
|
1453 break; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1454 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1455 wv = single_submenu (key, string, maps); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1456 if (prev_wv) |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1457 prev_wv->next = wv; |
9725
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1458 else |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1459 first_wv->contents = wv; |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1460 /* Don't set wv->name here; GC during the loop might relocate it. */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1461 wv->enabled = 1; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1462 prev_wv = wv; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1463 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1464 |
9725
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1465 /* Now GC cannot happen during the lifetime of the widget_value, |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1466 so it's safe to store data from a Lisp_String. */ |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1467 wv = first_wv->contents; |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1468 for (i = 0; i < XVECTOR (items)->size; i += 3) |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1469 { |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1470 Lisp_Object string; |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1471 string = XVECTOR (items)->contents[i + 1]; |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1472 if (NILP (string)) |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1473 break; |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1474 wv->name = (char *) XSTRING (string)->data; |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1475 wv = wv->next; |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1476 } |
98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents:
9649
diff
changeset
|
1477 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1478 finish_menu_items (); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1479 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1480 f->menu_bar_vector = menu_items; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1481 f->menu_bar_items_used = menu_items_used; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1482 menu_items = Qnil; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1483 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1484 if (menubar_widget) |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1485 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1486 /* Disable resizing (done for Motif!) */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1487 lw_allow_resizing (f->display.x->widget, False); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1488 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1489 /* The third arg is DEEP_P, which says to consider the entire |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1490 menu trees we supply, rather than just the menu bar item names. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1491 lw_modify_all_widgets (id, first_wv, 1); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1492 |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1493 /* Re-enable the edit widget to resize. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1494 lw_allow_resizing (f->display.x->widget, True); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1495 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1496 else |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1497 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1498 menubar_widget = lw_create_widget ("menubar", "menubar", |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1499 id, first_wv, |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1500 f->display.x->column_widget, |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1501 0, |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1502 popup_activate_callback, |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1503 menubar_selection_callback, |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1504 popup_deactivate_callback); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1505 f->display.x->menubar_widget = menubar_widget; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1506 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1507 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1508 free_menubar_widget_value_tree (first_wv); |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1509 |
6605
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1510 /* Don't update the menubar the first time it is created via x_window. */ |
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1511 if (!first_time) |
f5b781f33789
(set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6526
diff
changeset
|
1512 update_frame_menubar (f); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1513 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1514 UNBLOCK_INPUT; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1515 } |
5897
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1516 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1517 /* Called from Fx_create_frame to create the inital menubar of a frame |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1518 before it is mapped, so that the window is mapped with the menubar already |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1519 there instead of us tacking it on later and thrashing the window after it |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1520 is visible. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1521 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1522 void |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1523 initialize_frame_menubar (f) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1524 FRAME_PTR f; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1525 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1526 /* This function is called before the first chance to redisplay |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1527 the frame. It has to be, so the frame will have the right size. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1528 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1529 set_frame_menubar (f, 1); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1530 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1531 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1532 /* Get rid of the menu bar of frame F, and free its storage. |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1533 This is used when deleting a frame, and when turning off the menu bar. */ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1534 |
5897
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1535 void |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1536 free_frame_menubar (f) |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1537 FRAME_PTR f; |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1538 { |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1539 Widget menubar_widget; |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1540 int id; |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1541 |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1542 menubar_widget = f->display.x->menubar_widget; |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1543 |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1544 if (menubar_widget) |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1545 { |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
1546 id = frame_vector_add_frame (f); |
5897
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1547 BLOCK_INPUT; |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1548 lw_destroy_all_widgets (id); |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
1549 XVECTOR (frame_vector)->contents[id] = Qnil; |
5897
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1550 UNBLOCK_INPUT; |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1551 } |
5a68abc8f1f9
(free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5896
diff
changeset
|
1552 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1553 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1554 #endif /* USE_X_TOOLKIT */ |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1555 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1556 /* xmenu_show actually displays a menu using the panes and items in menu_items |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1557 and returns the value selected from it. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1558 There are two versions of xmenu_show, one for Xt and one for Xlib. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1559 Both assume input is blocked by the caller. */ |
118 | 1560 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1561 /* F is the frame the menu is for. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1562 X and Y are the frame-relative specified position, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1563 relative to the inside upper left corner of the frame F. |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
1564 MENUBARP is 1 if this menu came from the menu bar. |
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
1565 FOR_CLICK if this menu was invoked for a mouse click. |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1566 KEYMAPS is 1 if this menu was specified with keymaps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1567 in that case, we return a list containing the chosen item's value |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1568 and perhaps also the pane's prefix. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1569 TITLE is the specified menu title. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1570 ERROR is a place to store an error message string in case of failure. |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1571 (We return nil on failure, but the value doesn't actually matter.) */ |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1572 |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1573 #ifdef USE_X_TOOLKIT |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1574 |
9336
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
1575 /* We need a unique id for each widget handled by the Lucid Widget |
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
1576 library. This includes the frame main windows, popup menu and |
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
1577 dialog box. */ |
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
1578 LWLIB_ID widget_id_tick; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1579 |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1580 #ifdef __STDC__ |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1581 static Lisp_Object *volatile menu_item_selection; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1582 #else |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1583 static Lisp_Object *menu_item_selection; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1584 #endif |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1585 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1586 static void |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1587 popup_selection_callback (widget, id, client_data) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1588 Widget widget; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1589 LWLIB_ID id; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1590 XtPointer client_data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1591 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1592 menu_item_selection = (Lisp_Object *) client_data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1593 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1594 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1595 static Lisp_Object |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
1596 xmenu_show (f, x, y, menubarp, for_click, keymaps, title, error) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1597 FRAME_PTR f; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1598 int x; |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1599 int y; |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
1600 int menubarp; /* This arg is unused in Xt version. */ |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
1601 int for_click; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1602 int keymaps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1603 Lisp_Object title; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1604 char **error; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1605 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1606 int i; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1607 int menu_id; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1608 Widget menu; |
8414
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
1609 Arg av [2]; |
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
1610 int ac = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1611 widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1612 widget_value **submenu_stack |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1613 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1614 Lisp_Object *subprefix_stack |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1615 = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object)); |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1616 int submenu_depth = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1617 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1618 /* Define a queue to save up for later unreading |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1619 all X events that don't pertain to the menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1620 struct event_queue |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1621 { |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1622 XEvent event; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1623 struct event_queue *next; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1624 }; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1625 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1626 struct event_queue *queue = NULL; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1627 struct event_queue *queue_tmp; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1628 |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1629 Position root_x, root_y; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1630 |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1631 int first_pane; |
8175
c3bc5fca374f
(xmenu_show) {USE_X_TOOLKIT}: ButtonPress no longer pops
Richard M. Stallman <rms@gnu.org>
parents:
8166
diff
changeset
|
1632 int next_release_must_exit = 0; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1633 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1634 *error = NULL; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1635 |
7335
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1636 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1637 { |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1638 *error = "Empty menu"; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1639 return Qnil; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
1640 } |
5896
b20145eafe0c
(xmenu_show) [USE_X_TOOLKIT]: return Qnil when val is null.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
5881
diff
changeset
|
1641 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1642 /* Create a tree of widget_value objects |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1643 representing the panes and their items. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1644 wv = malloc_widget_value (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1645 wv->name = "menu"; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1646 wv->value = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1647 wv->enabled = 1; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1648 first_wv = wv; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1649 first_pane = 1; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1650 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1651 /* Loop over all panes and items, filling in the tree. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1652 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1653 while (i < menu_items_used) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1654 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1655 if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1656 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1657 submenu_stack[submenu_depth++] = save_wv; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1658 save_wv = prev_wv; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1659 prev_wv = 0; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1660 first_pane = 1; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1661 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1662 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1663 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1664 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1665 prev_wv = save_wv; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1666 save_wv = submenu_stack[--submenu_depth]; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1667 first_pane = 0; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1668 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1669 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1670 else if (EQ (XVECTOR (menu_items)->contents[i], Qt) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1671 && submenu_depth != 0) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1672 i += MENU_ITEMS_PANE_LENGTH; |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1673 /* Ignore a nil in the item list. |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1674 It's meaningful only for dialog boxes. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1675 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1676 i += 1; |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1677 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1678 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1679 /* Create a new pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1680 Lisp_Object pane_name, prefix; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1681 char *pane_string; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1682 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1683 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1684 pane_string = (NILP (pane_name) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1685 ? "" : (char *) XSTRING (pane_name)->data); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1686 /* If there is just one top-level pane, put all its items directly |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1687 under the top-level menu. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1688 if (menu_items_n_panes == 1) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1689 pane_string = ""; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1690 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1691 /* If the pane has a meaningful name, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1692 make the pane a top-level menu item |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1693 with its items as a submenu beneath it. */ |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1694 if (!keymaps && strcmp (pane_string, "")) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1695 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1696 wv = malloc_widget_value (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1697 if (save_wv) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1698 save_wv->next = wv; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1699 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1700 first_wv->contents = wv; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1701 wv->name = pane_string; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1702 if (keymaps && !NILP (prefix)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1703 wv->name++; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1704 wv->value = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1705 wv->enabled = 1; |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1706 save_wv = wv; |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1707 prev_wv = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1708 } |
7521
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1709 else if (first_pane) |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1710 { |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1711 save_wv = wv; |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1712 prev_wv = 0; |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1713 } |
2971264ff9aa
(xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents:
7459
diff
changeset
|
1714 first_pane = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1715 i += MENU_ITEMS_PANE_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1716 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1717 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1718 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1719 /* Create a new item within current pane. */ |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
1720 Lisp_Object item_name, enable, descrip, def; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1721 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1722 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1723 descrip |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1724 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
1725 def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION]; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1726 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1727 wv = malloc_widget_value (); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1728 if (prev_wv) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1729 prev_wv->next = wv; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1730 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1731 save_wv->contents = wv; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1732 wv->name = (char *) XSTRING (item_name)->data; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1733 if (!NILP (descrip)) |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1734 wv->key = (char *) XSTRING (descrip)->data; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1735 wv->value = 0; |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
1736 /* If this item has a null value, |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
1737 make the call_data null so that it won't display a box |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
1738 when the mouse is on it. */ |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
1739 wv->call_data |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
1740 = (!NILP (def) ? (void *) &XVECTOR (menu_items)->contents[i] : 0); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1741 wv->enabled = !NILP (enable); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1742 prev_wv = wv; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1743 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1744 i += MENU_ITEMS_ITEM_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1745 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1746 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1747 |
9236
583bb9211b2b
(popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents:
9233
diff
changeset
|
1748 /* Deal with the title, if it is non-nil. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1749 if (!NILP (title)) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1750 { |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1751 widget_value *wv_title = malloc_widget_value (); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1752 widget_value *wv_sep1 = malloc_widget_value (); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1753 widget_value *wv_sep2 = malloc_widget_value (); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1754 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1755 wv_sep2->name = "--"; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1756 wv_sep2->next = first_wv->contents; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1757 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1758 wv_sep1->name = "--"; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1759 wv_sep1->next = wv_sep2; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1760 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1761 wv_title->name = (char *) XSTRING (title)->data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1762 wv_title->enabled = True; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1763 wv_title->next = wv_sep1; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1764 first_wv->contents = wv_title; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1765 } |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1766 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1767 /* Actually create the menu. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1768 menu_id = ++widget_id_tick; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1769 menu = lw_create_widget ("popup", first_wv->name, menu_id, first_wv, |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1770 f->display.x->widget, 1, 0, |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1771 popup_selection_callback, |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1772 popup_deactivate_callback); |
8414
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
1773 |
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
1774 /* Don't allow any geometry request from the user. */ |
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
1775 XtSetArg (av[ac], XtNgeometry, 0); ac++; |
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
1776 XtSetValues (menu, av, ac); |
8a8d2cdd4218
(xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents:
8269
diff
changeset
|
1777 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1778 /* Free the widget_value objects we used to specify the contents. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1779 free_menubar_widget_value_tree (first_wv); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1780 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1781 /* No selection has been chosen yet. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1782 menu_item_selection = 0; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1783 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1784 /* Display the menu. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1785 lw_popup_menu (menu); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1786 popup_activated_flag = 1; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1787 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1788 /* Process events that apply to the menu. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1789 popup_get_selection ((XEvent *) 0); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1790 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1791 pop_down: |
6625
d53ff9fcf05a
(xmenu_show): Undo part of March 11 change:
Richard M. Stallman <rms@gnu.org>
parents:
6605
diff
changeset
|
1792 /* fp turned off the following statement and wrote a comment |
d53ff9fcf05a
(xmenu_show): Undo part of March 11 change:
Richard M. Stallman <rms@gnu.org>
parents:
6605
diff
changeset
|
1793 that it is unnecessary--that the menu has already disappeared. |
d53ff9fcf05a
(xmenu_show): Undo part of March 11 change:
Richard M. Stallman <rms@gnu.org>
parents:
6605
diff
changeset
|
1794 I observer that is not so. -- rms. */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1795 /* Make sure the menu disappears. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1796 lw_destroy_all_widgets (menu_id); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1797 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1798 /* Unread any events that we got but did not handle. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1799 while (queue != NULL) |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1800 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1801 queue_tmp = queue; |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
1802 XPutBackEvent (FRAME_X_DISPLAY (f), &queue_tmp->event); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1803 queue = queue_tmp->next; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1804 free ((char *)queue_tmp); |
7129
6b894fba586b
(xmenu_show, xdialog_show):
Richard M. Stallman <rms@gnu.org>
parents:
6931
diff
changeset
|
1805 /* Cause these events to get read as soon as we UNBLOCK_INPUT. */ |
6b894fba586b
(xmenu_show, xdialog_show):
Richard M. Stallman <rms@gnu.org>
parents:
6931
diff
changeset
|
1806 interrupt_input_pending = 1; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1807 } |
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1808 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1809 /* Find the selected item, and its pane, to return |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1810 the proper value. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1811 if (menu_item_selection != 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1812 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1813 Lisp_Object prefix; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1814 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1815 prefix = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1816 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1817 while (i < menu_items_used) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1818 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1819 Lisp_Object entry; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1820 |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1821 if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1822 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1823 subprefix_stack[submenu_depth++] = prefix; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1824 prefix = entry; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1825 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1826 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1827 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1828 { |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1829 prefix = subprefix_stack[--submenu_depth]; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1830 i++; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1831 } |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1832 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1833 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1834 prefix |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1835 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1836 i += MENU_ITEMS_PANE_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1837 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1838 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1839 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1840 entry |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1841 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1842 if (menu_item_selection == &XVECTOR (menu_items)->contents[i]) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1843 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1844 if (keymaps != 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1845 { |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1846 int j; |
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1847 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1848 entry = Fcons (entry, Qnil); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1849 if (!NILP (prefix)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1850 entry = Fcons (prefix, entry); |
6291
38ec8e76594f
(Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents:
6200
diff
changeset
|
1851 for (j = submenu_depth - 1; j >= 0; j--) |
6931
2d0ee7ef620a
(xmenu_show): Fix typo in last change.
Richard M. Stallman <rms@gnu.org>
parents:
6913
diff
changeset
|
1852 if (!NILP (subprefix_stack[j])) |
6913
f167828a3ec2
(xmenu_show): Don't cons on subprefix_stck[j] if nil.
Richard M. Stallman <rms@gnu.org>
parents:
6881
diff
changeset
|
1853 entry = Fcons (subprefix_stack[j], entry); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1854 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1855 return entry; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1856 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1857 i += MENU_ITEMS_ITEM_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1858 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1859 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1860 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1861 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
1862 return Qnil; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1863 } |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1864 |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1865 static void |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1866 dialog_selection_callback (widget, id, client_data) |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1867 Widget widget; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1868 LWLIB_ID id; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1869 XtPointer client_data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1870 { |
11266
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1871 /* The EMACS_INT cast avoids a warning. There's no problem |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1872 as long as pointers have enough bits to hold small integers. */ |
3e93d8b99b05
(menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents:
11237
diff
changeset
|
1873 if ((int) (EMACS_INT) client_data != -1) |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1874 menu_item_selection = (Lisp_Object *) client_data; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1875 BLOCK_INPUT; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1876 lw_destroy_all_widgets (id); |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1877 UNBLOCK_INPUT; |
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
1878 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
1879 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1880 static char * button_names [] = { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1881 "button1", "button2", "button3", "button4", "button5", |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1882 "button6", "button7", "button8", "button9", "button10" }; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1883 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1884 static Lisp_Object |
6439
463b12ba8260
(xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents:
6426
diff
changeset
|
1885 xdialog_show (f, menubarp, keymaps, title, error) |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1886 FRAME_PTR f; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1887 int menubarp; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1888 int keymaps; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1889 Lisp_Object title; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1890 char **error; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1891 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1892 int i, nb_buttons=0; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1893 int dialog_id; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1894 Widget menu; |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1895 char dialog_name[6]; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1896 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1897 widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1898 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1899 /* Define a queue to save up for later unreading |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1900 all X events that don't pertain to the menu. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1901 struct event_queue |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1902 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1903 XEvent event; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1904 struct event_queue *next; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1905 }; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1906 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1907 struct event_queue *queue = NULL; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1908 struct event_queue *queue_tmp; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1909 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1910 /* Number of elements seen so far, before boundary. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1911 int left_count = 0; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1912 /* 1 means we've seen the boundary between left-hand elts and right-hand. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1913 int boundary_seen = 0; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1914 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1915 *error = NULL; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1916 |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1917 if (menu_items_n_panes > 1) |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1918 { |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1919 *error = "Multiple panes in dialog box"; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1920 return Qnil; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1921 } |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1922 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1923 /* Create a tree of widget_value objects |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1924 representing the text label and buttons. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1925 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1926 Lisp_Object pane_name, prefix; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1927 char *pane_string; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1928 pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1929 prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1930 pane_string = (NILP (pane_name) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1931 ? "" : (char *) XSTRING (pane_name)->data); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1932 prev_wv = malloc_widget_value (); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1933 prev_wv->value = pane_string; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1934 if (keymaps && !NILP (prefix)) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1935 prev_wv->name++; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1936 prev_wv->enabled = 1; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1937 prev_wv->name = "message"; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1938 first_wv = prev_wv; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1939 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1940 /* Loop over all panes and items, filling in the tree. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1941 i = MENU_ITEMS_PANE_LENGTH; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1942 while (i < menu_items_used) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1943 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1944 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1945 /* Create a new item within current pane. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1946 Lisp_Object item_name, enable, descrip; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1947 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1948 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1949 descrip |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1950 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1951 |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1952 if (NILP (item_name)) |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1953 { |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1954 free_menubar_widget_value_tree (first_wv); |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1955 *error = "Submenu in dialog items"; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1956 return Qnil; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1957 } |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1958 if (EQ (item_name, Qquote)) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1959 { |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1960 /* This is the boundary between left-side elts |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1961 and right-side elts. Stop incrementing right_count. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1962 boundary_seen = 1; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1963 i++; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1964 continue; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1965 } |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1966 if (nb_buttons >= 10) |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1967 { |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1968 free_menubar_widget_value_tree (first_wv); |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1969 *error = "Too many dialog items"; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1970 return Qnil; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1971 } |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1972 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1973 wv = malloc_widget_value (); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1974 prev_wv->next = wv; |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1975 wv->name = (char *) button_names[nb_buttons]; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1976 if (!NILP (descrip)) |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1977 wv->key = (char *) XSTRING (descrip)->data; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
1978 wv->value = (char *) XSTRING (item_name)->data; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1979 wv->call_data = (void *) &XVECTOR (menu_items)->contents[i]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1980 wv->enabled = !NILP (enable); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1981 prev_wv = wv; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1982 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1983 if (! boundary_seen) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1984 left_count++; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1985 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1986 nb_buttons++; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1987 i += MENU_ITEMS_ITEM_LENGTH; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1988 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1989 |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1990 /* If the boundary was not specified, |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1991 by default put half on the left and half on the right. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1992 if (! boundary_seen) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1993 left_count = nb_buttons - nb_buttons / 2; |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
1994 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
1995 wv = malloc_widget_value (); |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1996 wv->name = dialog_name; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1997 |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1998 /* Dialog boxes use a really stupid name encoding |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
1999 which specifies how many buttons to use |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2000 and how many buttons are on the right. |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2001 The Q means something also. */ |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2002 dialog_name[0] = 'Q'; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2003 dialog_name[1] = '0' + nb_buttons; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2004 dialog_name[2] = 'B'; |
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2005 dialog_name[3] = 'R'; |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2006 /* Number of buttons to put on the right. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2007 dialog_name[4] = '0' + nb_buttons - left_count; |
6426
1f1388aa2d44
(Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents:
6424
diff
changeset
|
2008 dialog_name[5] = 0; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2009 wv->contents = first_wv; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2010 first_wv = wv; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2011 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2012 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2013 /* Actually create the dialog. */ |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2014 dialog_id = ++widget_id_tick; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2015 menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv, |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2016 f->display.x->widget, 1, 0, |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2017 dialog_selection_callback, 0); |
7770
41dda174ca7c
(xdialog_show): Fix problem with message in dialog box.
Karl Heuer <kwzh@gnu.org>
parents:
7679
diff
changeset
|
2018 lw_modify_all_widgets (dialog_id, first_wv->contents, True); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2019 /* Free the widget_value objects we used to specify the contents. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2020 free_menubar_widget_value_tree (first_wv); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2021 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2022 /* No selection has been chosen yet. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2023 menu_item_selection = 0; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2024 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2025 /* Display the menu. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2026 lw_pop_up_all_widgets (dialog_id); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2027 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2028 /* Process events that apply to the menu. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2029 while (1) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2030 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2031 XEvent event; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2032 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2033 XtAppNextEvent (Xt_app_con, &event); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2034 if (event.type == ButtonRelease) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2035 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2036 XtDispatchEvent (&event); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2037 break; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2038 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2039 else if (event.type == Expose) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2040 process_expose_from_menu (event); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2041 XtDispatchEvent (&event); |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2042 if (XtWindowToWidget (FRAME_X_DISPLAY (f), event.xany.window) != menu) |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2043 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2044 queue_tmp = (struct event_queue *) malloc (sizeof (struct event_queue)); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2045 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2046 if (queue_tmp != NULL) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2047 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2048 queue_tmp->event = event; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2049 queue_tmp->next = queue; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2050 queue = queue_tmp; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2051 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2052 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2053 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2054 pop_down: |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2055 |
9572 | 2056 #ifdef HAVE_X_WINDOWS |
7208
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2057 /* State that no mouse buttons are now held. |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2058 That is not necessarily true, but the fiction leads to reasonable |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2059 results, and it is a pain to ask which are actually held now |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2060 or track this in the loop above. */ |
9619
1c985426ad84
(xdialog_show, xmenu_show): Use grabbed field instead of x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
9608
diff
changeset
|
2061 FRAME_X_DISPLAY_INFO (f)->grabbed = 0; |
9572 | 2062 #endif |
7208
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2063 |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2064 /* Unread any events that we got but did not handle. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2065 while (queue != NULL) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2066 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2067 queue_tmp = queue; |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2068 XPutBackEvent (FRAME_X_DISPLAY (f), &queue_tmp->event); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2069 queue = queue_tmp->next; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2070 free ((char *)queue_tmp); |
7129
6b894fba586b
(xmenu_show, xdialog_show):
Richard M. Stallman <rms@gnu.org>
parents:
6931
diff
changeset
|
2071 /* Cause these events to get read as soon as we UNBLOCK_INPUT. */ |
6b894fba586b
(xmenu_show, xdialog_show):
Richard M. Stallman <rms@gnu.org>
parents:
6931
diff
changeset
|
2072 interrupt_input_pending = 1; |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2073 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2074 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2075 /* Find the selected item, and its pane, to return |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2076 the proper value. */ |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2077 if (menu_item_selection != 0) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2078 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2079 Lisp_Object prefix; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2080 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2081 prefix = Qnil; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2082 i = 0; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2083 while (i < menu_items_used) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2084 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2085 Lisp_Object entry; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2086 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2087 if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2088 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2089 prefix |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2090 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2091 i += MENU_ITEMS_PANE_LENGTH; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2092 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2093 else |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2094 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2095 entry |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2096 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2097 if (menu_item_selection == &XVECTOR (menu_items)->contents[i]) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2098 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2099 if (keymaps != 0) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2100 { |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2101 entry = Fcons (entry, Qnil); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2102 if (!NILP (prefix)) |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2103 entry = Fcons (prefix, entry); |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2104 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2105 return entry; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2106 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2107 i += MENU_ITEMS_ITEM_LENGTH; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2108 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2109 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2110 } |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2111 |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2112 return Qnil; |
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2113 } |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2114 #else /* not USE_X_TOOLKIT */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2115 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2116 static Lisp_Object |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
2117 xmenu_show (f, x, y, menubarp, for_click, keymaps, title, error) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2118 FRAME_PTR f; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2119 int x, y; |
10757
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
2120 int menubarp; |
2829c9840b0e
(xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents:
10716
diff
changeset
|
2121 int for_click; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2122 int keymaps; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2123 Lisp_Object title; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2124 char **error; |
118 | 2125 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2126 Window root; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2127 XMenu *menu; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2128 int pane, selidx, lpane, status; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2129 Lisp_Object entry, pane_prefix; |
118 | 2130 char *datap; |
2131 int ulx, uly, width, height; | |
2132 int dispwidth, dispheight; | |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2133 int i, j; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2134 int maxwidth; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2135 int dummy_int; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2136 unsigned int dummy_uint; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
2137 |
3747
6506b2fd475a
(xmenu_show): Store 0 in *ERROR at the beginning.
Richard M. Stallman <rms@gnu.org>
parents:
3501
diff
changeset
|
2138 *error = 0; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2139 if (menu_items_n_panes == 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2140 return Qnil; |
1082
d24afc1bef38
(xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents:
975
diff
changeset
|
2141 |
7335
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2142 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2143 { |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2144 *error = "Empty menu"; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2145 return Qnil; |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2146 } |
73d1276933e1
(xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents:
7334
diff
changeset
|
2147 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2148 /* Figure out which root window F is on. */ |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2149 XGetGeometry (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &root, |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2150 &dummy_int, &dummy_int, &dummy_uint, &dummy_uint, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2151 &dummy_uint, &dummy_uint); |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2152 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2153 /* Make the menu on that window. */ |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2154 menu = XMenuCreate (FRAME_X_DISPLAY (f), root, "emacs"); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2155 if (menu == NULL) |
118 | 2156 { |
2157 *error = "Can't create menu"; | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2158 return Qnil; |
118 | 2159 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2160 |
9572 | 2161 #ifdef HAVE_X_WINDOWS |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2162 /* Adjust coordinates to relative to the outer (window manager) window. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2163 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2164 Window child; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2165 int win_x = 0, win_y = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2166 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2167 /* Find the position of the outside upper-left corner of |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2168 the inner window, with respect to the outer window. */ |
9649
910da93766c8
(xmenu_show): Get the screen number for DisplayHeight
Richard M. Stallman <rms@gnu.org>
parents:
9619
diff
changeset
|
2169 if (f->display.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2170 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2171 BLOCK_INPUT; |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2172 XTranslateCoordinates (FRAME_X_DISPLAY (f), |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2173 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2174 /* From-window, to-window. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2175 f->display.x->window_desc, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2176 f->display.x->parent_desc, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2177 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2178 /* From-position, to-position. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2179 0, 0, &win_x, &win_y, |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2180 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2181 /* Child of window. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2182 &child); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2183 UNBLOCK_INPUT; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2184 x += win_x; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2185 y += win_y; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2186 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2187 } |
9572 | 2188 #endif /* HAVE_X_WINDOWS */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2189 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2190 /* Adjust coordinates to be root-window-relative. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2191 x += f->display.x->left_pos; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2192 y += f->display.x->top_pos; |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2193 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2194 /* Create all the necessary panes and their items. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2195 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2196 while (i < menu_items_used) |
118 | 2197 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2198 if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
118 | 2199 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2200 /* Create a new pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2201 Lisp_Object pane_name, prefix; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2202 char *pane_string; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2203 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2204 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2205 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2206 pane_string = (NILP (pane_name) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2207 ? "" : (char *) XSTRING (pane_name)->data); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2208 if (keymaps && !NILP (prefix)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2209 pane_string++; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2210 |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2211 lpane = XMenuAddPane (FRAME_X_DISPLAY (f), menu, pane_string, TRUE); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2212 if (lpane == XM_FAILURE) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2213 { |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2214 XMenuDestroy (FRAME_X_DISPLAY (f), menu); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2215 *error = "Can't create pane"; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2216 return Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2217 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2218 i += MENU_ITEMS_PANE_LENGTH; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2219 |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2220 /* Find the width of the widest item in this pane. */ |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2221 maxwidth = 0; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2222 j = i; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2223 while (j < menu_items_used) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2224 { |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2225 Lisp_Object item; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2226 item = XVECTOR (menu_items)->contents[j]; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2227 if (EQ (item, Qt)) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2228 break; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2229 if (NILP (item)) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2230 { |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2231 j++; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2232 continue; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2233 } |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2234 width = XSTRING (item)->size; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2235 if (width > maxwidth) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2236 maxwidth = width; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2237 |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2238 j += MENU_ITEMS_ITEM_LENGTH; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2239 } |
118 | 2240 } |
6746
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2241 /* Ignore a nil in the item list. |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2242 It's meaningful only for dialog boxes. */ |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2243 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) |
cda1ce7952ca
(Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6656
diff
changeset
|
2244 i += 1; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2245 else |
118 | 2246 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2247 /* Create a new item within current pane. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2248 Lisp_Object item_name, enable, descrip; |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2249 unsigned char *item_data; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2250 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2251 item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2252 enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2253 descrip |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2254 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2255 if (!NILP (descrip)) |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2256 { |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2257 int gap = maxwidth - XSTRING (item_name)->size; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2258 #ifdef C_ALLOCA |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2259 Lisp_Object spacer; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2260 spacer = Fmake_string (make_number (gap), make_number (' ')); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2261 item_name = concat2 (item_name, spacer); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2262 item_name = concat2 (item_name, descrip); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2263 item_data = XSTRING (item_name)->data; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2264 #else |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2265 /* if alloca is fast, use that to make the space, |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2266 to reduce gc needs. */ |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2267 item_data |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2268 = (unsigned char *) alloca (maxwidth |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2269 + XSTRING (descrip)->size + 1); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2270 bcopy (XSTRING (item_name)->data, item_data, |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2271 XSTRING (item_name)->size); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2272 for (j = XSTRING (item_name)->size; j < maxwidth; j++) |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2273 item_data[j] = ' '; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2274 bcopy (XSTRING (descrip)->data, item_data + j, |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2275 XSTRING (descrip)->size); |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2276 item_data[j + XSTRING (descrip)->size] = 0; |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2277 #endif |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2278 } |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2279 else |
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2280 item_data = XSTRING (item_name)->data; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2281 |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2282 if (XMenuAddSelection (FRAME_X_DISPLAY (f), |
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2283 menu, lpane, 0, item_data, |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2284 !NILP (enable)) |
118 | 2285 == XM_FAILURE) |
2286 { | |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2287 XMenuDestroy (FRAME_X_DISPLAY (f), menu); |
118 | 2288 *error = "Can't add selection to menu"; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2289 return Qnil; |
118 | 2290 } |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2291 i += MENU_ITEMS_ITEM_LENGTH; |
118 | 2292 } |
2293 } | |
6881
796416bd7f7e
(last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6764
diff
changeset
|
2294 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2295 /* All set and ready to fly. */ |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2296 XMenuRecompute (FRAME_X_DISPLAY (f), menu); |
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2297 dispwidth = DisplayWidth (FRAME_X_DISPLAY (f), |
9649
910da93766c8
(xmenu_show): Get the screen number for DisplayHeight
Richard M. Stallman <rms@gnu.org>
parents:
9619
diff
changeset
|
2298 XScreenNumberOfScreen (FRAME_X_SCREEN (f))); |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2299 dispheight = DisplayHeight (FRAME_X_DISPLAY (f), |
9649
910da93766c8
(xmenu_show): Get the screen number for DisplayHeight
Richard M. Stallman <rms@gnu.org>
parents:
9619
diff
changeset
|
2300 XScreenNumberOfScreen (FRAME_X_SCREEN (f))); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2301 x = min (x, dispwidth); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2302 y = min (y, dispheight); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2303 x = max (x, 1); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2304 y = max (y, 1); |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2305 XMenuLocate (FRAME_X_DISPLAY (f), menu, 0, 0, x, y, |
118 | 2306 &ulx, &uly, &width, &height); |
2307 if (ulx+width > dispwidth) | |
2308 { | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2309 x -= (ulx + width) - dispwidth; |
118 | 2310 ulx = dispwidth - width; |
2311 } | |
2312 if (uly+height > dispheight) | |
2313 { | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2314 y -= (uly + height) - dispheight; |
118 | 2315 uly = dispheight - height; |
2316 } | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2317 if (ulx < 0) x -= ulx; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2318 if (uly < 0) y -= uly; |
6526
95661fd7a320
(xmenu_show): Enable asynchronous events.
Karl Heuer <kwzh@gnu.org>
parents:
6481
diff
changeset
|
2319 |
95661fd7a320
(xmenu_show): Enable asynchronous events.
Karl Heuer <kwzh@gnu.org>
parents:
6481
diff
changeset
|
2320 XMenuSetAEQ (menu, TRUE); |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2321 XMenuSetFreeze (menu, TRUE); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2322 pane = selidx = 0; |
118 | 2323 |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2324 status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2325 x, y, ButtonReleaseMask, &datap); |
10167
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2326 |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2327 |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2328 /* Assume the mouse has moved out of the X window. |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2329 If it has actually moved in, we will get an EnterNotify. */ |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2330 x_mouse_leave (); |
358d48409854
Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents:
9725
diff
changeset
|
2331 |
118 | 2332 switch (status) |
2333 { | |
2334 case XM_SUCCESS: | |
2335 #ifdef XDEBUG | |
2336 fprintf (stderr, "pane= %d line = %d\n", panes, selidx); | |
2337 #endif | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2338 |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2339 /* Find the item number SELIDX in pane number PANE. */ |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2340 i = 0; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2341 while (i < menu_items_used) |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
2342 { |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2343 if (EQ (XVECTOR (menu_items)->contents[i], Qt)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2344 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2345 if (pane == 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2346 pane_prefix |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2347 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2348 pane--; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2349 i += MENU_ITEMS_PANE_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2350 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2351 else |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2352 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2353 if (pane == -1) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2354 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2355 if (selidx == 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2356 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2357 entry |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2358 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2359 if (keymaps != 0) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2360 { |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2361 entry = Fcons (entry, Qnil); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2362 if (!NILP (pane_prefix)) |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2363 entry = Fcons (pane_prefix, entry); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2364 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2365 break; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2366 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2367 selidx--; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2368 } |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2369 i += MENU_ITEMS_ITEM_LENGTH; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2370 } |
2747
f258c79c9162
(Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents:
2514
diff
changeset
|
2371 } |
118 | 2372 break; |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2373 |
118 | 2374 case XM_FAILURE: |
2375 *error = "Can't activate menu"; | |
2376 case XM_IA_SELECT: | |
2377 case XM_NO_SELECT: | |
2378 entry = Qnil; | |
2379 break; | |
2380 } | |
9608
1a85137cb257
Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents:
9572
diff
changeset
|
2381 XMenuDestroy (FRAME_X_DISPLAY (f), menu); |
7208
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2382 |
9572 | 2383 #ifdef HAVE_X_WINDOWS |
7208
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2384 /* State that no mouse buttons are now held. |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2385 (The oldXMenu code doesn't track this info for us.) |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2386 That is not necessarily true, but the fiction leads to reasonable |
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2387 results, and it is a pain to ask which are actually held now. */ |
9619
1c985426ad84
(xdialog_show, xmenu_show): Use grabbed field instead of x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
9608
diff
changeset
|
2388 FRAME_X_DISPLAY_INFO (f)->grabbed = 0; |
9572 | 2389 #endif |
7208
2d3c771ff861
(xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents:
7175
diff
changeset
|
2390 |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2391 return entry; |
118 | 2392 } |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2393 |
5673
7035bc81858b
Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents:
5602
diff
changeset
|
2394 #endif /* not USE_X_TOOLKIT */ |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2395 |
118 | 2396 syms_of_xmenu () |
2397 { | |
6058
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2398 staticpro (&menu_items); |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2399 menu_items = Qnil; |
662b9cd767fe
(Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents:
6018
diff
changeset
|
2400 |
9336
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
2401 #ifdef USE_X_TOOLKIT |
9233
746cc6b0d28f
(widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents:
9102
diff
changeset
|
2402 widget_id_tick = (1<<16); |
9336
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
2403 #endif |
d5ffd9c9edb0
(widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents:
9236
diff
changeset
|
2404 |
11237
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
2405 staticpro (&frame_vector); |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
2406 frame_vector = Fmake_vector (make_number (10), Qnil); |
7c968b691ff0
(frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents:
11125
diff
changeset
|
2407 |
118 | 2408 defsubr (&Sx_popup_menu); |
6307
1f9fa4022502
(xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents:
6291
diff
changeset
|
2409 defsubr (&Sx_popup_dialog); |
118 | 2410 } |