annotate src/xmenu.c @ 6325:d6817c9c0413

Undo previous change. Instead: (Fx_popup_dialog) [! USE_X_TOOLKIT]: Call Fx_popup_menu.
author Richard M. Stallman <rms@gnu.org>
date Mon, 14 Mar 1994 00:18:52 +0000
parents fa8040a2bba9
children 6240067bfe33
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 /* X pop-up deck-of-cards menu facility for gnuemacs.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 *
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 * Written by Jon Arnold and Roman Budzianowski
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 * Mods and rewrite by Robert Krawitz
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 *
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 #include <stdio.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 /* On 4.3 this loses if it comes after xterm.h. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 #include <signal.h>
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 4627
diff changeset
36 #include <config.h>
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
4de9c9a62bda entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
39 #include "frame.h"
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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"
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 /* This may include sys/types.h, and that somehow loses
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 if this is not done before the other system files. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 #include "xterm.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 /* Load sys/types.h if not already loaded.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 In some systems loading it twice is suicidal. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 #ifndef makedev
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 #include <sys/types.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 #include "dispextern.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 #ifdef HAVE_X11
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 #include "../oldXMenu/XMenu.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 #else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 #include <X/XMenu.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
62 #ifdef USE_X_TOOLKIT
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
63 #include <X11/Xlib.h>
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
64 #include <X11/IntrinsicP.h>
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
65 #include <X11/CoreP.h>
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
66 #include <X11/StringDefs.h>
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
67 #include <X11/Xaw/Paned.h>
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
68 #include "../lwlib/lwlib.h"
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
69 #include "../lwlib/xlwmenuP.h"
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
70 #endif /* USE_X_TOOLKIT */
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
71
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 #define min(x,y) (((x) < (y)) ? (x) : (y))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 #define max(x,y) (((x) > (y)) ? (x) : (y))
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 #ifndef TRUE
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 #define TRUE 1
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 #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
78 #endif /* no TRUE */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 #ifdef HAVE_X11
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 extern Display *x_current_display;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 #else
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 #define ButtonReleaseMask ButtonReleased
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 #endif /* not HAVE_X11 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
86 /* We need a unique id for each popup menu and dialog box. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
87 static unsigned int popup_id_tick;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
88
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
89 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
90 extern Lisp_Object 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
91
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
92 #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
93 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
94 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
95
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
96 static int string_width ();
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
97 static Lisp_Object xdialog_show ();
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
98 #endif
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
99
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
100 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
101 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
102 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
103 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
104 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
105
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
106 /* 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
107 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
108
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
109 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
110
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
111 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
112 t, the pane name, the pane's prefix key.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
113 Then follow the pane's items, with 4 elements per item:
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
114 the item string, the enable flag, the 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
115 and the equivalent keyboard key's description string.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
116
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
117 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
118 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
119 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
120 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
121
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
122 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
123 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
124
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_NAME 1
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_PREFIX 2
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
127 #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
128
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_NAME 0
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_ENABLE 1
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_VALUE 2
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
132 #define MENU_ITEMS_ITEM_EQUIV_KEY 3
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
133 #define MENU_ITEMS_ITEM_LENGTH 4
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
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
150 /* 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
151 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
152
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
153 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
154 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
155 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
156 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
157 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
158 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
159 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
160 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
161
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
162 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
163 menu_items_n_panes = 0;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
164 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
165 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
166
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
167 /* 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
168 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
169
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
170 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
171 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
172 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
173 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
174
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
175 /* 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
176 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
177
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
178 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
179 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
180 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
181 /* 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
182 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
183 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
184 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
185 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
186 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
187 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
188 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
189
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
190 /* 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
191
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
192 static void
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
193 grow_menu_items ()
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
194 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
195 Lisp_Object old;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
196 int old_size = menu_items_allocated;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
197 old = menu_items;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
198
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
199 menu_items_allocated *= 2;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
200 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
201 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
202 old_size * sizeof (Lisp_Object));
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
203 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
204
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
205 /* Begin a submenu. */
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
206
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
207 static void
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
208 push_submenu_start ()
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
209 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
210 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
211 grow_menu_items ();
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
212
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
213 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
214 menu_items_submenu_depth++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
215 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
216
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
217 /* End a submenu. */
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
218
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
219 static void
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
220 push_submenu_end ()
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
221 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
222 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
223 grow_menu_items ();
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
224
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
225 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
226 menu_items_submenu_depth--;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
227 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
228
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
229 /* 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
230 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
231
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
232 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
233 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
234 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
235 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
236 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
237 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
238
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
239 if (menu_items_submenu_depth == 0)
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
240 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
241 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
242 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
243 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
244 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
246 /* 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
247 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
248 this item can be selected. KEY is the key generated by
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
249 choosing this item. EQUIV is the textual description
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
250 of the keyboard equivalent for this item (or nil if none). */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
251
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
252 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
253 push_menu_item (name, enable, key, equiv)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
254 Lisp_Object name, enable, key, equiv;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
255 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
256 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
257 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
258
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
259 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
260 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
261 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
262 XVECTOR (menu_items)->contents[menu_items_used++] = equiv;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
263 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
264
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
265 /* 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
266 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
267 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
268 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
269 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
270 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
271
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
272 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
273 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
274 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
275 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
276 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
277 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
278 /* 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
279 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
280 /* 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
281 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
282 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
283 /* 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
284 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
285 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
286 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
287 int changed = 0;
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 /* 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
290 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
291 && 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
292 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
293
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
294 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
295
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
296 /* 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
297 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
298 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
299 && (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
300 || 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
301 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
302 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
303 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
304 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
305 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
306 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
307
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
308 /* 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
309 def1 = Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
310 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
311 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
312 /* 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
313 if (! EQ (def1, def)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
314 /* 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
315 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
316 && !(!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
317 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
318 changed = 1;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
319 descrip = Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
320 savedkey = Fwhere_is_internal (def, Qnil, Qt, Qnil);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
321 if (VECTORP (savedkey)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
322 && EQ (XVECTOR (savedkey)->contents[0], Qmenu_bar))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
323 savedkey = Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
324 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
325 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
326 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
327 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
328 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
329 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
330 }
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 /* 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
333 if (NILP (cachelist))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
334 XCONS (item1)->cdr = Fcons (Fcons (savedkey, descrip), def);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
335 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
336 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
337 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
338 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
339 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
340
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
341 *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
342 return def;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
343 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
344
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
345 /* This is used as the handler when calling internal_condition_case_1. */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
347 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
348 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
349 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
350 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
351 return Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
352 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
353
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
354 /* 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
355 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
356 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
357
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
358 static Lisp_Object
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
359 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
360 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
361 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
362 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
363
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
364 enabled = Qt;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
365 if (notreal)
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
366 return enabled;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
367 if (XTYPE (def) == Lisp_Symbol)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
368 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
369 /* 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
370 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
371 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
372 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
373 /* (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
374 (error nil)) */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
375 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
376 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
377 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
378 return enabled;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
379 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
380
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
381 /* 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
382 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
383 If NOTREAL is nonzero,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
384 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
385
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
386 static void
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
387 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
388 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
389 int nmaps;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
390 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
391 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
392 int mapno;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
393
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
394 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
395
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
396 /* 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
397 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
398 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
399 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
400 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
401
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
402 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
403 }
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 /* 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
406 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
407 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
408 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
409 If NOTREAL is nonzero,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
410 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
411
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
412 static void
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
413 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
414 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
415 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
416 Lisp_Object prefix;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
417 int notreal;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
419 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
420 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
421 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
422
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
423 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
424
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
425 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
426
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
427 for (tail = keymap; XTYPE (tail) == Lisp_Cons; tail = XCONS (tail)->cdr)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
428 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
429 /* 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
430 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
431 item = XCONS (tail)->car;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
432 if (XTYPE (item) == Lisp_Cons)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
433 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
434 item1 = XCONS (item)->cdr;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
435 if (XTYPE (item1) == Lisp_Cons)
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 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
438 if (XTYPE (item_string) == Lisp_String)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
439 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
440 /* 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
441 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
442 /* 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
443 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
444 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
445 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
446
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
447 def = menu_item_equiv_key (item_string, item1, &descrip);
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 /* GCPRO because we will call eval.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
450 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
451 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
452 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
453 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
454 GCPRO4 (keymap, pending_maps, def, descrip);
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
455 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
456
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
457 UNGCPRO;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
458
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
459 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
460
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
461 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
462 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
463 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
464 pending_maps);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
465 else
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
466 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
467 Lisp_Object submap;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
468 submap = get_keymap_1 (def, 0, 1);
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
469 #ifndef USE_X_TOOLKIT
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
470 /* 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
471 if (!NILP (submap))
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
472 item_string = concat2 (item_string,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
473 build_string (" >"));
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
474 #endif
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
475 push_menu_item (item_string, enabled, XCONS (item)->car,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
476 descrip);
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
477 #ifdef USE_X_TOOLKIT
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
478 /* Display a submenu using the toolkit. */
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
479 if (! NILP (submap))
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
480 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
481 push_submenu_start ();
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
482 single_keymap_panes (submap, Qnil,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
483 XCONS (item)->car, notreal);
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
484 push_submenu_end ();
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
485 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
486 #endif
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
487 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
488 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
489 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
490 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
491 else if (XTYPE (item) == Lisp_Vector)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
492 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
493 /* 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
494 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
495 int c;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
496 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
497 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
498 Lisp_Object character;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
499 XFASTINT (character) = c;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
500 item1 = XVECTOR (item)->contents[c];
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
501 if (XTYPE (item1) == Lisp_Cons)
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 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
504 if (XTYPE (item_string) == Lisp_String)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
505 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
506 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
507
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
508 /* 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
509 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
510 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
511 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
512
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
513 def = menu_item_equiv_key (item_string, item1, &descrip);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
514
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
515 /* GCPRO because we will call eval.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
516 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
517 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
518 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
519 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
520 GCPRO4 (keymap, pending_maps, def, descrip);
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
521 enabled = 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
522 UNGCPRO;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
523
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
524 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
525
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
526 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
527 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
528 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
529 pending_maps);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
530 else
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
531 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
532 Lisp_Object submap;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
533 submap = get_keymap_1 (def, 0, 1);
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
534 #ifndef USE_X_TOOLKIT
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
535 if (!NILP (submap))
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
536 item_string = concat2 (item_string,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
537 build_string (" >"));
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
538 #endif
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
539 push_menu_item (item_string, enabled, character,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
540 descrip);
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
541 #ifdef USE_X_TOOLKIT
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
542 if (! NILP (submap))
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
543 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
544 push_submenu_start ();
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
545 single_keymap_panes (submap, Qnil,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
546 character, notreal);
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
547 push_submenu_end ();
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 #endif
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
550 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
551 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
552 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
553 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
554 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
555 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
556
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
557 /* 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
558 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
559 {
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
560 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
561 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
562 eltcdr = XCONS (elt)->cdr;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
563 string = XCONS (eltcdr)->car;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
564 /* 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
565 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
566 single_keymap_panes (Fcar (elt), string,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
567 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
568 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
569 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
571
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
572 /* 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
573 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
574 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
575
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
576 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
577 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
578 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
579 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
580 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
581
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
582 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
583
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
584 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
585 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
586 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
587 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
588 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
589 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
590 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
591 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
592 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
593 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
594 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
596 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
597 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
598
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
599 /* 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
600
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
601 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
602 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
603 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
604 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
605 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
606
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
607 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
608 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
609 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
610 if (STRINGP (item))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
611 push_menu_item (item, Qnil, Qnil);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
612 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
613 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
614 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
615 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
616 CHECK_STRING (item1, 1);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
617 push_menu_item (item1, Qt, Fcdr (item), Qnil);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
618 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
619 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
620 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
621
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
622 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 1, 2, 0,
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 "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
624 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
625 or a list ((XOFFSET YOFFSET) WINDOW)\n\
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 where XOFFSET and YOFFSET are positions in characters 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
627 corner of WINDOW's frame. (WINDOW may be a frame object instead of a window.)\n\
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 This controls the position of the center of the first line\n\
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 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
630 If POSITION is t, it means to use the current mouse position.\n\
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631 \n\
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
632 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
633 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
634 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
635 \(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
636 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
637 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
638 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
639 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
640 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
641 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
642 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
643 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
644 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
645 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
646 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
647 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
648 \n\
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
649 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
650 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
651 (position, menu)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
652 Lisp_Object position, menu;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 {
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
654 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
655 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
656 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
657 Lisp_Object title;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 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
659 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
660 int i, j;
770
4de9c9a62bda entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
661 FRAME_PTR f;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 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
663 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
664 int menubarp = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
665 struct gcpro gcpro1;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
667 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
668 {
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
669 check_x ();
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
670
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
671 /* 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
672 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
673 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
674 /* Use the mouse's current position. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
675 FRAME_PTR new_f;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
676 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
677 int part;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
678 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
679
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
680 (*mouse_position_hook) (&new_f, &bar_window, &part, &x, &y, &time);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
681 XSET (window, Lisp_Frame, new_f);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
682 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
683 else
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
684 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
685 tem = Fcar (position);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
686 if (XTYPE (tem) == Lisp_Cons)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
687 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
688 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
689 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
690 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
691 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
692 else
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
693 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
694 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
695 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
696 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
697 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
698 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
699
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
700 /* 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
701 tem = Fcar (Fcdr (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
702 if (XTYPE (Fcar (position)) != Lisp_Cons
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
703 && CONSP (tem)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
704 && EQ (Fcar (tem), Qmenu_bar))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
705 menubarp = 1;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
706 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
707 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
708
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
709 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
710 CHECK_NUMBER (y, 0);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
711
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
712 /* 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
713
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
714 if (XTYPE (window) == Lisp_Frame)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
715 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
716 f = XFRAME (window);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
717
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
718 xpos = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
719 ypos = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
720 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
721 else if (XTYPE (window) == Lisp_Window)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
722 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
723 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
724 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
725
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
726 xpos = (FONT_WIDTH (f->display.x->font) * XWINDOW (window)->left);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
727 ypos = (FONT_HEIGHT (f->display.x->font) * XWINDOW (window)->top);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
728 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
729 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
730 /* ??? 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
731 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
732 CHECK_WINDOW (window, 0);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
733
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
734 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
735 ypos += XINT (y);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
736 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
737
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
738 title = Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
739 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
740
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
741 /* 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
742
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
743 keymap = Fkeymapp (menu);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
744 tem = Qnil;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
745 if (XTYPE (menu) == Lisp_Cons)
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
746 tem = Fkeymapp (Fcar (menu));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
747 if (!NILP (keymap))
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
748 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
749 /* 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
750 Lisp_Object prompt;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
751 keymap = get_keymap (menu);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
752
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
753 /* 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
754 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
755
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
756 /* 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
757 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
758 prompt = map_prompt (keymap);
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
759
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
760 /* 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
761 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
762 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
763
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
764 keymaps = 1;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
765 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
766 else if (!NILP (tem))
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
767 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
768 /* 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
769 int nmaps = XFASTINT (Flength (menu));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
770 Lisp_Object *maps
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
771 = (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
772 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
773
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
774 title = Qnil;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
775
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
776 /* 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
777 supplies the menu title. */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
778 for (tem = menu, i = 0; XTYPE (tem) == Lisp_Cons; tem = Fcdr (tem))
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
779 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
780 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
781
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
782 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
783
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
784 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
785 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
786 title = prompt;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
787 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
788
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
789 /* 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
790 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
791
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
792 /* 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
793 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
794 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
795
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
796 keymaps = 1;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
797 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
798 else
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
799 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
800 /* 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
801 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
802 CHECK_STRING (title, 1);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
803
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
804 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
805
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
806 keymaps = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
807 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
808
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
809 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
810 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
811 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
812 UNGCPRO;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
813 return Qnil;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
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
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
816 /* 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
817 BLOCK_INPUT;
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 selection = xmenu_show (f, xpos, ypos, menubarp,
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
820 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
821 UNBLOCK_INPUT;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
822
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
823 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
824
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
825 UNGCPRO;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
826
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
827 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
828 return selection;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
829 }
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
830
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
831 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 1, 2, 0,
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
832 "Pop up a dialog box and return user's selection.\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
833 POSITION is a position specification. This is either a mouse button event\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
834 or a list ((XOFFSET YOFFSET) WINDOW)\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
835 where XOFFSET and YOFFSET are positions in characters from the top left\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
836 corner of WINDOW's frame. (WINDOW may be a frame object instead of a window.)\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
837 This controls the position of the center of the first line\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
838 in the first pane of the menu, not the top left of the menu as a whole.\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
839 If POSITION is t, it means to use the current mouse position.\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
840 \n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
841 MENU is a specifier for a menu. For the simplest case, MENU is a keymap.\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
842 The menu items come from key bindings that have a menu string as well as\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
843 a definition; actually, the \"definition\" in such a key binding looks like\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
844 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
845 the keymap as a top-level element.\n\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
846 You can also use a list of keymaps as MENU.\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
847 Then each keymap makes a separate pane.\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
848 When MENU is a keymap or a list of keymaps, the return value\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
849 is a list of events.\n\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
850 Alternatively, you can specify a menu of multiple panes\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
851 with a list of the form (TITLE PANE1 PANE2...),\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
852 where each pane is a list of form (TITLE ITEM1 ITEM2...).\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
853 Each ITEM is normally a cons cell (STRING . VALUE);\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
854 but a string can appear as an item--that makes a nonselectable line\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
855 in the menu.\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
856 With this form of menu, the return value is VALUE from the chosen item.\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
857 \n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
858 If POSITION is nil, don't display the menu at all, just precalculate the\n\
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
859 cached information about equivalent key sequences.")
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
860 (position, menu)
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
861 Lisp_Object position, menu;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
862 {
6325
d6817c9c0413 Undo previous change. Instead:
Richard M. Stallman <rms@gnu.org>
parents: 6324
diff changeset
863 #ifndef USE_X_TOOLKIT
d6817c9c0413 Undo previous change. Instead:
Richard M. Stallman <rms@gnu.org>
parents: 6324
diff changeset
864 return Fx_popup_menu (position, menu);
d6817c9c0413 Undo previous change. Instead:
Richard M. Stallman <rms@gnu.org>
parents: 6324
diff changeset
865 #else
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
866 int number_of_panes, panes;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
867 Lisp_Object keymap, tem;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
868 int xpos, ypos;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
869 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
870 char *error_name;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
871 Lisp_Object selection;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
872 int i, j;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
873 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
874 Lisp_Object x, y, window;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
875 int 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
876 int menubarp = 0;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
877 struct gcpro gcpro1;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
878
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
879 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
880
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
881 if (! NILP (position))
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
882 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
883 /* Decode the first argument: find the window and the coordinates. */
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
884 if (EQ (position, Qt))
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
885 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
886 /* Use the mouse's current position. */
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
887 FRAME_PTR new_f;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
888 Lisp_Object bar_window;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
889 int part;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
890 unsigned long time;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
891
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
892 (*mouse_position_hook) (&new_f, &bar_window, &part, &x, &y, &time);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
893 XSET (window, Lisp_Frame, new_f);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
894 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
895
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
896 CHECK_NUMBER (x, 0);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
897 CHECK_NUMBER (y, 0);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
898
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
899 /* Decode where to put 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
900
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
901 if (XTYPE (window) == Lisp_Frame)
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
902 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
903 f = XFRAME (window);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
904
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
905 xpos = 0;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
906 ypos = 0;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
907 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
908 else if (XTYPE (window) == Lisp_Window)
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
909 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
910 CHECK_LIVE_WINDOW (window, 0);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
911 f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
912
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
913 xpos = (FONT_WIDTH (f->display.x->font) * XWINDOW (window)->left);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
914 ypos = (FONT_HEIGHT (f->display.x->font) * XWINDOW (window)->top);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
915 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
916 else
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
917 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
918 but I don't want to make one now. */
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
919 CHECK_WINDOW (window, 0);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
920
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
921 xpos += XINT (x);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
922 ypos += XINT (y);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
923 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
924
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
925 title = Qnil;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
926 GCPRO1 (title);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
927
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
928 /* Decode the dialog items from what was specified. */
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
929 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
930 /* We were given an old-fashioned menu. */
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
931 title = Fcar (menu);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
932 CHECK_STRING (title, 1);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
933
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
934 list_of_panes (Fcdr (menu));
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
935
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
936 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
937 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
938
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
939 if (NILP (position))
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
940 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
941 discard_menu_items ();
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
942 UNGCPRO;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
943 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
944 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
945
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
946 /* Display them in a dialog box. */
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
947 BLOCK_INPUT;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
948
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
949 selection = xdialog_show (f, xpos, ypos, menubarp,
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
950 keymaps, title, &error_name);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
951 UNBLOCK_INPUT;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
952
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
953 discard_menu_items ();
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
954
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
955 UNGCPRO;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
956
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
957 if (error_name) error (error_name);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
958 return selection;
6325
d6817c9c0413 Undo previous change. Instead:
Richard M. Stallman <rms@gnu.org>
parents: 6324
diff changeset
959 #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
960 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
961
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
962 #ifdef USE_X_TOOLKIT
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
963
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
964 static void
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
965 dispatch_dummy_expose (w, x, y)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
966 Widget w;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
967 int x;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
968 int y;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
969 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
970 XExposeEvent dummy;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
971
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
972 dummy.type = Expose;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
973 dummy.window = XtWindow (w);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
974 dummy.count = 0;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
975 dummy.serial = 0;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
976 dummy.send_event = 0;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
977 dummy.display = XtDisplay (w);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
978 dummy.x = x;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
979 dummy.y = y;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
980
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
981 XtDispatchEvent (&dummy);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
982 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
983
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
984 static int
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
985 string_width (mw, s)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
986 XlwMenuWidget mw;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
987 char* s;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
988 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
989 XCharStruct xcs;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
990 int drop;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
991
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
992 XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
993 return xcs.width;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
994 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
995
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
996 static int
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
997 event_is_in_menu_item (mw, event, name, string_w)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
998 XlwMenuWidget mw;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
999 struct input_event *event;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1000 char *name;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1001 int *string_w;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1002 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1003 *string_w += (string_width (mw, name)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1004 + 2 * (mw->menu.horizontal_spacing
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1005 + mw->menu.shadow_thickness));
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1006 return XINT (event->x) < *string_w;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1007 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1008
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1009
6172
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1010 /* Return the menu bar key which corresponds to event EVENT in frame F. */
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1011
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1012 Lisp_Object
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1013 map_event_to_object (event, f)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1014 struct input_event *event;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1015 FRAME_PTR f;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1016 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1017 int i,j, string_w;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1018 window_state* ws;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1019 XlwMenuWidget mw = (XlwMenuWidget) f->display.x->menubar_widget;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1020 widget_value *val;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1021
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1022
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1023 string_w = 0;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1024 /* Find the window */
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1025 for (val = mw->menu.old_stack [0]->contents; val; val = val->next)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1026 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1027 ws = &mw->menu.windows [0];
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1028 if (ws && event_is_in_menu_item (mw, event, val->name, &string_w))
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1029 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1030 Lisp_Object items;
6172
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1031 int i;
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1032
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1033 items = FRAME_MENU_BAR_ITEMS (f);
6172
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1034
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1035 for (i = 0; i < XVECTOR (items)->size; i += 3)
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1036 {
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1037 Lisp_Object pos, string, item;
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1038 item = XVECTOR (items)->contents[i];
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1039 string = XVECTOR (items)->contents[i + 1];
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1040 pos = XVECTOR (items)->contents[i + 2];
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1041 if (NILP (string))
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1042 break;
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1043
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1044 if (!strcmp (val->name, XSTRING (string)->data))
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1045 return item;
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1046 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1047 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1048 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1049 return Qnil;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1050 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1051
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1052 static Lisp_Object *menu_item_selection;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1053
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1054 static void
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1055 popup_selection_callback (widget, id, client_data)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1056 Widget widget;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1057 LWLIB_ID id;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1058 XtPointer client_data;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1059 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1060 menu_item_selection = (Lisp_Object *) client_data;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1061 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1062
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1063 static void
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1064 popup_down_callback (widget, id, client_data)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1065 Widget widget;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1066 LWLIB_ID id;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1067 XtPointer client_data;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1068 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1069 BLOCK_INPUT;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1070 lw_destroy_all_widgets (id);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1071 UNBLOCK_INPUT;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1072 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1073
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1074 static void
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1075 dialog_selection_callback (widget, id, client_data)
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1076 Widget widget;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1077 LWLIB_ID id;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1078 XtPointer client_data;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1079 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1080 if ((int)client_data != -1)
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1081 menu_item_selection = (Lisp_Object *) client_data;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1082 BLOCK_INPUT;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1083 lw_destroy_all_widgets (id);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1084 UNBLOCK_INPUT;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1085 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1086
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1087 /* This recursively calls free_widget_value() on the tree of widgets.
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1088 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
1089 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
1090 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
1091
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1092 void
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1093 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
1094 widget_value *wv;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1095 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1096 if (! wv) return;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1097
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1098 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
1099
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1100 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
1101 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1102 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
1103 wv->contents = (widget_value *) 0xDEADBEEF;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1104 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1105 if (wv->next)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1106 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1107 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
1108 wv->next = (widget_value *) 0xDEADBEEF;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1109 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1110 BLOCK_INPUT;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1111 free_widget_value (wv);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1112 UNBLOCK_INPUT;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1113 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1114
6200
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1115 extern void EmacsFrameSetCharSize ();
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1116
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1117 static void
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1118 update_one_frame_psheets (f)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1119 FRAME_PTR f;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1120 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1121 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
1122 int columns, rows;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1123 int menubar_changed;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1124
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1125 menubar_changed = (x->menubar_widget
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1126 && !XtIsManaged (x->menubar_widget));
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1127
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1128 if (! (menubar_changed))
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1129 return;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1130
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1131 BLOCK_INPUT;
6200
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1132 /* 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
1133 resize itself. So force it. */
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1134 columns = f->width;
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1135 rows = f->height;
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1136
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1137
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1138 XawPanedSetRefigureMode (x->column_widget, 0);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1139
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1140 /* 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
1141 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
1142 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
1143 */
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1144 XtUnmanageChild (x->edit_widget);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1145
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1146 /* 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
1147 should be there.
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1148 */
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1149 if (menubar_changed)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1150 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1151 XtManageChild (x->menubar_widget);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1152 XtMapWidget (x->menubar_widget);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1153 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
1154 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1155
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1156
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1157 /* Re-manage the text-area widget */
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1158 XtManageChild (x->edit_widget);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1159
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1160 /* and now thrash the sizes */
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1161 XawPanedSetRefigureMode (x->column_widget, 1);
6200
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1162
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1163 /* 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
1164 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
1165
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1166 UNBLOCK_INPUT;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1167 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1168
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1169 void
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1170 set_frame_menubar (f)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1171 FRAME_PTR f;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1172 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1173 Widget menubar_widget = f->display.x->menubar_widget;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1174 int id = (int) f;
6172
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1175 Lisp_Object tail, items;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1176 widget_value *wv, *save_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
1177 int i;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1178
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1179 BLOCK_INPUT;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1180
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1181 wv = malloc_widget_value ();
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1182 wv->name = "menubar";
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1183 wv->value = 0;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1184 wv->enabled = 1;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1185 save_wv = first_wv = wv;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1186
6172
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1187 items = FRAME_MENU_BAR_ITEMS (f);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1188
6172
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1189 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
1190 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1191 Lisp_Object string;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1192
6172
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1193 string = XVECTOR (items)->contents[i + 1];
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1194 if (NILP (string))
57d031171fa2 (map_event_to_object, set_frame_menubar):
Richard M. Stallman <rms@gnu.org>
parents: 6115
diff changeset
1195 break;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1196
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1197 wv = malloc_widget_value ();
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1198 if (prev_wv)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1199 prev_wv->next = wv;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1200 else
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1201 save_wv->contents = wv;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1202 wv->name = XSTRING (string)->data;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1203 wv->value = 0;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1204 wv->enabled = 1;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1205 prev_wv = wv;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1206 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1207
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1208 if (menubar_widget)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1209 lw_modify_all_widgets (id, first_wv, False);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1210 else
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1211 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1212 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
1213 id, first_wv,
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1214 f->display.x->column_widget,
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1215 0, 0,
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1216 0, 0);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1217 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
1218 XtVaSetValues (menubar_widget,
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1219 XtNshowGrip, 0,
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1220 XtNresizeToPreferred, 1,
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1221 XtNallowResize, 1,
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1222 0);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1223 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1224
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1225 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
1226
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1227 update_one_frame_psheets (f);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1228
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1229 UNBLOCK_INPUT;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1230 }
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
1231
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
1232 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
1233 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
1234 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
1235 {
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
1236 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
1237 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
1238
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
1239 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
1240 id = (int) 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
1241
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
1242 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
1243 {
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
1244 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
1245 lw_destroy_all_widgets (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
1246 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
1247 }
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
1248 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1249
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1250 /* Nonzero if position X, Y relative to inside of frame F
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1251 is in some other menu bar item. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1252
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1253 static int this_menu_bar_item_beg;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1254 static int this_menu_bar_item_end;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1255
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1256 static int
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1257 other_menu_bar_item_p (f, x, y)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1258 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
1259 int x, y;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1260 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1261 return (y >= 0
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1262 && y < f->display.x->menubar_widget->core.height
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1263 && x >= 0
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1264 && x < f->display.x->menubar_widget->core.width
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1265 && (x >= this_menu_bar_item_end
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1266 || x < this_menu_bar_item_beg));
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1267 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1268
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1269 /* Unread a button-press event in the menu bar of frame F
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1270 at x position XPOS relative to the inside of the frame. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1271
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1272 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1273 unread_menu_bar_button (f, xpos)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1274 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
1275 int xpos;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1276 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1277 XEvent event;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1278
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1279 event.type = ButtonPress;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1280 event.xbutton.display = x_current_display;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1281 event.xbutton.serial = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1282 event.xbutton.send_event = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1283 event.xbutton.time = CurrentTime;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1284 event.xbutton.button = Button1;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1285 event.xbutton.window = XtWindow (f->display.x->menubar_widget);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1286 event.xbutton.x = xpos;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1287 XPutBackEvent (XDISPLAY &event);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1288 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1289
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1290 /* If the mouse has moved to another menu bar item,
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1291 return 1 and unread a button press event for that item.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1292 Otherwise return 0. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1293
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1294 static int
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1295 check_mouse_other_menu_bar (f)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1296 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
1297 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1298 FRAME_PTR new_f;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1299 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
1300 int part;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1301 Lisp_Object x, y;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1302 unsigned long time;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1303
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1304 (*mouse_position_hook) (&new_f, &bar_window, &part, &x, &y, &time);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1305
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1306 if (f == new_f && other_menu_bar_item_p (f, x, y))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1307 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1308 unread_menu_bar_button (f, x);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1309 return 1;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1310 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1311
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1312 return 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1313 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1314 #endif /* USE_X_TOOLKIT */
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1315
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1316 /* 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
1317 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
1318 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
1319 Both assume input is blocked by the caller. */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1320
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1321 /* 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
1322 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
1323 relative to the inside upper left corner of the frame F.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1324 MENUBARP is 1 if the click that asked for this menu came from the menu bar.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1325 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
1326 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
1327 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
1328 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
1329 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
1330 (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
1331
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1332 #ifdef USE_X_TOOLKIT
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1333
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1334 extern unsigned int x_mouse_grabbed;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1335 extern Lisp_Object Vmouse_depressed;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1336
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1337 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
1338 xmenu_show (f, x, y, menubarp, keymaps, title, error)
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1339 FRAME_PTR f;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1340 int x;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1341 int y;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1342 int menubarp;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1343 int keymaps;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1344 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
1345 char **error;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1346 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1347 int i;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1348 int menu_id;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1349 Widget menu;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1350 XlwMenuWidget menubar = (XlwMenuWidget) f->display.x->menubar_widget;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1351
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1352 /* This is the menu bar item (if any) that led to this menu. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1353 widget_value *menubar_item = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1354
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1355 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
1356 widget_value **submenu_stack
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1357 = (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
1358 Lisp_Object *subprefix_stack
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1359 = (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
1360 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
1361
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1362 /* 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
1363 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
1364 struct event_queue
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1365 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1366 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
1367 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
1368 };
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1369
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1370 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
1371 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
1372
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1373 *error = NULL;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1374
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1375 this_menu_bar_item_beg = -1;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1376 this_menu_bar_item_end = -1;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1377
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1378 /* Figure out which menu bar item, if any, this 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
1379 if (menubarp)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1380 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1381 int xbeg;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1382 int xend = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1383
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1384 for (menubar_item = menubar->menu.old_stack[0]->contents;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1385 menubar_item;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1386 menubar_item = menubar_item->next)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1387 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1388 xbeg = xend;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1389 xend += (string_width (menubar, menubar_item->name)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1390 + 2 * (menubar->menu.horizontal_spacing
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1391 + menubar->menu.shadow_thickness));
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1392 if (x < xend)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1393 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1394 x = xbeg + 4;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1395 y = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1396 /* Arrange to show a different menu if we move in the menu bar
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1397 to a different item. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1398 this_menu_bar_item_beg = xbeg;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1399 this_menu_bar_item_end = xend;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1400 break;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1401 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1402 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1403 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1404 if (menubar_item == 0)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1405 menubarp = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1406
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1407 /* Offset the coordinates to root-relative. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1408 x += (f->display.x->widget->core.x
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1409 + f->display.x->widget->core.border_width);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1410 y += (f->display.x->widget->core.y
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1411 + f->display.x->widget->core.border_width
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1412 + f->display.x->menubar_widget->core.height);
5896
b20145eafe0c (xmenu_show) [USE_X_TOOLKIT]: return Qnil when val is null.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5881
diff changeset
1413
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1414 /* 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
1415 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
1416 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
1417 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
1418 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
1419 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
1420 first_wv = wv;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1421
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1422 /* 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
1423 i = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1424 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
1425 {
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1426 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
1427 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1428 submenu_stack[submenu_depth++] = save_wv;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1429 save_wv = prev_wv;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1430 prev_wv = 0;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1431 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1432 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1433 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
1434 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1435 prev_wv = save_wv;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1436 save_wv = submenu_stack[--submenu_depth];
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1437 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1438 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1439 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
1440 && submenu_depth != 0)
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1441 i += MENU_ITEMS_PANE_LENGTH;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1442 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
1443 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1444 /* 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
1445 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
1446 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
1447 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
1448 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
1449 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
1450 ? "" : (char *) XSTRING (pane_name)->data);
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1451 /* 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
1452 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
1453 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
1454 pane_string = "";
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1455
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1456 /* 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
1457 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
1458 with its items as a submenu beneath it. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1459 if (strcmp (pane_string, ""))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1460 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1461 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
1462 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
1463 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
1464 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1465 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
1466 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
1467 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
1468 wv->name++;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1469 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
1470 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
1471 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1472 save_wv = wv;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1473 prev_wv = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1474 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
1475 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1476 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1477 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1478 /* 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
1479 Lisp_Object item_name, enable, descrip;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1480 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
1481 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
1482 descrip
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1483 = 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
1484
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1485 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
1486 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
1487 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
1488 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1489 save_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
1490 wv->name = XSTRING (item_name)->data;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1491 if (!NILP (descrip))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1492 wv->key = XSTRING (descrip)->data;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1493 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
1494 wv->call_data = (void *) &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
1495 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
1496 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
1497
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1498 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
1499 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1500 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1501
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1502 /* Actually create the menu. */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1503 menu_id = ++popup_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
1504 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
1505 f->display.x->widget, 1, 0,
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1506 popup_selection_callback, popup_down_callback);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1507 /* 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
1508 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
1509
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1510 /* 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
1511 menu_item_selection = 0;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1512
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1513 /* If the mouse moves out of the menu before we show the menu,
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1514 don't show it at all. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1515 if (check_mouse_other_menu_bar (f))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1516 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1517 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
1518 return Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1519 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1520
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1521
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1522 /* Highlight the menu bar item (if any) that led to this menu. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1523 if (menubarp)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1524 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1525 menubar_item->call_data = (XtPointer) 1;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1526 dispatch_dummy_expose (f->display.x->menubar_widget, x, y);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1527 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1528
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1529 /* Display the menu. */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1530 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1531 XButtonPressedEvent dummy;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1532 XlwMenuWidget mw;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1533
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1534 mw = (XlwMenuWidget) ((CompositeWidget)menu)->composite.children[0];
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1535
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1536 dummy.type = ButtonPress;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1537 dummy.serial = 0;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1538 dummy.send_event = 0;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1539 dummy.display = XtDisplay (menu);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1540 dummy.window = XtWindow (XtParent (menu));
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1541 dummy.time = CurrentTime;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1542 dummy.button = 0;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1543 dummy.x_root = x;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1544 dummy.y_root = y;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1545
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1546 /* We activate directly the lucid implementation. */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1547 pop_up_menu (mw, &dummy);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1548 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1549
6200
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1550 /* No need to check a second time since this is done in the XEvent loop.
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1551 This slows done the execution. */
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1552 #if 0
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1553 /* Check again whether the mouse has moved to another menu bar item. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1554 if (check_mouse_other_menu_bar (f))
5865
8dc616f310e8 (xmenu_show ) [USE_X_TOOLKIT]: Implement a Motif behavior for the menubar. Now,
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5809
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 /* The mouse moved into a different menu bar item.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1557 We should bring up that item's menu instead.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1558 First pop down this menu. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1559 XtUngrabPointer ((Widget)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1560 ((XlwMenuWidget)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1561 ((CompositeWidget)menu)->composite.children[0]),
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1562 CurrentTime);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1563 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
1564 goto pop_down;
5865
8dc616f310e8 (xmenu_show ) [USE_X_TOOLKIT]: Implement a Motif behavior for the menubar. Now,
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5809
diff changeset
1565 }
6200
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
1566 #endif
5865
8dc616f310e8 (xmenu_show ) [USE_X_TOOLKIT]: Implement a Motif behavior for the menubar. Now,
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5809
diff changeset
1567
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1568 /* Process events that apply to the menu. */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1569 while (1)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1570 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1571 XEvent event;
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 XtAppNextEvent (Xt_app_con, &event);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1574 if (event.type == ButtonRelease)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1575 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1576 XtDispatchEvent (&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
1577 if (! menubarp)
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1578 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1579 /* Do the work of construct_mouse_click since it can't
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1580 be called. Initially, the popup menu has been called
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1581 from a ButtonPress in the edit_widget. Then the mouse
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1582 has been set to grabbed. Reset it now. */
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1583 x_mouse_grabbed &= ~(1 << event.xbutton.button);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1584 if (!x_mouse_grabbed)
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1585 Vmouse_depressed = Qnil;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1586 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1587 break;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1588 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1589 else if (event.type == Expose)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1590 process_expose_from_menu (event);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1591 else if (event.type == MotionNotify)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1592 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1593 int event_x = (event.xmotion.x_root
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1594 - (f->display.x->widget->core.x
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1595 + f->display.x->widget->core.border_width));
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1596 int event_y = (event.xmotion.y_root
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1597 - (f->display.x->widget->core.y
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1598 + f->display.x->widget->core.border_width));
5865
8dc616f310e8 (xmenu_show ) [USE_X_TOOLKIT]: Implement a Motif behavior for the menubar. Now,
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5809
diff changeset
1599
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1600 if (other_menu_bar_item_p (f, event_x, event_y))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1601 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1602 /* The mouse moved into a different menu bar item.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1603 We should bring up that item's menu instead.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1604 First pop down this menu. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1605 XtUngrabPointer ((Widget)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1606 ((XlwMenuWidget)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1607 ((CompositeWidget)menu)->composite.children[0]),
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1608 event.xbutton.time);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1609 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
1610
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1611 /* Put back an event that will bring up the other item's menu. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1612 unread_menu_bar_button (f, event_x);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1613 /* Don't let us select anything in this case. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1614 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
1615 break;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1616 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1617 }
5865
8dc616f310e8 (xmenu_show ) [USE_X_TOOLKIT]: Implement a Motif behavior for the menubar. Now,
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5809
diff changeset
1618
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1619 XtDispatchEvent (&event);
6198
d941186e8fb9 [USE_X_TOOLKIT] (xmenu_show): Pass display to XtWindowToWidget.
Roland McGrath <roland@gnu.org>
parents: 6172
diff changeset
1620 if (XtWindowToWidget(XDISPLAY event.xany.window) != menu)
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1621 {
6198
d941186e8fb9 [USE_X_TOOLKIT] (xmenu_show): Pass display to XtWindowToWidget.
Roland McGrath <roland@gnu.org>
parents: 6172
diff changeset
1622 queue_tmp
d941186e8fb9 [USE_X_TOOLKIT] (xmenu_show): Pass display to XtWindowToWidget.
Roland McGrath <roland@gnu.org>
parents: 6172
diff changeset
1623 = (struct event_queue *) malloc (sizeof (struct event_queue));
6115
e3d6c30a3906 (xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6058
diff changeset
1624
e3d6c30a3906 (xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6058
diff changeset
1625 if (queue_tmp != NULL)
e3d6c30a3906 (xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6058
diff changeset
1626 {
e3d6c30a3906 (xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6058
diff changeset
1627 queue_tmp->event = event;
e3d6c30a3906 (xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6058
diff changeset
1628 queue_tmp->next = queue;
e3d6c30a3906 (xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6058
diff changeset
1629 queue = queue_tmp;
e3d6c30a3906 (xmenu_show): Test XtWindowToWidget before inserting into the event_queue.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6058
diff changeset
1630 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1631 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1632 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1633
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1634 pop_down:
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1635 /* Unhighlight the menu bar item (if any) that led to this menu. */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1636 if (menubarp)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1637 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1638 menubar_item->call_data = (XtPointer) 0;
5775
07a36e38e514 (xmenu_show) [USE_X_TOOLKIT]: Remove the #if 0 directives and reverse one to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5673
diff changeset
1639 dispatch_dummy_expose (f->display.x->menubar_widget, x, y);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1640 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1641
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1642 #if 0 /* No need to do that. The menu has disappeared. */
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1643 /* 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
1644 lw_destroy_all_widgets (menu_id);
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1645 #endif
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1646
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1647 /* 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
1648 while (queue != NULL)
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1649 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1650 queue_tmp = queue;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1651 XPutBackEvent (XDISPLAY &queue_tmp->event);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1652 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
1653 free ((char *)queue_tmp);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1654 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1655
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1656 /* 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
1657 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
1658 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
1659 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1660 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
1661
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1662 prefix = Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1663 i = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1664 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
1665 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1666 Lisp_Object entry;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1667
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1668 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
1669 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1670 subprefix_stack[submenu_depth++] = prefix;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1671 prefix = entry;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1672 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1673 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1674 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
1675 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1676 prefix = subprefix_stack[--submenu_depth];
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1677 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1678 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1679 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
1680 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1681 prefix
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1682 = 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
1683 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
1684 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1685 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1686 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1687 entry
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1688 = 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
1689 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
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 (keymaps != 0)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1692 {
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1693 int j;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1694
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1695 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
1696 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
1697 entry = Fcons (prefix, entry);
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1698 for (j = submenu_depth - 1; j >= 0; j--)
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1699 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
1700 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1701 return entry;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1702 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1703 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
1704 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1705 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1706 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1707
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1708 return Qnil;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1709 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1710
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1711 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
1712 "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
1713 "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
1714
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1715 static Lisp_Object
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1716 xdialog_show (f, x, y, menubarp, keymaps, title, error)
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1717 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
1718 int x;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1719 int y;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1720 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
1721 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
1722 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
1723 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
1724 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1725 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
1726 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
1727 Widget menu;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1728 XlwMenuWidget menubar = (XlwMenuWidget) f->display.x->menubar_widget;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1729
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1730 /* This is the menu bar item (if any) that led to this menu. */
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1731 widget_value *menubar_item = 0;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1732
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1733 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
1734
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1735 /* 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
1736 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
1737 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
1738 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1739 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
1740 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
1741 };
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1742
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1743 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
1744 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
1745
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1746 *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
1747
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1748 /* 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
1749 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
1750 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1751 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
1752 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
1753 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
1754 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
1755 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
1756 ? "" : (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
1757 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
1758 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
1759 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
1760 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
1761 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
1762 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
1763 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
1764
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1765 /* 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
1766 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
1767 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
1768 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1769
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1770 /* 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
1771 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
1772 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
1773 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
1774 descrip
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1775 = 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
1776
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1777 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
1778 prev_wv->next = wv;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1779 wv->name = (char *) button_names [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
1780 if (!NILP (descrip))
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1781 wv->key = XSTRING (descrip)->data;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1782 wv->value = XSTRING (item_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
1783 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
1784 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
1785 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
1786
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1787 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
1788 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
1789 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1790
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1791 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
1792 wv->name = "Q2BR1";
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1793 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
1794 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
1795
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1796 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1797
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1798 /* Actually create the dialog. */
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1799 dialog_id = ++popup_id_tick;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1800 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
1801 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
1802 dialog_selection_callback, 0);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1803 lw_modify_all_widgets (dialog_id, first_wv, True);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1804 lw_modify_all_widgets (dialog_id, first_wv->contents, True);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1805 /* 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
1806 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
1807
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1808 /* 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
1809 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
1810
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1811
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1812 /* 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
1813 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
1814
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1815 /* 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
1816 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
1817 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1818 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
1819
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1820 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
1821 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
1822 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1823 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
1824 break;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1825 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1826 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
1827 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
1828 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
1829 if (XtWindowToWidget(XDISPLAY event.xany.window) != menu)
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1830 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1831 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
1832
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1833 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
1834 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1835 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
1836 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
1837 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
1838 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1839 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1840 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1841 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
1842
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1843 /* 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
1844 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
1845 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1846 queue_tmp = queue;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1847 XPutBackEvent (XDISPLAY &queue_tmp->event);
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1848 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
1849 free ((char *)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
1850 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1851
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1852 /* 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
1853 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
1854 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
1855 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1856 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
1857
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1858 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
1859 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
1860 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
1861 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1862 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
1863
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1864 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
1865 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1866 prefix
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1867 = 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
1868 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
1869 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1870 else
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1871 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1872 entry
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1873 = 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
1874 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
1875 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1876 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
1877 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1878 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
1879 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
1880 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
1881 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1882 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
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 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
1885 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1886 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1887 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1888
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1889 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
1890 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1891 #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
1892
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1893 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
1894 xmenu_show (f, x, y, menubarp, keymaps, title, error)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1895 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
1896 int x, y;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1897 int keymaps;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1898 int menubarp;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1899 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
1900 char **error;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1901 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1902 Window root;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1903 XMenu *menu;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1904 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
1905 Lisp_Object entry, pane_prefix;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1906 char *datap;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1907 int ulx, uly, width, height;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1908 int dispwidth, dispheight;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1909 int i;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1910 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
1911 unsigned int dummy_uint;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
1912
3747
6506b2fd475a (xmenu_show): Store 0 in *ERROR at the beginning.
Richard M. Stallman <rms@gnu.org>
parents: 3501
diff changeset
1913 *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
1914 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
1915 return Qnil;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
1916
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1917 /* Figure out which root window F is on. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1918 XGetGeometry (x_current_display, FRAME_X_WINDOW (f), &root,
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1919 &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
1920 &dummy_uint, &dummy_uint);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1921
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1922 /* Make the menu on that window. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1923 menu = XMenuCreate (XDISPLAY root, "emacs");
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1924 if (menu == NULL)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1925 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1926 *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
1927 return Qnil;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1928 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1929
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1930 /* 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
1931 #ifdef HAVE_X11
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1932 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1933 Window child;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1934 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
1935
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1936 /* 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
1937 the inner window, with respect to the outer window. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1938 if (f->display.x->parent_desc != ROOT_WINDOW)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1939 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1940 BLOCK_INPUT;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1941 XTranslateCoordinates (x_current_display,
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1942
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1943 /* 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
1944 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
1945 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
1946
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1947 /* 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
1948 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
1949
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1950 /* 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
1951 &child);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1952 UNBLOCK_INPUT;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1953 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
1954 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
1955 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1956 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1957 #endif /* HAVE_X11 */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1958
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1959 /* 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
1960 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
1961 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
1962
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1963 /* 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
1964 i = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1965 while (i < menu_items_used)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1966 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1967 if (EQ (XVECTOR (menu_items)->contents[i], Qt))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1968 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1969 /* 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
1970 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
1971 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
1972
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1973 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
1974 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
1975 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
1976 ? "" : (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
1977 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
1978 pane_string++;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1979
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1980 lpane = XMenuAddPane (XDISPLAY menu, pane_string, TRUE);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1981 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
1982 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1983 XMenuDestroy (XDISPLAY menu);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1984 *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
1985 return Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1986 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1987 i += MENU_ITEMS_PANE_LENGTH;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1988 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1989 else
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1990 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1991 /* 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
1992 Lisp_Object item_name, enable, descrip;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1993
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1994 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
1995 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
1996 descrip
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1997 = 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
1998 if (!NILP (descrip))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1999 item_name = concat2 (item_name, descrip);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2000
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2001 if (XMenuAddSelection (XDISPLAY menu, lpane, 0,
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2002 XSTRING (item_name)->data,
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2003 !NILP (enable))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2004 == XM_FAILURE)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2005 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2006 XMenuDestroy (XDISPLAY menu);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2007 *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
2008 return Qnil;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2009 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2010 i += MENU_ITEMS_ITEM_LENGTH;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2011 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2012 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2013
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2014 /* All set and ready to fly. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2015 XMenuRecompute (XDISPLAY menu);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2016 dispwidth = DisplayWidth (x_current_display, XDefaultScreen (x_current_display));
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2017 dispheight = DisplayHeight (x_current_display, XDefaultScreen (x_current_display));
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2018 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
2019 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
2020 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
2021 y = max (y, 1);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2022 XMenuLocate (XDISPLAY menu, 0, 0, x, y,
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2023 &ulx, &uly, &width, &height);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2024 if (ulx+width > dispwidth)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2025 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2026 x -= (ulx + width) - dispwidth;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2027 ulx = dispwidth - width;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2028 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2029 if (uly+height > dispheight)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2030 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2031 y -= (uly + height) - dispheight;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2032 uly = dispheight - height;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2033 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2034 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
2035 if (uly < 0) y -= uly;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2036
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2037 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
2038 pane = selidx = 0;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2039
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2040 status = XMenuActivate (XDISPLAY menu, &pane, &selidx,
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2041 x, y, ButtonReleaseMask, &datap);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2042 switch (status)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2043 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2044 case XM_SUCCESS:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2045 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2046 fprintf (stderr, "pane= %d line = %d\n", panes, selidx);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2047 #endif
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2048
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2049 /* 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
2050 i = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2051 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
2052 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2053 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
2054 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2055 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
2056 pane_prefix
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2057 = 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
2058 pane--;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2059 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
2060 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2061 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2062 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2063 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
2064 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2065 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
2066 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2067 entry
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2068 = 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
2069 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
2070 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2071 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
2072 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
2073 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
2074 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2075 break;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2076 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2077 selidx--;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2078 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2079 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
2080 }
2747
f258c79c9162 (Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents: 2514
diff changeset
2081 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2082 break;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2083
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2084 case XM_FAILURE:
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2085 XMenuDestroy (XDISPLAY menu);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2086 *error = "Can't activate menu";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2087 case XM_IA_SELECT:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2088 case XM_NO_SELECT:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2089 entry = Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2090 break;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2091 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2092 XMenuDestroy (XDISPLAY menu);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2093 return entry;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2094 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2095 #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
2096
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2097 syms_of_xmenu ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2098 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2099 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
2100 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
2101
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2102 popup_id_tick = (1<<16);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2103 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
2104 defsubr (&Sx_popup_dialog);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2105 }