annotate src/xmenu.c @ 109440:f8f118e78387

* xmenu.c (create_and_show_popup_menu, xmenu_show): Fix type of timestamp argument.
author Andreas Schwab <schwab@linux-m68k.org>
date Thu, 15 Jul 2010 23:53:32 +0200
parents a4e57fa6eb3f
children 6c14b478b70f
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.
64770
a0d1312ede66 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64084
diff changeset
2 Copyright (C) 1986, 1988, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2003,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106057
diff changeset
3 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 This file is part of GNU Emacs.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94005
diff changeset
7 GNU Emacs is free software: you can redistribute it and/or modify
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94005
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94005
diff changeset
10 (at your option) any later version.
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 GNU General Public License for more details.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94005
diff changeset
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
40239
5fda2888718a Spell the name of Emacs properly (GNU Emacs instead of gnuemacs).
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
20 /* X pop-up deck-of-cards menu facility for GNU Emacs.
118
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
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26036
diff changeset
32 #include <config.h>
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26036
diff changeset
33
62216
0c2ce5566afa Don't include signal.h.
Richard M. Stallman <rms@gnu.org>
parents: 62090
diff changeset
34 #if 0 /* Why was this included? And without syssignal.h? */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 /* On 4.3 this loses if it comes after xterm.h. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 #include <signal.h>
62216
0c2ce5566afa Don't include signal.h.
Richard M. Stallman <rms@gnu.org>
parents: 62090
diff changeset
37 #endif
7900
60795e826dad Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents: 7871
diff changeset
38
60795e826dad Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents: 7871
diff changeset
39 #include <stdio.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 102628
diff changeset
40 #include <setjmp.h>
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39914
diff changeset
41
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 #include "lisp.h"
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32179
diff changeset
43 #include "keyboard.h"
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
44 #include "keymap.h"
770
4de9c9a62bda entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
45 #include "frame.h"
83004
7900111db01c Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents: 53325
diff changeset
46 #include "termhooks.h"
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 #include "window.h"
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2209
diff changeset
48 #include "blockinput.h"
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
49 #include "buffer.h"
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
50 #include "charset.h"
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
51 #include "coding.h"
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
52 #include "sysselect.h"
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53
10502
1b08df5c5e4a [MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents: 10167
diff changeset
54 #ifdef MSDOS
1b08df5c5e4a [MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents: 10167
diff changeset
55 #include "msdos.h"
1b08df5c5e4a [MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents: 10167
diff changeset
56 #endif
1b08df5c5e4a [MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents: 10167
diff changeset
57
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9546
diff changeset
58 #ifdef HAVE_X_WINDOWS
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 /* This may include sys/types.h, and that somehow loses
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 if this is not done before the other system files. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 #include "xterm.h"
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9546
diff changeset
62 #endif
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 /* Load sys/types.h if not already loaded.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 In some systems loading it twice is suicidal. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 #ifndef makedev
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 #include <sys/types.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 #include "dispextern.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9546
diff changeset
72 #ifdef HAVE_X_WINDOWS
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
73 /* Defining HAVE_MULTILINGUAL_MENU would mean that the toolkit menu
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
74 code accepts the Emacs internal encoding. */
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
75 #undef HAVE_MULTILINGUAL_MENU
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
76 #ifdef USE_X_TOOLKIT
36958
0b580e75db8c Include widget.h only if USE_X_TOOLKIT is defined.
Eli Zaretskii <eliz@gnu.org>
parents: 36938
diff changeset
77 #include "widget.h"
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
78 #include <X11/Xlib.h>
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
79 #include <X11/IntrinsicP.h>
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
80 #include <X11/CoreP.h>
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
81 #include <X11/StringDefs.h>
8414
8a8d2cdd4218 (xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents: 8269
diff changeset
82 #include <X11/Shell.h>
13489
ddf90bfd3744 Don't include Xaw/Paned.h unless USE_LUCID is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13071
diff changeset
83 #ifdef USE_LUCID
107804
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
84 #include "xsettings.h"
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
85 #include "../lwlib/xlwmenu.h"
81370
a5376379eaae Link to xaw3d if available.
Chong Yidong <cyd@stupidchicken.com>
parents: 81273
diff changeset
86 #ifdef HAVE_XAW3D
a5376379eaae Link to xaw3d if available.
Chong Yidong <cyd@stupidchicken.com>
parents: 81273
diff changeset
87 #include <X11/Xaw3d/Paned.h>
a5376379eaae Link to xaw3d if available.
Chong Yidong <cyd@stupidchicken.com>
parents: 81273
diff changeset
88 #else /* !HAVE_XAW3D */
11898
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
89 #include <X11/Xaw/Paned.h>
81370
a5376379eaae Link to xaw3d if available.
Chong Yidong <cyd@stupidchicken.com>
parents: 81273
diff changeset
90 #endif /* HAVE_XAW3D */
13489
ddf90bfd3744 Don't include Xaw/Paned.h unless USE_LUCID is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13071
diff changeset
91 #endif /* USE_LUCID */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
92 #include "../lwlib/lwlib.h"
10167
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
93 #else /* not USE_X_TOOLKIT */
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
94 #ifndef USE_GTK
10167
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
95 #include "../oldXMenu/XMenu.h"
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
96 #endif
10167
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
97 #endif /* not USE_X_TOOLKIT */
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
98 #endif /* HAVE_X_WINDOWS */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
99
96608
127e54f8220e * menu.h: New file.
Andreas Schwab <schwab@suse.de>
parents: 95730
diff changeset
100 #ifdef USE_GTK
127e54f8220e * menu.h: New file.
Andreas Schwab <schwab@suse.de>
parents: 95730
diff changeset
101 #include "gtkutil.h"
127e54f8220e * menu.h: New file.
Andreas Schwab <schwab@suse.de>
parents: 95730
diff changeset
102 #endif
127e54f8220e * menu.h: New file.
Andreas Schwab <schwab@suse.de>
parents: 95730
diff changeset
103
127e54f8220e * menu.h: New file.
Andreas Schwab <schwab@suse.de>
parents: 95730
diff changeset
104 #include "menu.h"
127e54f8220e * menu.h: New file.
Andreas Schwab <schwab@suse.de>
parents: 95730
diff changeset
105
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 #ifndef TRUE
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 #define TRUE 1
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 #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
109 #endif /* no TRUE */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110
12625
e2831d2f5b09 (syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents: 12432
diff changeset
111 Lisp_Object Qdebug_on_next_call;
e2831d2f5b09 (syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents: 12432
diff changeset
112
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
113 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
114
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
115 extern Lisp_Object QCtoggle, QCradio;
12298
7c4b729e4b21 (menu_item_equiv_key): Do reconsider a command that had
Richard M. Stallman <rms@gnu.org>
parents: 12196
diff changeset
116
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
117 extern Lisp_Object Voverriding_local_map;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
118 extern Lisp_Object Voverriding_local_map_menu_flag;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
119
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
120 extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
121
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
122 extern Lisp_Object Qmenu_bar_update_hook;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
123
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
124 #ifdef USE_X_TOOLKIT
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 109067
diff changeset
125 extern void set_frame_menubar (FRAME_PTR, int, int);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
126 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
127
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 109067
diff changeset
128 static Lisp_Object xdialog_show (FRAME_PTR, int, Lisp_Object, Lisp_Object,
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 109067
diff changeset
129 char **);
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 109067
diff changeset
130 static void popup_get_selection (XEvent *, struct x_display_info *,
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 109067
diff changeset
131 LWLIB_ID, int);
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
132 #endif /* USE_X_TOOLKIT */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
133
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
134 #ifdef USE_GTK
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 109067
diff changeset
135 extern void set_frame_menubar (FRAME_PTR, int, int);
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 109067
diff changeset
136 static Lisp_Object xdialog_show (FRAME_PTR, int, Lisp_Object, Lisp_Object,
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 109067
diff changeset
137 char **);
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
138 #endif
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
139
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 109067
diff changeset
140 static int update_frame_menubar (struct frame *);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
141
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
142 /* Flag which when set indicates a dialog or menu has been posted by
9236
583bb9211b2b (popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents: 9233
diff changeset
143 Xt on behalf of one of the widget sets. */
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
144 static int popup_activated_flag;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
145
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
146 static int next_menubar_widget_id;
15792
feeb1f7c1cec (pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15785
diff changeset
147
97204
ba4a6844b73c Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 97198
diff changeset
148 /* For NS and NTGUI, these prototypes are defined in keyboard.h. */
ba4a6844b73c Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 97198
diff changeset
149 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 109067
diff changeset
150 extern widget_value *xmalloc_widget_value (void);
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 109067
diff changeset
151 extern widget_value *digest_single_submenu (int, int, int);
97204
ba4a6844b73c Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 97198
diff changeset
152 #endif
ba4a6844b73c Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 97198
diff changeset
153
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
154
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
155 #ifdef USE_X_TOOLKIT
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
156
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
157 /* Return the frame whose ->output_data.x->id equals ID, or 0 if none. */
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
158
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
159 static struct frame *
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
160 menubar_id_to_frame (LWLIB_ID id)
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
161 {
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
162 Lisp_Object tail, frame;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
163 FRAME_PTR f;
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
164
90970
3371fc48749b Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 90951
diff changeset
165 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
166 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25322
diff changeset
167 frame = XCAR (tail);
90970
3371fc48749b Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 90951
diff changeset
168 if (!FRAMEP (frame))
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
169 continue;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
170 f = XFRAME (frame);
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26088
diff changeset
171 if (!FRAME_WINDOW_P (f))
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
172 continue;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
173 if (f->output_data.x->id == id)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
174 return f;
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
175 }
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
176 return 0;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
177 }
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
178
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
179 #endif
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
180
49302
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
181 #ifdef HAVE_X_WINDOWS
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
182 /* Return the mouse position in *X and *Y. The coordinates are window
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
183 relative for the edit window in frame F.
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
184 This is for Fx_popup_menu. The mouse_position_hook can not
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
185 be used for X, as it returns window relative coordinates
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
186 for the window where the mouse is in. This could be the menu bar,
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
187 the scroll bar or the edit window. Fx_popup_menu needs to be
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
188 sure it is the edit window. */
105923
1011707400d3 * menu.c (Fx_popup_menu): Consolidate versions from xmenu.c,
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105903
diff changeset
189 void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
190 mouse_position_for_popup (FRAME_PTR f, int *x, int *y)
49302
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
191 {
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
192 Window root, dummy_window;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
193 int dummy;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
194
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
195 if (! FRAME_X_P (f))
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
196 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
197
49302
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
198 BLOCK_INPUT;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
199
49302
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
200 XQueryPointer (FRAME_X_DISPLAY (f),
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
201 DefaultRootWindow (FRAME_X_DISPLAY (f)),
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
202
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
203 /* The root window which contains the pointer. */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
204 &root,
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
205
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
206 /* Window pointer is on, not used */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
207 &dummy_window,
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
208
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
209 /* The position on that root window. */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
210 x, y,
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
211
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
212 /* x/y in dummy_window coordinates, not used. */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
213 &dummy, &dummy,
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
214
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
215 /* Modifier keys and pointer buttons, about which
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
216 we don't care. */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
217 (unsigned int *) &dummy);
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
218
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
219 UNBLOCK_INPUT;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
220
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
221 /* xmenu_show expects window coordinates, not root window
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
222 coordinates. Translate. */
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
223 *x -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
224 *y -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
49302
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
225 }
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
226
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
227 #endif /* HAVE_X_WINDOWS */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
228
14741
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
229 #ifdef HAVE_MENUS
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
230
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
231 DEFUN ("x-popup-dialog", Fx_popup_dialog, Sx_popup_dialog, 2, 3, 0,
40993
63f97168400b (x-popup-menu): Reindent.
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
232 doc: /* Pop up a dialog box and return user's selection.
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
233 POSITION specifies which frame to use.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
234 This is normally a mouse button event or a window or frame.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
235 If POSITION is t, it means to use the frame the mouse is on.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
236 The dialog box appears in the middle of the specified frame.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
237
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
238 CONTENTS specifies the alternatives to display in the dialog box.
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
239 It is a list of the form (DIALOG ITEM1 ITEM2...).
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
240 Each ITEM is a cons cell (STRING . VALUE).
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
241 The return value is VALUE from the chosen item.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
242
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
243 An ITEM may also be just a string--that makes a nonselectable item.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
244 An ITEM may also be nil--that means to put all preceding items
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
245 on the left of the dialog box and all following items on the right.
62090
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
246 \(By default, approximately half appear on each side.)
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
247
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
248 If HEADER is non-nil, the frame title for the box is "Information",
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
249 otherwise it is "Question".
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
250
62090
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
251 If the user gets rid of the dialog box without making a valid choice,
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
252 for instance using the window manager, then this produces a quit and
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
253 `x-popup-dialog' does not return. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109174
diff changeset
254 (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
255 {
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
256 FRAME_PTR f = NULL;
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
257 Lisp_Object window;
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
258
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
259 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
260
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
261 /* Decode the first argument: find the window or frame to use. */
11907
0f03ad1cac1e (Fx_popup_dialog): Treat (menu-bar) like t, for POSITION.
Karl Heuer <kwzh@gnu.org>
parents: 11898
diff changeset
262 if (EQ (position, Qt)
32179
15fe3fd7b8fc (Fx_popup_menu, Fx_popup_dialog): Check for tool-bar
Dave Love <fx@gnu.org>
parents: 31829
diff changeset
263 || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
15fe3fd7b8fc (Fx_popup_menu, Fx_popup_dialog): Check for tool-bar
Dave Love <fx@gnu.org>
parents: 31829
diff changeset
264 || EQ (XCAR (position), Qtool_bar))))
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
265 {
6653
14a0a3fe93fd (Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents: 6625
diff changeset
266 #if 0 /* Using the frame the mouse is on may not be right. */
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
267 /* Use the mouse's current position. */
25680
841eb01263ef (Fx_popup_menu): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents: 25646
diff changeset
268 FRAME_PTR new_f = SELECTED_FRAME ();
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
269 Lisp_Object bar_window;
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
270 enum scroll_bar_part part;
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
271 unsigned long time;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
272 Lisp_Object x, y;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
273
11125
dc78213dd2b3 (Fx_popup_menu): Pass 1 for `insist' arg.
Richard M. Stallman <rms@gnu.org>
parents: 10835
diff changeset
274 (*mouse_position_hook) (&new_f, 1, &bar_window, &part, &x, &y, &time);
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
275
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
276 if (new_f != 0)
9339
8a59acc95eea (Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents: 9336
diff changeset
277 XSETFRAME (window, new_f);
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
278 else
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
279 window = selected_window;
6653
14a0a3fe93fd (Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents: 6625
diff changeset
280 #endif
11907
0f03ad1cac1e (Fx_popup_dialog): Treat (menu-bar) like t, for POSITION.
Karl Heuer <kwzh@gnu.org>
parents: 11898
diff changeset
281 window = selected_window;
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
282 }
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
283 else if (CONSP (position))
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
284 {
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
285 Lisp_Object tem;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
286 tem = Fcar (position);
9102
7a73653817de (menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents: 8849
diff changeset
287 if (CONSP (tem))
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
288 window = Fcar (Fcdr (position));
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
289 else
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
290 {
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
291 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
292 window = Fcar (tem); /* POSN_WINDOW (tem) */
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
293 }
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
294 }
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
295 else if (WINDOWP (position) || FRAMEP (position))
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
296 window = position;
15807
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
297 else
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
298 window = Qnil;
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
299
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
300 /* Decode where to put the menu. */
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
301
9102
7a73653817de (menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents: 8849
diff changeset
302 if (FRAMEP (window))
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
303 f = XFRAME (window);
9102
7a73653817de (menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents: 8849
diff changeset
304 else if (WINDOWP (window))
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
305 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
306 CHECK_LIVE_WINDOW (window);
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
307 f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
308 }
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
309 else
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
310 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
311 but I don't want to make one now. */
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
312 CHECK_WINDOW (window);
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
313
97645
229acec13840 (Fx_popup_dialog, Fx_popup_menu, xmenu_show): Allow MSDOS frames along with
Eli Zaretskii <eliz@gnu.org>
parents: 97204
diff changeset
314 if (! FRAME_X_P (f) && ! FRAME_MSDOS_P (f))
229acec13840 (Fx_popup_dialog, Fx_popup_menu, xmenu_show): Allow MSDOS frames along with
Eli Zaretskii <eliz@gnu.org>
parents: 97204
diff changeset
315 error ("Can not put X dialog on this terminal");
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
316
102628
94c85c1ce9d8 (xdialog_show): Move Fredisplay call ...
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 100951
diff changeset
317 /* Force a redisplay before showing the dialog. If a frame is created
94c85c1ce9d8 (xdialog_show): Move Fredisplay call ...
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 100951
diff changeset
318 just before showing the dialog, its contents may not have been fully
94c85c1ce9d8 (xdialog_show): Move Fredisplay call ...
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 100951
diff changeset
319 drawn, as this depends on timing of events from the X server. Redisplay
94c85c1ce9d8 (xdialog_show): Move Fredisplay call ...
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 100951
diff changeset
320 is not done when a dialog is shown. If redisplay could be done in the
94c85c1ce9d8 (xdialog_show): Move Fredisplay call ...
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 100951
diff changeset
321 X event loop (i.e. the X event loop does not run in a signal handler)
94c85c1ce9d8 (xdialog_show): Move Fredisplay call ...
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 100951
diff changeset
322 this would not be needed.
94c85c1ce9d8 (xdialog_show): Move Fredisplay call ...
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 100951
diff changeset
323
94c85c1ce9d8 (xdialog_show): Move Fredisplay call ...
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 100951
diff changeset
324 Do this before creating the widget value that points to Lisp
94c85c1ce9d8 (xdialog_show): Move Fredisplay call ...
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 100951
diff changeset
325 string contents, because Fredisplay may GC and relocate them. */
94c85c1ce9d8 (xdialog_show): Move Fredisplay call ...
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 100951
diff changeset
326 Fredisplay (Qt);
94c85c1ce9d8 (xdialog_show): Move Fredisplay call ...
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 100951
diff changeset
327
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
328 #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
329 /* Display a menu with these alternatives
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
330 in the middle of frame F. */
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
331 {
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
332 Lisp_Object x, y, frame, newpos;
9339
8a59acc95eea (Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents: 9336
diff changeset
333 XSETFRAME (frame, f);
8a59acc95eea (Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents: 9336
diff changeset
334 XSETINT (x, x_pixel_width (f) / 2);
8a59acc95eea (Fx_popup_menu, Fx_popup_dialog): Use new accessor macros instead of calling
Karl Heuer <kwzh@gnu.org>
parents: 9336
diff changeset
335 XSETINT (y, x_pixel_height (f) / 2);
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
336 newpos = Fcons (Fcons (x, Fcons (y, Qnil)), Fcons (frame, Qnil));
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
337
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
338 return Fx_popup_menu (newpos,
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
339 Fcons (Fcar (contents), Fcons (contents, Qnil)));
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
340 }
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
341 #else
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
342 {
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
343 Lisp_Object title;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
344 char *error_name;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
345 Lisp_Object selection;
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
346 int specpdl_count = SPECPDL_INDEX ();
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
347
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
348 /* Decode the dialog items from what was specified. */
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
349 title = Fcar (contents);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
350 CHECK_STRING (title);
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
351 record_unwind_protect (unuse_menu_items, Qnil);
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
352
53545
ed3e26153ee9 * xmenu.c (Fx_popup_dialog): Add an Ok button if no buttons are
Jan Djärv <jan.h.d@swipnet.se>
parents: 53325
diff changeset
353 if (NILP (Fcar (Fcdr (contents))))
ed3e26153ee9 * xmenu.c (Fx_popup_dialog): Add an Ok button if no buttons are
Jan Djärv <jan.h.d@swipnet.se>
parents: 53325
diff changeset
354 /* No buttons specified, add an "Ok" button so users can pop down
ed3e26153ee9 * xmenu.c (Fx_popup_dialog): Add an Ok button if no buttons are
Jan Djärv <jan.h.d@swipnet.se>
parents: 53325
diff changeset
355 the dialog. Also, the lesstif/motif version crashes if there are
ed3e26153ee9 * xmenu.c (Fx_popup_dialog): Add an Ok button if no buttons are
Jan Djärv <jan.h.d@swipnet.se>
parents: 53325
diff changeset
356 no buttons. */
ed3e26153ee9 * xmenu.c (Fx_popup_dialog): Add an Ok button if no buttons are
Jan Djärv <jan.h.d@swipnet.se>
parents: 53325
diff changeset
357 contents = Fcons (title, Fcons (Fcons (build_string ("Ok"), Qt), Qnil));
58171
e08eaff3b8ab (pop_down_menu): Return nil.
Kim F. Storm <storm@cua.dk>
parents: 58170
diff changeset
358
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
359 list_of_panes (Fcons (contents, Qnil));
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
360
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
361 /* Display them in a dialog box. */
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
362 BLOCK_INPUT;
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
363 selection = xdialog_show (f, 0, title, header, &error_name);
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
364 UNBLOCK_INPUT;
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
365
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
366 unbind_to (specpdl_count, Qnil);
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
367 discard_menu_items ();
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
368
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
369 if (error_name) error (error_name);
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
370 return selection;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
371 }
6325
d6817c9c0413 Undo previous change. Instead:
Richard M. Stallman <rms@gnu.org>
parents: 6324
diff changeset
372 #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
373 }
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
374
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
375
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
376 #ifndef MSDOS
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
377
58202
54c649507b74 * xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58197
diff changeset
378 /* Set menu_items_inuse so no other popup menu or dialog is created. */
54c649507b74 * xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58197
diff changeset
379
54c649507b74 * xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58197
diff changeset
380 void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
381 x_menu_set_in_use (int in_use)
58202
54c649507b74 * xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58197
diff changeset
382 {
54c649507b74 * xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58197
diff changeset
383 menu_items_inuse = in_use ? Qt : Qnil;
58283
c163562b2d59 * xmenu.c (x_menu_in_use): Removed.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58216
diff changeset
384 popup_activated_flag = in_use;
72854
f295b430aa3a * xterm.c (x_initialize): Don't install Xt event timer here.
Chong Yidong <cyd@stupidchicken.com>
parents: 72757
diff changeset
385 #ifdef USE_X_TOOLKIT
f295b430aa3a * xterm.c (x_initialize): Don't install Xt event timer here.
Chong Yidong <cyd@stupidchicken.com>
parents: 72757
diff changeset
386 if (popup_activated_flag)
f295b430aa3a * xterm.c (x_initialize): Don't install Xt event timer here.
Chong Yidong <cyd@stupidchicken.com>
parents: 72757
diff changeset
387 x_activate_timeout_atimer ();
f295b430aa3a * xterm.c (x_initialize): Don't install Xt event timer here.
Chong Yidong <cyd@stupidchicken.com>
parents: 72757
diff changeset
388 #endif
58202
54c649507b74 * xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58197
diff changeset
389 }
54c649507b74 * xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58197
diff changeset
390
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
391 /* Wait for an X event to arrive or for a timer to expire. */
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
392
58202
54c649507b74 * xfns.c (Fx_file_dialog): Call x_menu_in_use and x_menu_set_in_use.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58197
diff changeset
393 void
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
394 x_menu_wait_for_event (void *data)
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
395 {
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
396 /* Another way to do this is to register a timer callback, that can be
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
397 done in GTK and Xt. But we have to do it like this when using only X
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
398 anyway, and with callbacks we would have three variants for timer handling
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
399 instead of the small ifdefs below. */
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
400
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
401 while (
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
402 #ifdef USE_X_TOOLKIT
58170
66ace4a9a250 (pop_down_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58169
diff changeset
403 ! XtAppPending (Xt_app_con)
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
404 #elif defined USE_GTK
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
405 ! gtk_events_pending ()
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
406 #else
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
407 ! XPending ((Display*) data)
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
408 #endif
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
409 )
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
410 {
105936
45191c90be7e Bug #4574. Common code for file/font dialog. Handle timers with glib-timers.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105931
diff changeset
411 EMACS_TIME next_time = timer_check (1), *ntp;
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
412 long secs = EMACS_SECS (next_time);
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
413 long usecs = EMACS_USECS (next_time);
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
414 SELECT_TYPE read_fds;
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
415 struct x_display_info *dpyinfo;
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
416 int n = 0;
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
417
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
418 FD_ZERO (&read_fds);
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
419 for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
420 {
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
421 int fd = ConnectionNumber (dpyinfo->display);
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
422 FD_SET (fd, &read_fds);
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
423 if (fd > n) n = fd;
106057
385ba537122c *** empty log message ***
Jan Djärv <jan.h.d@swipnet.se>
parents: 106056
diff changeset
424 XFlush (dpyinfo->display);
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
425 }
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
426
105936
45191c90be7e Bug #4574. Common code for file/font dialog. Handle timers with glib-timers.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105931
diff changeset
427 if (secs < 0 && usecs < 0)
45191c90be7e Bug #4574. Common code for file/font dialog. Handle timers with glib-timers.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105931
diff changeset
428 ntp = 0;
45191c90be7e Bug #4574. Common code for file/font dialog. Handle timers with glib-timers.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105931
diff changeset
429 else
45191c90be7e Bug #4574. Common code for file/font dialog. Handle timers with glib-timers.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105931
diff changeset
430 ntp = &next_time;
45191c90be7e Bug #4574. Common code for file/font dialog. Handle timers with glib-timers.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105931
diff changeset
431
45191c90be7e Bug #4574. Common code for file/font dialog. Handle timers with glib-timers.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105931
diff changeset
432 select (n + 1, &read_fds, (SELECT_TYPE *)0, (SELECT_TYPE *)0, ntp);
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
433 }
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
434 }
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
435 #endif /* ! MSDOS */
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
436
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
437
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
438 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
439
58170
66ace4a9a250 (pop_down_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58169
diff changeset
440 #ifdef USE_X_TOOLKIT
66ace4a9a250 (pop_down_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58169
diff changeset
441
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
442 /* Loop in Xt until the menu pulldown or dialog popup has been
13821
4d2bf17e7631 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13654
diff changeset
443 popped down (deactivated). This is used for x-popup-menu
48912
b0b74923fe41 (popup_get_selection): Now static. New arg DO_TIMERS.
Richard M. Stallman <rms@gnu.org>
parents: 48329
diff changeset
444 and x-popup-dialog; it is not used for the menu bar.
b0b74923fe41 (popup_get_selection): Now static. New arg DO_TIMERS.
Richard M. Stallman <rms@gnu.org>
parents: 48329
diff changeset
445
11954
4117d74ba254 (popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents: 11918
diff changeset
446 NOTE: All calls to popup_get_selection should be protected
9236
583bb9211b2b (popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents: 9233
diff changeset
447 with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */
11449
fca5a32f7806 (popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents: 11266
diff changeset
448
48912
b0b74923fe41 (popup_get_selection): Now static. New arg DO_TIMERS.
Richard M. Stallman <rms@gnu.org>
parents: 48329
diff changeset
449 static void
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
450 popup_get_selection (XEvent *initial_event, struct x_display_info *dpyinfo, LWLIB_ID id, int do_timers)
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
451 {
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
452 XEvent event;
49116
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
453
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
454 while (popup_activated_flag)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
455 {
59107
d264cb5b989f Indentation fix.
Richard M. Stallman <rms@gnu.org>
parents: 59102
diff changeset
456 if (initial_event)
49116
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
457 {
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
458 event = *initial_event;
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
459 initial_event = 0;
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
460 }
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
461 else
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
462 {
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
463 if (do_timers) x_menu_wait_for_event (0);
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
464 XtAppNextEvent (Xt_app_con, &event);
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
465 }
49116
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
466
15628
f74c79dcaf8d (popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents: 15428
diff changeset
467 /* Make sure we don't consider buttons grabbed after menu goes.
49116
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
468 And make sure to deactivate for any ButtonRelease,
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
469 even if XtDispatchEvent doesn't do that. */
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
470 if (event.type == ButtonRelease
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
471 && dpyinfo->display == event.xbutton.display)
15628
f74c79dcaf8d (popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents: 15428
diff changeset
472 {
f74c79dcaf8d (popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents: 15428
diff changeset
473 dpyinfo->grabbed &= ~(1 << event.xbutton.button);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
474 #ifdef USE_MOTIF /* Pretending that the event came from a
49116
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
475 Btn1Down seems the only way to convince Motif to
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
476 activate its callbacks; setting the XmNmenuPost
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
477 isn't working. --marcus@sysc.pdx.edu. */
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
478 event.xbutton.button = 1;
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
479 /* Motif only pops down menus when no Ctrl, Alt or Mod
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
480 key is pressed and the button is released. So reset key state
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
481 so Motif thinks this is the case. */
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
482 event.xbutton.state = 0;
15839
e66ccb471d26 (xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents: 15807
diff changeset
483 #endif
15628
f74c79dcaf8d (popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents: 15428
diff changeset
484 }
59155
6690f246cffe * xmenu.c (popup_get_selection): Only pop down dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents: 59107
diff changeset
485 /* Pop down on C-g and Escape. */
11954
4117d74ba254 (popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents: 11918
diff changeset
486 else if (event.type == KeyPress
15628
f74c79dcaf8d (popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents: 15428
diff changeset
487 && dpyinfo->display == event.xbutton.display)
49116
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
488 {
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
489 KeySym keysym = XLookupKeysym (&event.xkey, 0);
59102
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
490
59155
6690f246cffe * xmenu.c (popup_get_selection): Only pop down dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents: 59107
diff changeset
491 if ((keysym == XK_g && (event.xkey.state & ControlMask) != 0)
6690f246cffe * xmenu.c (popup_get_selection): Only pop down dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents: 59107
diff changeset
492 || keysym == XK_Escape) /* Any escape, ignore modifiers. */
59102
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
493 popup_activated_flag = 0;
49116
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
494 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
495
49116
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
496 x_dispatch_event (&event, event.xany.display);
11449
fca5a32f7806 (popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents: 11266
diff changeset
497 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
498 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
499
83542
2d56e13fd23d Merged from emacs@sv.gnu.org
Karoly Lorentey <lorentey@elte.hu>
parents: 83537 73320
diff changeset
500 DEFUN ("x-menu-bar-open-internal", Fx_menu_bar_open_internal, Sx_menu_bar_open_internal, 0, 1, "i",
71057
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
501 doc: /* Start key navigation of the menu bar in FRAME.
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
502 This initially opens the first menu bar item and you can then navigate with the
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
503 arrow keys, select a menu entry with the return key or cancel with the
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
504 escape key. If FRAME has no menu bar this function does nothing.
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
505
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
506 If FRAME is nil or not given, use the selected frame. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109174
diff changeset
507 (Lisp_Object frame)
71057
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
508 {
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
509 XEvent ev;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
510 FRAME_PTR f = check_x_frame (frame);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
511 Widget menubar;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
512 BLOCK_INPUT;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
513
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
514 if (FRAME_EXTERNAL_MENU_BAR (f))
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
515 set_frame_menubar (f, 0, 1);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
516
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
517 menubar = FRAME_X_OUTPUT (f)->menubar_widget;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
518 if (menubar)
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
519 {
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
520 Window child;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
521 int error_p = 0;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
522
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
523 x_catch_errors (FRAME_X_DISPLAY (f));
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
524 memset (&ev, 0, sizeof ev);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
525 ev.xbutton.display = FRAME_X_DISPLAY (f);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
526 ev.xbutton.window = XtWindow (menubar);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
527 ev.xbutton.root = FRAME_X_DISPLAY_INFO (f)->root_window;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
528 ev.xbutton.time = XtLastTimestampProcessed (FRAME_X_DISPLAY (f));
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
529 ev.xbutton.button = Button1;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
530 ev.xbutton.x = ev.xbutton.y = FRAME_MENUBAR_HEIGHT (f) / 2;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
531 ev.xbutton.same_screen = True;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
532
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
533 #ifdef USE_MOTIF
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
534 {
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
535 Arg al[2];
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
536 WidgetList list;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
537 Cardinal nr;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
538 XtSetArg (al[0], XtNchildren, &list);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
539 XtSetArg (al[1], XtNnumChildren, &nr);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
540 XtGetValues (menubar, al, 2);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
541 ev.xbutton.window = XtWindow (list[0]);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
542 }
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
543 #endif
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
544
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
545 XTranslateCoordinates (FRAME_X_DISPLAY (f),
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
546 /* From-window, to-window. */
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
547 ev.xbutton.window, ev.xbutton.root,
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
548
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
549 /* From-position, to-position. */
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
550 ev.xbutton.x, ev.xbutton.y,
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
551 &ev.xbutton.x_root, &ev.xbutton.y_root,
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
552
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
553 /* Child of win. */
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
554 &child);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
555 error_p = x_had_errors_p (FRAME_X_DISPLAY (f));
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
556 x_uncatch_errors ();
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
557
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
558 if (! error_p)
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
559 {
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
560 ev.type = ButtonPress;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
561 ev.xbutton.state = 0;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
562
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
563 XtDispatchEvent (&ev);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
564 ev.xbutton.type = ButtonRelease;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
565 ev.xbutton.state = Button1Mask;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
566 XtDispatchEvent (&ev);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
567 }
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
568 }
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
569
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
570 UNBLOCK_INPUT;
71094
bff9557e8c24 (Fmenu_bar_start): Return a value.
Andreas Schwab <schwab@suse.de>
parents: 71057
diff changeset
571
bff9557e8c24 (Fmenu_bar_start): Return a value.
Andreas Schwab <schwab@suse.de>
parents: 71057
diff changeset
572 return Qnil;
71057
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
573 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
574 #endif /* USE_X_TOOLKIT */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
575
71057
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
576
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
577 #ifdef USE_GTK
83542
2d56e13fd23d Merged from emacs@sv.gnu.org
Karoly Lorentey <lorentey@elte.hu>
parents: 83537 73320
diff changeset
578 DEFUN ("x-menu-bar-open-internal", Fx_menu_bar_open_internal, Sx_menu_bar_open_internal, 0, 1, "i",
71057
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
579 doc: /* Start key navigation of the menu bar in FRAME.
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
580 This initially opens the first menu bar item and you can then navigate with the
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
581 arrow keys, select a menu entry with the return key or cancel with the
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
582 escape key. If FRAME has no menu bar this function does nothing.
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
583
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
584 If FRAME is nil or not given, use the selected frame. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109174
diff changeset
585 (Lisp_Object frame)
71057
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
586 {
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
587 GtkWidget *menubar;
73662
ea2e12adb144 * xmenu.c (Fmenu_bar_open): Declare variable before BLOCK_INPUT to
Chong Yidong <cyd@stupidchicken.com>
parents: 73320
diff changeset
588 FRAME_PTR f;
ea2e12adb144 * xmenu.c (Fmenu_bar_open): Declare variable before BLOCK_INPUT to
Chong Yidong <cyd@stupidchicken.com>
parents: 73320
diff changeset
589
73715
fbb020e31484 Add a comment.
Chong Yidong <cyd@stupidchicken.com>
parents: 73697
diff changeset
590 /* gcc 2.95 doesn't accept the FRAME_PTR declaration after
fbb020e31484 Add a comment.
Chong Yidong <cyd@stupidchicken.com>
parents: 73697
diff changeset
591 BLOCK_INPUT. */
fbb020e31484 Add a comment.
Chong Yidong <cyd@stupidchicken.com>
parents: 73697
diff changeset
592
71057
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
593 BLOCK_INPUT;
73662
ea2e12adb144 * xmenu.c (Fmenu_bar_open): Declare variable before BLOCK_INPUT to
Chong Yidong <cyd@stupidchicken.com>
parents: 73320
diff changeset
594 f = check_x_frame (frame);
71057
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
595
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
596 if (FRAME_EXTERNAL_MENU_BAR (f))
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
597 set_frame_menubar (f, 0, 1);
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
598
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
599 menubar = FRAME_X_OUTPUT (f)->menubar_widget;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
600 if (menubar)
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
601 {
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
602 /* Activate the first menu. */
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
603 GList *children = gtk_container_get_children (GTK_CONTAINER (menubar));
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
604
97075
864ac210d576 * xmenu.c (Fx_menu_bar_open_internal): Use activate_item signal to
Jan Djärv <jan.h.d@swipnet.se>
parents: 96608
diff changeset
605 if (children)
864ac210d576 * xmenu.c (Fx_menu_bar_open_internal): Use activate_item signal to
Jan Djärv <jan.h.d@swipnet.se>
parents: 96608
diff changeset
606 {
864ac210d576 * xmenu.c (Fx_menu_bar_open_internal): Use activate_item signal to
Jan Djärv <jan.h.d@swipnet.se>
parents: 96608
diff changeset
607 g_signal_emit_by_name (children->data, "activate_item");
864ac210d576 * xmenu.c (Fx_menu_bar_open_internal): Use activate_item signal to
Jan Djärv <jan.h.d@swipnet.se>
parents: 96608
diff changeset
608 popup_activated_flag = 1;
864ac210d576 * xmenu.c (Fx_menu_bar_open_internal): Use activate_item signal to
Jan Djärv <jan.h.d@swipnet.se>
parents: 96608
diff changeset
609 g_list_free (children);
864ac210d576 * xmenu.c (Fx_menu_bar_open_internal): Use activate_item signal to
Jan Djärv <jan.h.d@swipnet.se>
parents: 96608
diff changeset
610 }
71057
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
611 }
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
612 UNBLOCK_INPUT;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
613
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
614 return Qnil;
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
615 }
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
616
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
617 /* Loop util popup_activated_flag is set to zero in a callback.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
618 Used for popup menus and dialogs. */
58170
66ace4a9a250 (pop_down_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58169
diff changeset
619
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
620 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
621 popup_widget_loop (int do_timers, GtkWidget *widget)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
622 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
623 ++popup_activated_flag;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
624
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
625 /* Process events in the Gtk event loop until done. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
626 while (popup_activated_flag)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
627 {
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
628 if (do_timers) x_menu_wait_for_event (0);
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
629 gtk_main_iteration ();
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
630 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
631 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
632 #endif
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
633
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
634 /* Activate the menu bar of frame F.
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
635 This is called from keyboard.c when it gets the
45803
9484de301252 Rename enum event_kind items.
Pavel Janík <Pavel@Janik.cz>
parents: 42588
diff changeset
636 MENU_BAR_ACTIVATE_EVENT out of the Emacs event queue.
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
637
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
638 To activate the menu bar, we use the X button-press event
15710
85d87cd0f655 (x_activate_menubar): Allow any event, not just ButtonPress.
Karl Heuer <kwzh@gnu.org>
parents: 15628
diff changeset
639 that was saved in saved_menu_event.
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
640 That makes the toolkit do its thing.
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
641
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
642 But first we recompute the menu bar contents (the whole tree).
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
643
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
644 The reason for saving the button event until here, instead of
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
645 passing it to the toolkit right away, is that we can safely
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
646 execute Lisp code. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
647
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21268
diff changeset
648 void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
649 x_activate_menubar (FRAME_PTR f)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
650 {
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
651 if (! FRAME_X_P (f))
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
652 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
653
15710
85d87cd0f655 (x_activate_menubar): Allow any event, not just ButtonPress.
Karl Heuer <kwzh@gnu.org>
parents: 15628
diff changeset
654 if (!f->output_data.x->saved_menu_event->type)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
655 return;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
656
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
657 #ifdef USE_GTK
53069
1218a42792ea Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52981
diff changeset
658 if (! xg_win_to_widget (FRAME_X_DISPLAY (f),
1218a42792ea Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52981
diff changeset
659 f->output_data.x->saved_menu_event->xany.window))
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
660 return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
661 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
662
15807
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
663 set_frame_menubar (f, 0, 1);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
664 BLOCK_INPUT;
109391
a4e57fa6eb3f Fix menu bar activation with click for Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109374
diff changeset
665 popup_activated_flag = 1;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
666 #ifdef USE_GTK
109291
35d06d80fc61 Fix hang for mouse press on menubar but not on an item (Bug#6499).
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
667 /* If we click outside any menu item, the menu bar still grabs.
35d06d80fc61 Fix hang for mouse press on menubar but not on an item (Bug#6499).
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
668 So we send Press and the Release. If outside, grab is released.
35d06d80fc61 Fix hang for mouse press on menubar but not on an item (Bug#6499).
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
669 If on a menu item, it is popped up normally.
35d06d80fc61 Fix hang for mouse press on menubar but not on an item (Bug#6499).
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
670 PutBack is like a stack, so we put back in reverse order. */
35d06d80fc61 Fix hang for mouse press on menubar but not on an item (Bug#6499).
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
671 f->output_data.x->saved_menu_event->type = ButtonRelease;
35d06d80fc61 Fix hang for mouse press on menubar but not on an item (Bug#6499).
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
672 XPutBackEvent (f->output_data.x->display_info->display,
35d06d80fc61 Fix hang for mouse press on menubar but not on an item (Bug#6499).
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
673 f->output_data.x->saved_menu_event);
35d06d80fc61 Fix hang for mouse press on menubar but not on an item (Bug#6499).
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
674 f->output_data.x->saved_menu_event->type = ButtonPress;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
675 XPutBackEvent (f->output_data.x->display_info->display,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
676 f->output_data.x->saved_menu_event);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
677 #else
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
678 XtDispatchEvent (f->output_data.x->saved_menu_event);
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
679 #endif
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
680 UNBLOCK_INPUT;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
681
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
682 /* Ignore this if we get it a second time. */
15710
85d87cd0f655 (x_activate_menubar): Allow any event, not just ButtonPress.
Karl Heuer <kwzh@gnu.org>
parents: 15628
diff changeset
683 f->output_data.x->saved_menu_event->type = 0;
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
684 }
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
685
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
686 /* This callback is invoked when the user selects a menubar cascade
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
687 pushbutton, but before the pulldown menu is posted. */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
688
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
689 #ifndef USE_GTK
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
690 static void
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
691 popup_activate_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
692 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
693 popup_activated_flag = 1;
72854
f295b430aa3a * xterm.c (x_initialize): Don't install Xt event timer here.
Chong Yidong <cyd@stupidchicken.com>
parents: 72757
diff changeset
694 #ifdef USE_X_TOOLKIT
f295b430aa3a * xterm.c (x_initialize): Don't install Xt event timer here.
Chong Yidong <cyd@stupidchicken.com>
parents: 72757
diff changeset
695 x_activate_timeout_atimer ();
f295b430aa3a * xterm.c (x_initialize): Don't install Xt event timer here.
Chong Yidong <cyd@stupidchicken.com>
parents: 72757
diff changeset
696 #endif
27425
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
697 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
698 #endif
27425
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
699
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
700 /* This callback is invoked when a dialog or menu is finished being
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
701 used and has been unposted. */
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
702
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
703 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
704 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
705 popup_deactivate_callback (GtkWidget *widget, gpointer client_data)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
706 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
707 popup_activated_flag = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
708 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
709 #else
27425
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
710 static void
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
711 popup_deactivate_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
27425
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
712 {
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
713 popup_activated_flag = 0;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
715 #endif
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
716
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
717
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
718 /* Function that finds the frame for WIDGET and shows the HELP text
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
719 for that widget.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
720 F is the frame if known, or NULL if not known. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
721 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
722 show_help_event (FRAME_PTR f, xt_or_gtk_widget widget, Lisp_Object help)
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
723 {
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
724 Lisp_Object frame;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
725
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
726 if (f)
30472
0c982ed8515f (menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents: 30420
diff changeset
727 {
0c982ed8515f (menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents: 30420
diff changeset
728 XSETFRAME (frame, f);
0c982ed8515f (menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents: 30420
diff changeset
729 kbd_buffer_store_help_event (frame, help);
0c982ed8515f (menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents: 30420
diff changeset
730 }
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
731 else
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
732 {
53325
8e8832ef3963 (show_help_event): Remove unused code.
Kim F. Storm <storm@cua.dk>
parents: 53069
diff changeset
733 #if 0 /* This code doesn't do anything useful. ++kfs */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
734 /* WIDGET is the popup menu. It's parent is the frame's
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
735 widget. See which frame that is. */
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
736 xt_or_gtk_widget frame_widget = XtParent (widget);
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
737 Lisp_Object tail;
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
738
90970
3371fc48749b Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 90951
diff changeset
739 for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail))
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
740 {
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
741 frame = XCAR (tail);
90970
3371fc48749b Replace uses of GC_* macros with the non-GC_ versions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 90951
diff changeset
742 if (FRAMEP (frame)
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
743 && (f = XFRAME (frame),
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
744 FRAME_X_P (f) && f->output_data.x->widget == frame_widget))
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
745 break;
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
746 }
53325
8e8832ef3963 (show_help_event): Remove unused code.
Kim F. Storm <storm@cua.dk>
parents: 53069
diff changeset
747 #endif
30472
0c982ed8515f (menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents: 30420
diff changeset
748 show_help_echo (help, Qnil, Qnil, Qnil, 1);
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
749 }
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
750 }
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
751
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
752 /* Callback called when menu items are highlighted/unhighlighted
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
753 while moving the mouse over them. WIDGET is the menu bar or menu
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
754 popup widget. ID is its LWLIB_ID. CALL_DATA contains a pointer to
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
755 the data structure for the menu item, or null in case of
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
756 unhighlighting. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
757
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
758 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
759 void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
760 menu_highlight_callback (GtkWidget *widget, gpointer call_data)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
761 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
762 xg_menu_item_cb_data *cb_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
763 Lisp_Object help;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
764
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
765 cb_data = (xg_menu_item_cb_data*) g_object_get_data (G_OBJECT (widget),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
766 XG_ITEM_DATA);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
767 if (! cb_data) return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
768
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
769 help = call_data ? cb_data->help : Qnil;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
770
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
771 /* If popup_activated_flag is greater than 1 we are in a popup menu.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
772 Don't show help for them, they won't appear before the
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
773 popup is popped down. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
774 if (popup_activated_flag <= 1)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
775 show_help_event (cb_data->cl_data->f, widget, help);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
776 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
777 #else
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
778 void
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
779 menu_highlight_callback (Widget widget, LWLIB_ID id, void *call_data)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
780 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
781 struct frame *f;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
782 Lisp_Object help;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
783
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
784 widget_value *wv = (widget_value *) call_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
785
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
786 help = wv ? wv->help : Qnil;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
787
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
788 /* Determine the frame for the help event. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
789 f = menubar_id_to_frame (id);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
790
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
791 show_help_event (f, widget, help);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
792 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
793 #endif
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
794
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
795 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
796 /* Gtk calls callbacks just because we tell it what item should be
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
797 selected in a radio group. If this variable is set to a non-zero
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
798 value, we are creating menus and don't want callbacks right now.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
799 */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
800 static int xg_crazy_callback_abort;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
801
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
802 /* This callback is called from the menu bar pulldown menu
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
803 when the user makes a selection.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
804 Figure out what the user chose
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
805 and put the appropriate events into the keyboard buffer. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
806 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
807 menubar_selection_callback (GtkWidget *widget, gpointer client_data)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
808 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
809 xg_menu_item_cb_data *cb_data = (xg_menu_item_cb_data*) client_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
810
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
811 if (xg_crazy_callback_abort)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
812 return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
813
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
814 if (! cb_data || ! cb_data->cl_data || ! cb_data->cl_data->f)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
815 return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
816
67527
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
817 /* For a group of radio buttons, GTK calls the selection callback first
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
818 for the item that was active before the selection and then for the one that
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
819 is active after the selection. For C-h k this means we get the help on
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
820 the deselected item and then the selected item is executed. Prevent that
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
821 by ignoring the non-active item. */
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
822 if (GTK_IS_RADIO_MENU_ITEM (widget)
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
823 && ! gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
824 return;
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
825
59912
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
826 /* When a menu is popped down, X generates a focus event (i.e. focus
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
827 goes back to the frame below the menu). Since GTK buffers events,
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
828 we force it out here before the menu selection event. Otherwise
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
829 sit-for will exit at once if the focus event follows the menu selection
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
830 event. */
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
831
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
832 BLOCK_INPUT;
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
833 while (gtk_events_pending ())
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
834 gtk_main_iteration ();
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
835 UNBLOCK_INPUT;
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
836
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
837 find_and_call_menu_selection (cb_data->cl_data->f,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
838 cb_data->cl_data->menu_bar_items_used,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
839 cb_data->cl_data->menu_bar_vector,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
840 cb_data->call_data);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
841 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
842
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
843 #else /* not USE_GTK */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
844
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
845 /* This callback is called from the menu bar pulldown menu
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
846 when the user makes a selection.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
847 Figure out what the user chose
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
848 and put the appropriate events into the keyboard buffer. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
849 static void
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
850 menubar_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
851 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
852 FRAME_PTR f;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
853
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
854 f = menubar_id_to_frame (id);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
855 if (!f)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
856 return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
857 find_and_call_menu_selection (f, f->menu_bar_items_used,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
858 f->menu_bar_vector, client_data);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
859 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
860 #endif /* not USE_GTK */
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
861
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
862 /* Recompute all the widgets of frame F, when the menu bar has been
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
863 changed. Value is non-zero if widgets were updated. */
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
864
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
865 static int
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
866 update_frame_menubar (FRAME_PTR f)
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
867 {
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
868 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
869 return xg_update_frame_menubar (f);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
870 #else
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
871 struct x_output *x;
6200
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
872 int columns, rows;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
873
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
874 if (! FRAME_X_P (f))
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
875 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
876
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
877 x = f->output_data.x;
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
878
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
879 if (!x->menubar_widget || XtIsManaged (x->menubar_widget))
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
880 return 0;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
881
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
882 BLOCK_INPUT;
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
883 /* Save the size of the frame because the pane widget doesn't accept
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
884 to resize itself. So force it. */
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
885 columns = FRAME_COLS (f);
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
886 rows = FRAME_LINES (f);
6200
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
887
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
888 /* Do the voodoo which means "I'm changing lots of things, don't try
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
889 to refigure sizes until I'm done." */
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
890 lw_refigure_widget (x->column_widget, False);
6200
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
891
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
892 /* The order in which children are managed is the top to bottom
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
893 order in which they are displayed in the paned window. First,
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
894 remove the text-area widget. */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
895 XtUnmanageChild (x->edit_widget);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
896
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
897 /* Remove the menubar that is there now, and put up the menubar that
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
898 should be there. */
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
899 XtManageChild (x->menubar_widget);
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
900 XtMapWidget (x->menubar_widget);
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
901 XtVaSetValues (x->menubar_widget, XtNmappedWhenManaged, 1, NULL);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
902
9236
583bb9211b2b (popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents: 9233
diff changeset
903 /* Re-manage the text-area widget, and then thrash the sizes. */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
904 XtManageChild (x->edit_widget);
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
905 lw_refigure_widget (x->column_widget, True);
6200
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
906
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
907 /* 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
908 EmacsFrameSetCharSize (x->edit_widget, columns, rows);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
909 UNBLOCK_INPUT;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
910 #endif
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
911 return 1;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
912 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
913
107804
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
914 #ifdef USE_LUCID
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
915 static void
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
916 apply_systemfont_to_dialog (Widget w)
107827
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
917 {
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
918 const char *fn = xsettings_get_system_normal_font ();
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
919 if (fn)
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
920 {
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
921 XrmDatabase db = XtDatabase (XtDisplay (w));
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
922 if (db)
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
923 XrmPutStringResource (&db, "*dialog.faceName", fn);
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
924 }
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
925 }
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
926
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
927 static void
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
928 apply_systemfont_to_menu (Widget w)
107804
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
929 {
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
930 const char *fn = xsettings_get_system_normal_font ();
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
931 int defflt;
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
932
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
933 if (!fn) return;
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
934
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
935 if (XtIsShell (w)) /* popup menu */
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
936 {
107827
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
937 Widget *childs = NULL;
107878
faaa7a6517a8 * xmenu.c (apply_systemfont_to_menu): *childs was incorrectly used.
Jan D <jan.h.d@swipnet.se>
parents: 107827
diff changeset
938
107827
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
939 XtVaGetValues (w, XtNchildren, &childs, NULL);
107878
faaa7a6517a8 * xmenu.c (apply_systemfont_to_menu): *childs was incorrectly used.
Jan D <jan.h.d@swipnet.se>
parents: 107827
diff changeset
940 if (*childs) w = *childs;
107804
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
941 }
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
942
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
943 /* Only use system font if the default is used for the menu. */
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
944 XtVaGetValues (w, XtNdefaultFace, &defflt, NULL);
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
945 if (defflt)
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
946 XtVaSetValues (w, XtNfaceName, fn, NULL);
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
947 }
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
948 #endif
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
949
12018
f5d820ad7a13 (set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents: 11954
diff changeset
950 /* Set the contents of the menubar widgets of frame F.
f5d820ad7a13 (set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents: 11954
diff changeset
951 The argument FIRST_TIME is currently ignored;
f5d820ad7a13 (set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents: 11954
diff changeset
952 it is set the first time this is called, from initialize_frame_menubar. */
f5d820ad7a13 (set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents: 11954
diff changeset
953
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
954 void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
955 set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
956 {
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
957 xt_or_gtk_widget menubar_widget;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
958 #ifdef USE_X_TOOLKIT
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
959 LWLIB_ID id;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
960 #endif
25730
db88a4b84d91 (single_menu_item, Fx_popup_menu, Fx_popup_menu,
Gerd Moellmann <gerd@gnu.org>
parents: 25680
diff changeset
961 Lisp_Object items;
9725
98d374d51f4d (set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents: 9649
diff changeset
962 widget_value *wv, *first_wv, *prev_wv = 0;
56959
dc35c2e20d41 (update_submenu_strings): YAILOM.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56848
diff changeset
963 int i, last_i = 0;
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
964 int *submenu_start, *submenu_end;
48946
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
965 int *submenu_top_level_items, *submenu_n_panes;
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
966
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
967 if (! FRAME_X_P (f))
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
968 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
969
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
970 menubar_widget = f->output_data.x->menubar_widget;
11449
fca5a32f7806 (popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents: 11266
diff changeset
971
16656
9cbbf721b91c (Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16411
diff changeset
972 XSETFRAME (Vmenu_updating_frame, f);
9cbbf721b91c (Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16411
diff changeset
973
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
974 #ifdef USE_X_TOOLKIT
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
975 if (f->output_data.x->id == 0)
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
976 f->output_data.x->id = next_menubar_widget_id++;
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
977 id = f->output_data.x->id;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
978 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
979
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
980 if (! menubar_widget)
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
981 deep_p = 1;
15807
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
982 /* Make the first call for any given frame always go deep. */
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
983 else if (!f->output_data.x->saved_menu_event && !deep_p)
15792
feeb1f7c1cec (pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15785
diff changeset
984 {
feeb1f7c1cec (pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15785
diff changeset
985 deep_p = 1;
15807
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
986 f->output_data.x->saved_menu_event = (XEvent*)xmalloc (sizeof (XEvent));
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
987 f->output_data.x->saved_menu_event->type = 0;
15792
feeb1f7c1cec (pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15785
diff changeset
988 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
989
52981
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
990 #ifdef USE_GTK
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
991 /* If we have detached menus, we must update deep so detached menus
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
992 also gets updated. */
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
993 deep_p = deep_p || xg_have_tear_offs ();
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
994 #endif
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
995
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
996 if (deep_p)
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
997 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
998 /* Make a widget-value tree representing the entire menu trees. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
999
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1000 struct buffer *prev = current_buffer;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1001 Lisp_Object buffer;
46293
1fb8f75062c6 Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents: 45803
diff changeset
1002 int specpdl_count = SPECPDL_INDEX ();
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1003 int previous_menu_items_used = f->menu_bar_items_used;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1004 Lisp_Object *previous_items
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1005 = (Lisp_Object *) alloca (previous_menu_items_used
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1006 * sizeof (Lisp_Object));
12634
eec80ea06395 (set_frame_menubar): If the Lisp-level menu bar menus
Richard M. Stallman <rms@gnu.org>
parents: 12625
diff changeset
1007
17554
0a75fcee3cb8 (set_frame_menubar): When widget is new, forget records of old contents.
Richard M. Stallman <rms@gnu.org>
parents: 17364
diff changeset
1008 /* If we are making a new widget, its contents are empty,
0a75fcee3cb8 (set_frame_menubar): When widget is new, forget records of old contents.
Richard M. Stallman <rms@gnu.org>
parents: 17364
diff changeset
1009 do always reinitialize them. */
0a75fcee3cb8 (set_frame_menubar): When widget is new, forget records of old contents.
Richard M. Stallman <rms@gnu.org>
parents: 17364
diff changeset
1010 if (! menubar_widget)
0a75fcee3cb8 (set_frame_menubar): When widget is new, forget records of old contents.
Richard M. Stallman <rms@gnu.org>
parents: 17364
diff changeset
1011 previous_menu_items_used = 0;
0a75fcee3cb8 (set_frame_menubar): When widget is new, forget records of old contents.
Richard M. Stallman <rms@gnu.org>
parents: 17364
diff changeset
1012
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1013 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1014 specbind (Qinhibit_quit, Qt);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1015 /* Don't let the debugger step into this code
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1016 because it is not reentrant. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1017 specbind (Qdebug_on_next_call, Qnil);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1018
63147
9bde03db5726 * composite.c (compose_chars_in_text):
Kim F. Storm <storm@cua.dk>
parents: 63070
diff changeset
1019 record_unwind_save_match_data ();
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1020 if (NILP (Voverriding_local_map_menu_flag))
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1021 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1022 specbind (Qoverriding_terminal_local_map, Qnil);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1023 specbind (Qoverriding_local_map, Qnil);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1024 }
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1025
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1026 set_buffer_internal_1 (XBUFFER (buffer));
12634
eec80ea06395 (set_frame_menubar): If the Lisp-level menu bar menus
Richard M. Stallman <rms@gnu.org>
parents: 12625
diff changeset
1027
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1028 /* Run the Lucid hook. */
36191
0cee3a77c592 (set_frame_menubar): Run acivate-menu-bar-hook with
Gerd Moellmann <gerd@gnu.org>
parents: 34038
diff changeset
1029 safe_run_hooks (Qactivate_menubar_hook);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1030
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1031 /* If it has changed current-menubar from previous value,
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1032 really recompute the menubar from the value. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1033 if (! NILP (Vlucid_menu_bar_dirty_flag))
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1034 call0 (Qrecompute_lucid_menubar);
14298
6448a36ceaad (set_frame_menubar):
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
1035 safe_run_hooks (Qmenu_bar_update_hook);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1036 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1037
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1038 items = FRAME_MENU_BAR_ITEMS (f);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1039
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1040 /* Save the frame's previous menu bar contents data. */
38594
53ed5f089c9e (set_frame_menubar): Take into account that
Gerd Moellmann <gerd@gnu.org>
parents: 37940
diff changeset
1041 if (previous_menu_items_used)
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109126
diff changeset
1042 memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents,
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109126
diff changeset
1043 previous_menu_items_used * sizeof (Lisp_Object));
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1044
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1045 /* Fill in menu_items with the current menu bar contents.
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1046 This can evaluate Lisp code. */
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1047 save_menu_items ();
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1048
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1049 menu_items = f->menu_bar_vector;
38594
53ed5f089c9e (set_frame_menubar): Take into account that
Gerd Moellmann <gerd@gnu.org>
parents: 37940
diff changeset
1050 menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1051 submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1052 submenu_end = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
48946
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1053 submenu_n_panes = (int *) alloca (XVECTOR (items)->size * sizeof (int));
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1054 submenu_top_level_items
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1055 = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1056 init_menu_items ();
15107
e025990722ca (set_frame_menubar): FRAME_MENU_BAR_ITEMS now has four elements per item.
Richard M. Stallman <rms@gnu.org>
parents: 14741
diff changeset
1057 for (i = 0; i < XVECTOR (items)->size; i += 4)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1058 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1059 Lisp_Object key, string, maps;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1060
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1061 last_i = i;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1062
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1063 key = XVECTOR (items)->contents[i];
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1064 string = XVECTOR (items)->contents[i + 1];
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1065 maps = XVECTOR (items)->contents[i + 2];
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1066 if (NILP (string))
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1067 break;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1068
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1069 submenu_start[i] = menu_items_used;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1070
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1071 menu_items_n_panes = 0;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1072 submenu_top_level_items[i]
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1073 = parse_single_submenu (key, string, maps);
48946
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1074 submenu_n_panes[i] = menu_items_n_panes;
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1075
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1076 submenu_end[i] = menu_items_used;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1077 }
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1078
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1079 finish_menu_items ();
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1080
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1081 /* Convert menu_items into widget_value trees
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1082 to display the menu. This cannot evaluate Lisp code. */
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1083
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1084 wv = xmalloc_widget_value ();
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1085 wv->name = "menubar";
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1086 wv->value = 0;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1087 wv->enabled = 1;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1088 wv->button_type = BUTTON_TYPE_NONE;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1089 wv->help = Qnil;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1090 first_wv = wv;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1091
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1092 for (i = 0; i < last_i; i += 4)
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1093 {
48946
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1094 menu_items_n_panes = submenu_n_panes[i];
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1095 wv = digest_single_submenu (submenu_start[i], submenu_end[i],
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1096 submenu_top_level_items[i]);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1097 if (prev_wv)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1098 prev_wv->next = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1099 else
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1100 first_wv->contents = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1101 /* Don't set wv->name here; GC during the loop might relocate it. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1102 wv->enabled = 1;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1103 wv->button_type = BUTTON_TYPE_NONE;
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1104 prev_wv = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1105 }
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1106
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1107 set_buffer_internal_1 (prev);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1108
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1109 /* If there has been no change in the Lisp-level contents
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1110 of the menu bar, skip redisplaying it. Just exit. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1111
70086
c12e24e779ab Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 70085
diff changeset
1112 /* Compare the new menu items with the ones computed last time. */
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1113 for (i = 0; i < previous_menu_items_used; i++)
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1114 if (menu_items_used == i
17364
573189779804 (Fx_popup_menu): Don't use Lisp_Object as integer.
Karl Heuer <kwzh@gnu.org>
parents: 16752
diff changeset
1115 || (!EQ (previous_items[i], XVECTOR (menu_items)->contents[i])))
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1116 break;
13654
645e14e39a2b (set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents: 13489
diff changeset
1117 if (i == menu_items_used && i == previous_menu_items_used && i != 0)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1118 {
70086
c12e24e779ab Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 70085
diff changeset
1119 /* The menu items have not changed. Don't bother updating
c12e24e779ab Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 70085
diff changeset
1120 the menus in any form, since it would be a no-op. */
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1121 free_menubar_widget_value_tree (first_wv);
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
1122 discard_menu_items ();
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1123 unbind_to (specpdl_count, Qnil);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1124 return;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1125 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1126
70086
c12e24e779ab Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 70085
diff changeset
1127 /* The menu items are different, so store them in the frame. */
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1128 f->menu_bar_vector = menu_items;
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1129 f->menu_bar_items_used = menu_items_used;
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1130
95647
0f6a0e86ee24 Remove platform-independent menu definitions.
Chong Yidong <cyd@stupidchicken.com>
parents: 94963
diff changeset
1131 /* This undoes save_menu_items. */
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1132 unbind_to (specpdl_count, Qnil);
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1133
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1134 /* Now GC cannot happen during the lifetime of the widget_value,
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1135 so it's safe to store data from a Lisp_String. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1136 wv = first_wv->contents;
15107
e025990722ca (set_frame_menubar): FRAME_MENU_BAR_ITEMS now has four elements per item.
Richard M. Stallman <rms@gnu.org>
parents: 14741
diff changeset
1137 for (i = 0; i < XVECTOR (items)->size; i += 4)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1138 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1139 Lisp_Object string;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1140 string = XVECTOR (items)->contents[i + 1];
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1141 if (NILP (string))
56846
5817080daeba * xmenu.c (digest_single_submenu): Set lname and lkey in widget_value
Jan Djärv <jan.h.d@swipnet.se>
parents: 56805
diff changeset
1142 break;
56847
6079dd23b546 Don't call ENCODE_MENU_STRING on top level menu names, GC may occur.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56846
diff changeset
1143 wv->name = (char *) SDATA (string);
56846
5817080daeba * xmenu.c (digest_single_submenu): Set lname and lkey in widget_value
Jan Djärv <jan.h.d@swipnet.se>
parents: 56805
diff changeset
1144 update_submenu_strings (wv->contents);
5817080daeba * xmenu.c (digest_single_submenu): Set lname and lkey in widget_value
Jan Djärv <jan.h.d@swipnet.se>
parents: 56805
diff changeset
1145 wv = wv->next;
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1146 }
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1147
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1148 }
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1149 else
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1150 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1151 /* Make a widget-value tree containing
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1152 just the top level menu bar strings. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1153
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1154 wv = xmalloc_widget_value ();
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1155 wv->name = "menubar";
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1156 wv->value = 0;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1157 wv->enabled = 1;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1158 wv->button_type = BUTTON_TYPE_NONE;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1159 wv->help = Qnil;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1160 first_wv = wv;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1161
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1162 items = FRAME_MENU_BAR_ITEMS (f);
15107
e025990722ca (set_frame_menubar): FRAME_MENU_BAR_ITEMS now has four elements per item.
Richard M. Stallman <rms@gnu.org>
parents: 14741
diff changeset
1163 for (i = 0; i < XVECTOR (items)->size; i += 4)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1164 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1165 Lisp_Object string;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1166
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1167 string = XVECTOR (items)->contents[i + 1];
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1168 if (NILP (string))
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1169 break;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1170
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
1171 wv = xmalloc_widget_value ();
56847
6079dd23b546 Don't call ENCODE_MENU_STRING on top level menu names, GC may occur.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56846
diff changeset
1172 wv->name = (char *) SDATA (string);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1173 wv->value = 0;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1174 wv->enabled = 1;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1175 wv->button_type = BUTTON_TYPE_NONE;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
1176 wv->help = Qnil;
15785
9902d8a8a548 (set_frame_menubar): Use -1 for call_data
Richard M. Stallman <rms@gnu.org>
parents: 15710
diff changeset
1177 /* This prevents lwlib from assuming this
9902d8a8a548 (set_frame_menubar): Use -1 for call_data
Richard M. Stallman <rms@gnu.org>
parents: 15710
diff changeset
1178 menu item is really supposed to be empty. */
9902d8a8a548 (set_frame_menubar): Use -1 for call_data
Richard M. Stallman <rms@gnu.org>
parents: 15710
diff changeset
1179 /* The EMACS_INT cast avoids a warning.
9902d8a8a548 (set_frame_menubar): Use -1 for call_data
Richard M. Stallman <rms@gnu.org>
parents: 15710
diff changeset
1180 This value just has to be different from small integers. */
9902d8a8a548 (set_frame_menubar): Use -1 for call_data
Richard M. Stallman <rms@gnu.org>
parents: 15710
diff changeset
1181 wv->call_data = (void *) (EMACS_INT) (-1);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1182
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1183 if (prev_wv)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1184 prev_wv->next = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1185 else
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1186 first_wv->contents = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1187 prev_wv = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1188 }
13654
645e14e39a2b (set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents: 13489
diff changeset
1189
645e14e39a2b (set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents: 13489
diff changeset
1190 /* Forget what we thought we knew about what is in the
645e14e39a2b (set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents: 13489
diff changeset
1191 detailed contents of the menu bar menus.
645e14e39a2b (set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents: 13489
diff changeset
1192 Changing the top level always destroys the contents. */
645e14e39a2b (set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents: 13489
diff changeset
1193 f->menu_bar_items_used = 0;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1194 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1195
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1196 /* Create or update the menu bar widget. */
11449
fca5a32f7806 (popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents: 11266
diff changeset
1197
fca5a32f7806 (popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents: 11266
diff changeset
1198 BLOCK_INPUT;
fca5a32f7806 (popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents: 11266
diff changeset
1199
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1200 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1201 xg_crazy_callback_abort = 1;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1202 if (menubar_widget)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1203 {
52981
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
1204 /* The fourth arg is DEEP_P, which says to consider the entire
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1205 menu trees we supply, rather than just the menu bar item names. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1206 xg_modify_menubar_widgets (menubar_widget,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1207 f,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1208 first_wv,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1209 deep_p,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1210 G_CALLBACK (menubar_selection_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1211 G_CALLBACK (popup_deactivate_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1212 G_CALLBACK (menu_highlight_callback));
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1213 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1214 else
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1215 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1216 GtkWidget *wvbox = f->output_data.x->vbox_widget;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1217
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1218 menubar_widget
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1219 = xg_create_widget ("menubar", "menubar", f, first_wv,
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1220 G_CALLBACK (menubar_selection_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1221 G_CALLBACK (popup_deactivate_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1222 G_CALLBACK (menu_highlight_callback));
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1223
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1224 f->output_data.x->menubar_widget = menubar_widget;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1225 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1226
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1227
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1228 #else /* not USE_GTK */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1229 if (menubar_widget)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1230 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1231 /* Disable resizing (done for Motif!) */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
1232 lw_allow_resizing (f->output_data.x->widget, False);
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1234 /* The third arg is DEEP_P, which says to consider the entire
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1235 menu trees we supply, rather than just the menu bar item names. */
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1236 lw_modify_all_widgets (id, first_wv, deep_p);
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1237
9236
583bb9211b2b (popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents: 9233
diff changeset
1238 /* Re-enable the edit widget to resize. */
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
1239 lw_allow_resizing (f->output_data.x->widget, True);
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1240 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1241 else
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1242 {
59102
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
1243 char menuOverride[] = "Ctrl<KeyPress>g: MenuGadgetEscape()";
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
1244 XtTranslations override = XtParseTranslationTable (menuOverride);
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
1245
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1246 menubar_widget = lw_create_widget ("menubar", "menubar", id, first_wv,
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
1247 f->output_data.x->column_widget,
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1248 0,
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1249 popup_activate_callback,
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1250 menubar_selection_callback,
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1251 popup_deactivate_callback,
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1252 menu_highlight_callback);
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
1253 f->output_data.x->menubar_widget = menubar_widget;
59102
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
1254
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
1255 /* Make menu pop down on C-g. */
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
1256 XtOverrideTranslations (menubar_widget, override);
109174
01e36ca71747 Fix compilation for Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109165
diff changeset
1257 #ifdef USE_LUCID
107804
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
1258 apply_systemfont_to_menu (menubar_widget);
109174
01e36ca71747 Fix compilation for Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109165
diff changeset
1259 #endif
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1260 }
11898
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1261
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1262 {
109391
a4e57fa6eb3f Fix menu bar activation with click for Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109374
diff changeset
1263 int menubar_size;
109184
04ae6087d3c0 Fix frame sizing for Lucid/Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109179
diff changeset
1264 if (f->output_data.x->menubar_widget)
04ae6087d3c0 Fix frame sizing for Lucid/Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109179
diff changeset
1265 XtRealizeWidget (f->output_data.x->menubar_widget);
04ae6087d3c0 Fix frame sizing for Lucid/Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109179
diff changeset
1266
109391
a4e57fa6eb3f Fix menu bar activation with click for Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109374
diff changeset
1267 menubar_size
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
1268 = (f->output_data.x->menubar_widget
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
1269 ? (f->output_data.x->menubar_widget->core.height
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
1270 + f->output_data.x->menubar_widget->core.border_width)
11898
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1271 : 0);
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1272
105693
964ff7cbc8a6 Fix resize due to font change on a maximized/xmonad-controlled frame.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105669
diff changeset
1273 #if 1 /* Experimentally, we now get the right results
964ff7cbc8a6 Fix resize due to font change on a maximized/xmonad-controlled frame.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105669
diff changeset
1274 for -geometry -0-0 without this. 24 Aug 96, rms.
964ff7cbc8a6 Fix resize due to font change on a maximized/xmonad-controlled frame.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105669
diff changeset
1275 Maybe so, but the menu bar size is missing the pixels so the
109391
a4e57fa6eb3f Fix menu bar activation with click for Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109374
diff changeset
1276 WM size hints are off by these pixels. Jan D, oct 2009. */
13489
ddf90bfd3744 Don't include Xaw/Paned.h unless USE_LUCID is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13071
diff changeset
1277 #ifdef USE_LUCID
11898
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1278 if (FRAME_EXTERNAL_MENU_BAR (f))
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1279 {
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1280 Dimension ibw = 0;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
1281 XtVaGetValues (f->output_data.x->column_widget,
11898
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1282 XtNinternalBorderWidth, &ibw, NULL);
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1283 menubar_size += ibw;
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1284 }
13489
ddf90bfd3744 Don't include Xaw/Paned.h unless USE_LUCID is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13071
diff changeset
1285 #endif /* USE_LUCID */
105693
964ff7cbc8a6 Fix resize due to font change on a maximized/xmonad-controlled frame.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105669
diff changeset
1286 #endif /* 1 */
11898
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1287
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
1288 f->output_data.x->menubar_height = menubar_size;
11898
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
1289 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1290 #endif /* not USE_GTK */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1291
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1292 free_menubar_widget_value_tree (first_wv);
36938
010e601743d5 (update_frame_menubar, set_frame_menubar, xmenu_show):
Gerd Moellmann <gerd@gnu.org>
parents: 36933
diff changeset
1293 update_frame_menubar (f);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1294
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1295 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1296 xg_crazy_callback_abort = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1297 #endif
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1298
12634
eec80ea06395 (set_frame_menubar): If the Lisp-level menu bar menus
Richard M. Stallman <rms@gnu.org>
parents: 12625
diff changeset
1299 UNBLOCK_INPUT;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1300 }
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
1301
14036
621a575db6f7 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13821
diff changeset
1302 /* Called from Fx_create_frame to create the initial menubar of a frame
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1303 before it is mapped, so that the window is mapped with the menubar already
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1304 there instead of us tacking it on later and thrashing the window after it
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1305 is visible. */
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1306
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1307 void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
1308 initialize_frame_menubar (FRAME_PTR f)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1309 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1310 /* This function is called before the first chance to redisplay
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1311 the frame. It has to be, so the frame will have the right size. */
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1312 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1313 set_frame_menubar (f, 1, 1);
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1314 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1315
37022
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1316
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1317 /* Get rid of the menu bar of frame F, and free its storage.
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1318 This is used when deleting a frame, and when turning off the menu bar.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1319 For GTK this function is in gtkutil.c. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1320
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1321 #ifndef USE_GTK
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
1322 void
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
1323 free_frame_menubar (FRAME_PTR f)
5897
5a68abc8f1f9 (free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5896
diff changeset
1324 {
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
1325 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
1326
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1327 if (! FRAME_X_P (f))
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1328 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1329
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
1330 menubar_widget = f->output_data.x->menubar_widget;
19624
c73494a6bcd3 (free_frame_menubar): Clear menubar_height field.
Richard M. Stallman <rms@gnu.org>
parents: 17709
diff changeset
1331
c73494a6bcd3 (free_frame_menubar): Clear menubar_height field.
Richard M. Stallman <rms@gnu.org>
parents: 17709
diff changeset
1332 f->output_data.x->menubar_height = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1333
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
1334 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
1335 {
37022
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1336 #ifdef USE_MOTIF
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1337 /* Removing the menu bar magically changes the shell widget's x
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1338 and y position of (0, 0) which, when the menu bar is turned
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1339 on again, leads to pull-down menuss appearing in strange
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1340 positions near the upper-left corner of the display. This
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1341 happens only with some window managers like twm and ctwm,
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1342 but not with other like Motif's mwm or kwm, because the
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1343 latter generate ConfigureNotify events when the menu bar
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1344 is switched off, which fixes the shell position. */
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1345 Position x0, y0, x1, y1;
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1346 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1347
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
1348 BLOCK_INPUT;
37022
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1349
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1350 #ifdef USE_MOTIF
37211
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
1351 if (f->output_data.x->widget)
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
1352 XtVaGetValues (f->output_data.x->widget, XtNx, &x0, XtNy, &y0, NULL);
37022
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1353 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1354
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
1355 lw_destroy_all_widgets ((LWLIB_ID) f->output_data.x->id);
36457
b0905c60d1ab (free_frame_menubar): Set the frame's menubar_widget to
Gerd Moellmann <gerd@gnu.org>
parents: 36191
diff changeset
1356 f->output_data.x->menubar_widget = NULL;
37022
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1357
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1358 #ifdef USE_MOTIF
37211
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
1359 if (f->output_data.x->widget)
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
1360 {
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
1361 XtVaGetValues (f->output_data.x->widget, XtNx, &x1, XtNy, &y1, NULL);
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
1362 if (x1 == 0 && y1 == 0)
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
1363 XtVaSetValues (f->output_data.x->widget, XtNx, x0, XtNy, y0, NULL);
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
1364 }
37022
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
1365 #endif
109184
04ae6087d3c0 Fix frame sizing for Lucid/Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109179
diff changeset
1366 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
5897
5a68abc8f1f9 (free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5896
diff changeset
1367 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
1368 }
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
1369 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1370 #endif /* not USE_GTK */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1371
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1372 #endif /* USE_X_TOOLKIT || USE_GTK */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1373
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1374 /* 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
1375 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
1376 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
1377 Both assume input is blocked by the caller. */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1378
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1379 /* 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
1380 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
1381 relative to the inside upper left corner of the frame F.
15839
e66ccb471d26 (xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents: 15807
diff changeset
1382 FOR_CLICK is nonzero if this menu was invoked for a mouse click.
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1383 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
1384 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
1385 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
1386 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
1387 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
1388 (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
1389
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1390 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1391
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1392 /* The item selected in the popup menu. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1393 static Lisp_Object *volatile menu_item_selection;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1394
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1395 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1396
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1397 /* Used when position a popup menu. See menu_position_func and
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1398 create_and_show_popup_menu below. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1399 struct next_popup_x_y
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1400 {
49651
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1401 FRAME_PTR f;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1402 int x;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1403 int y;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1404 };
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1405
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1406 /* The menu position function to use if we are not putting a popup
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1407 menu where the pointer is.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1408 MENU is the menu to pop up.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1409 X and Y shall on exit contain x/y where the menu shall pop up.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1410 PUSH_IN is not documented in the GTK manual.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1411 USER_DATA is any data passed in when calling gtk_menu_popup.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1412 Here it points to a struct next_popup_x_y where the coordinates
49651
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1413 to store in *X and *Y are as well as the frame for the popup.
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1414
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1415 Here only X and Y are used. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1416 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
1417 menu_position_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1418 {
49651
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1419 struct next_popup_x_y* data = (struct next_popup_x_y*)user_data;
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1420 GtkRequisition req;
98224
25a5f64dd9db (menu_position_func): Use x_display_pixel_height and
Chong Yidong <cyd@stupidchicken.com>
parents: 98035
diff changeset
1421 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (data->f);
25a5f64dd9db (menu_position_func): Use x_display_pixel_height and
Chong Yidong <cyd@stupidchicken.com>
parents: 98035
diff changeset
1422 int disp_width = x_display_pixel_width (dpyinfo);
25a5f64dd9db (menu_position_func): Use x_display_pixel_height and
Chong Yidong <cyd@stupidchicken.com>
parents: 98035
diff changeset
1423 int disp_height = x_display_pixel_height (dpyinfo);
58171
e08eaff3b8ab (pop_down_menu): Return nil.
Kim F. Storm <storm@cua.dk>
parents: 58170
diff changeset
1424
49651
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1425 *x = data->x;
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1426 *y = data->y;
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1427
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1428 /* Check if there is room for the menu. If not, adjust x/y so that
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1429 the menu is fully visible. */
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1430 gtk_widget_size_request (GTK_WIDGET (menu), &req);
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1431 if (data->x + req.width > disp_width)
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1432 *x -= data->x + req.width - disp_width;
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1433 if (data->y + req.height > disp_height)
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1434 *y -= data->y + req.height - disp_height;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1435 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1436
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1437 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
1438 popup_selection_callback (GtkWidget *widget, gpointer client_data)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1439 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1440 xg_menu_item_cb_data *cb_data = (xg_menu_item_cb_data*) client_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1441
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1442 if (xg_crazy_callback_abort) return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1443 if (cb_data) menu_item_selection = (Lisp_Object *) cb_data->call_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1444 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1445
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1446 static Lisp_Object
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
1447 pop_down_menu (Lisp_Object arg)
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1448 {
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
1449 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
1450
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1451 popup_activated_flag = 0;
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
1452 BLOCK_INPUT;
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
1453 gtk_widget_destroy (GTK_WIDGET (p->pointer));
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
1454 UNBLOCK_INPUT;
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1455 return Qnil;
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1456 }
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1457
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1458 /* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1459 menu pops down.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1460 menu_item_selection will be set to the selection. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1461 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
1462 create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, int x, int y, int for_click, EMACS_UINT timestamp)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1463 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1464 int i;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1465 GtkWidget *menu;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1466 GtkMenuPositionFunc pos_func = 0; /* Pop up at pointer. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1467 struct next_popup_x_y popup_x_y;
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1468 int specpdl_count = SPECPDL_INDEX ();
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1469
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1470 if (! FRAME_X_P (f))
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1471 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1472
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1473 xg_crazy_callback_abort = 1;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1474 menu = xg_create_widget ("popup", first_wv->name, f, first_wv,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1475 G_CALLBACK (popup_selection_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1476 G_CALLBACK (popup_deactivate_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1477 G_CALLBACK (menu_highlight_callback));
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1478 xg_crazy_callback_abort = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1479
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1480 if (! for_click)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1481 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1482 /* Not invoked by a click. pop up at x/y. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1483 pos_func = menu_position_func;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1484
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1485 /* Adjust coordinates to be root-window-relative. */
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
1486 x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
1487 y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1488
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1489 popup_x_y.x = x;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1490 popup_x_y.y = y;
49651
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
1491 popup_x_y.f = f;
59415
72adb36e240f * xmenu.c (create_and_show_popup_menu): Pass zero as button to
Jan Djärv <jan.h.d@swipnet.se>
parents: 59156
diff changeset
1492
72adb36e240f * xmenu.c (create_and_show_popup_menu): Pass zero as button to
Jan Djärv <jan.h.d@swipnet.se>
parents: 59156
diff changeset
1493 i = 0; /* gtk_menu_popup needs this to be 0 for a non-button popup. */
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1494 }
59415
72adb36e240f * xmenu.c (create_and_show_popup_menu): Pass zero as button to
Jan Djärv <jan.h.d@swipnet.se>
parents: 59156
diff changeset
1495 else
72adb36e240f * xmenu.c (create_and_show_popup_menu): Pass zero as button to
Jan Djärv <jan.h.d@swipnet.se>
parents: 59156
diff changeset
1496 {
72adb36e240f * xmenu.c (create_and_show_popup_menu): Pass zero as button to
Jan Djärv <jan.h.d@swipnet.se>
parents: 59156
diff changeset
1497 for (i = 0; i < 5; i++)
72adb36e240f * xmenu.c (create_and_show_popup_menu): Pass zero as button to
Jan Djärv <jan.h.d@swipnet.se>
parents: 59156
diff changeset
1498 if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i))
72adb36e240f * xmenu.c (create_and_show_popup_menu): Pass zero as button to
Jan Djärv <jan.h.d@swipnet.se>
parents: 59156
diff changeset
1499 break;
72adb36e240f * xmenu.c (create_and_show_popup_menu): Pass zero as button to
Jan Djärv <jan.h.d@swipnet.se>
parents: 59156
diff changeset
1500 }
61619
489414dfb069 Remove eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 60890
diff changeset
1501
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1502 /* Display the menu. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1503 gtk_widget_show_all (menu);
105903
28d5dd02302d * xmenu.c (Fx_popup_menu): Hide any tooltip before opening a menu.
Chong Yidong <cyd@stupidchicken.com>
parents: 105895
diff changeset
1504
105891
07c792840800 * xmenu.c (Fx_popup_menu): Extract event timestamp. Pass it to
Chong Yidong <cyd@stupidchicken.com>
parents: 105877
diff changeset
1505 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i,
105895
1b0e58de42e6 Fix last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 105891
diff changeset
1506 timestamp > 0 ? timestamp : gtk_get_current_event_time());
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1507
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
1508 record_unwind_protect (pop_down_menu, make_save_value (menu, 0));
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1509
109067
b5f73bf59a4f Use non-deprecated Gtk+ functions, add changes for Gtk+3 with GSEAL_ENABLE.
Jan D <jan.h.d@swipnet.se>
parents: 107878
diff changeset
1510 if (gtk_widget_get_mapped (menu))
60890
a48e83530ac6 * xmenu.c (create_and_show_popup_menu): Just remove menu and return
Jan Djärv <jan.h.d@swipnet.se>
parents: 60658
diff changeset
1511 {
a48e83530ac6 * xmenu.c (create_and_show_popup_menu): Just remove menu and return
Jan Djärv <jan.h.d@swipnet.se>
parents: 60658
diff changeset
1512 /* Set this to one. popup_widget_loop increases it by one, so it becomes
a48e83530ac6 * xmenu.c (create_and_show_popup_menu): Just remove menu and return
Jan Djärv <jan.h.d@swipnet.se>
parents: 60658
diff changeset
1513 two. show_help_echo uses this to detect popup menus. */
a48e83530ac6 * xmenu.c (create_and_show_popup_menu): Just remove menu and return
Jan Djärv <jan.h.d@swipnet.se>
parents: 60658
diff changeset
1514 popup_activated_flag = 1;
a48e83530ac6 * xmenu.c (create_and_show_popup_menu): Just remove menu and return
Jan Djärv <jan.h.d@swipnet.se>
parents: 60658
diff changeset
1515 /* Process events that apply to the menu. */
a48e83530ac6 * xmenu.c (create_and_show_popup_menu): Just remove menu and return
Jan Djärv <jan.h.d@swipnet.se>
parents: 60658
diff changeset
1516 popup_widget_loop (1, menu);
a48e83530ac6 * xmenu.c (create_and_show_popup_menu): Just remove menu and return
Jan Djärv <jan.h.d@swipnet.se>
parents: 60658
diff changeset
1517 }
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1518
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1519 unbind_to (specpdl_count, Qnil);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1520
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1521 /* Must reset this manually because the button release event is not passed
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1522 to Emacs event loop. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1523 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1524 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1525
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1526 #else /* not USE_GTK */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1527
9336
d5ffd9c9edb0 (widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents: 9236
diff changeset
1528 /* We need a unique id for each widget handled by the Lucid Widget
11918
da016ba65a6c (xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents: 11907
diff changeset
1529 library.
da016ba65a6c (xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents: 11907
diff changeset
1530
da016ba65a6c (xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents: 11907
diff changeset
1531 For the main windows, and popup menus, we use this counter,
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1532 which we increment each time after use. This starts from 1<<16.
11918
da016ba65a6c (xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents: 11907
diff changeset
1533
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1534 For menu bars, we use numbers starting at 0, counted in
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1535 next_menubar_widget_id. */
9336
d5ffd9c9edb0 (widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents: 9236
diff changeset
1536 LWLIB_ID widget_id_tick;
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1537
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1538 static void
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
1539 popup_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1540 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1541 menu_item_selection = (Lisp_Object *) client_data;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1542 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1543
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1544 /* ARG is the LWLIB ID of the dialog box, represented
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1545 as a Lisp object as (HIGHPART . LOWPART). */
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1546
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1547 static Lisp_Object
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
1548 pop_down_menu (Lisp_Object arg)
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1549 {
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1550 LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID)
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1551 | XINT (XCDR (arg)));
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1552
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1553 BLOCK_INPUT;
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1554 lw_destroy_all_widgets (id);
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1555 UNBLOCK_INPUT;
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1556 popup_activated_flag = 0;
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1557
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1558 return Qnil;
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1559 }
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1560
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1561 /* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1562 menu pops down.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1563 menu_item_selection will be set to the selection. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1564 static void
109440
f8f118e78387 * xmenu.c (create_and_show_popup_menu, xmenu_show): Fix type of timestamp argument.
Andreas Schwab <schwab@linux-m68k.org>
parents: 109391
diff changeset
1565 create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv,
f8f118e78387 * xmenu.c (create_and_show_popup_menu, xmenu_show): Fix type of timestamp argument.
Andreas Schwab <schwab@linux-m68k.org>
parents: 109391
diff changeset
1566 int x, int y, int for_click, EMACS_UINT timestamp)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1567 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1568 int i;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1569 Arg av[2];
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1570 int ac = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1571 XButtonPressedEvent dummy;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1572 LWLIB_ID menu_id;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1573 Widget menu;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1574
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1575 if (! FRAME_X_P (f))
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1576 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1577
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1578 menu_id = widget_id_tick++;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1579 menu = lw_create_widget ("popup", first_wv->name, menu_id, first_wv,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1580 f->output_data.x->widget, 1, 0,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1581 popup_selection_callback,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1582 popup_deactivate_callback,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1583 menu_highlight_callback);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1584
109174
01e36ca71747 Fix compilation for Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109165
diff changeset
1585 #ifdef USE_LUCID
107804
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
1586 apply_systemfont_to_menu (menu);
109174
01e36ca71747 Fix compilation for Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109165
diff changeset
1587 #endif
107804
24c4451bcaf7 Lucid menus can now use Xft for fonts.
Jan D. <jan.h.d@swipnet.se>
parents: 106815
diff changeset
1588
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1589 dummy.type = ButtonPress;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1590 dummy.serial = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1591 dummy.send_event = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1592 dummy.display = FRAME_X_DISPLAY (f);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1593 dummy.time = CurrentTime;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1594 dummy.root = FRAME_X_DISPLAY_INFO (f)->root_window;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1595 dummy.window = dummy.root;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1596 dummy.subwindow = dummy.root;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1597 dummy.x = x;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1598 dummy.y = y;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1599
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1600 /* Adjust coordinates to be root-window-relative. */
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
1601 x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
1602 y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1603
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1604 dummy.x_root = x;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1605 dummy.y_root = y;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1606
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1607 dummy.state = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1608 dummy.button = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1609 for (i = 0; i < 5; i++)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1610 if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i))
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1611 dummy.button = i;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1612
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1613 /* Don't allow any geometry request from the user. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1614 XtSetArg (av[ac], XtNgeometry, 0); ac++;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1615 XtSetValues (menu, av, ac);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1616
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1617 /* Display the menu. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1618 lw_popup_menu (menu, (XEvent *) &dummy);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1619 popup_activated_flag = 1;
72854
f295b430aa3a * xterm.c (x_initialize): Don't install Xt event timer here.
Chong Yidong <cyd@stupidchicken.com>
parents: 72757
diff changeset
1620 x_activate_timeout_atimer ();
61619
489414dfb069 Remove eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 60890
diff changeset
1621
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1622 {
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1623 int fact = 4 * sizeof (LWLIB_ID);
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1624 int specpdl_count = SPECPDL_INDEX ();
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1625 record_unwind_protect (pop_down_menu,
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1626 Fcons (make_number (menu_id >> (fact)),
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1627 make_number (menu_id & ~(-1 << (fact)))));
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1628
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1629 /* Process events that apply to the menu. */
59156
03a6e350cf4d (popup_get_selection): Remove parameter down_on_keypress.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59155
diff changeset
1630 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 1);
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1631
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1632 unbind_to (specpdl_count, Qnil);
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1633 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1634 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1635
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1636 #endif /* not USE_GTK */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1637
105923
1011707400d3 * menu.c (Fx_popup_menu): Consolidate versions from xmenu.c,
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105903
diff changeset
1638 Lisp_Object
1011707400d3 * menu.c (Fx_popup_menu): Consolidate versions from xmenu.c,
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105903
diff changeset
1639 xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
1011707400d3 * menu.c (Fx_popup_menu): Consolidate versions from xmenu.c,
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105903
diff changeset
1640 Lisp_Object title, char **error, EMACS_UINT timestamp)
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1641 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1642 int i;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1643 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
1644 widget_value **submenu_stack
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1645 = (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
1646 Lisp_Object *subprefix_stack
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1647 = (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
1648 int submenu_depth = 0;
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
1649
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1650 int first_pane;
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1651
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1652 if (! FRAME_X_P (f))
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1653 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1654
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1655 *error = NULL;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1656
7335
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
1657 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
1658 {
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
1659 *error = "Empty menu";
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
1660 return Qnil;
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
1661 }
5896
b20145eafe0c (xmenu_show) [USE_X_TOOLKIT]: return Qnil when val is null.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5881
diff changeset
1662
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1663 /* 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
1664 representing the panes and their items. */
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
1665 wv = xmalloc_widget_value ();
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1666 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
1667 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
1668 wv->enabled = 1;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1669 wv->button_type = BUTTON_TYPE_NONE;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
1670 wv->help =Qnil;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1671 first_wv = wv;
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1672 first_pane = 1;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1673
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1674 /* 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
1675 i = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1676 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
1677 {
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1678 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
1679 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1680 submenu_stack[submenu_depth++] = save_wv;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1681 save_wv = prev_wv;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1682 prev_wv = 0;
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1683 first_pane = 1;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1684 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1685 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1686 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
1687 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1688 prev_wv = save_wv;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1689 save_wv = submenu_stack[--submenu_depth];
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1690 first_pane = 0;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1691 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1692 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1693 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
1694 && submenu_depth != 0)
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1695 i += MENU_ITEMS_PANE_LENGTH;
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
1696 /* Ignore a nil in the item list.
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
1697 It's meaningful only for dialog boxes. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
1698 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
1699 i += 1;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1700 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
1701 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1702 /* 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
1703 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
1704 char *pane_string;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1705
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1706 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1707 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1708
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
1709 #ifndef HAVE_MULTILINGUAL_MENU
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1710 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1711 {
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
1712 pane_name = ENCODE_MENU_STRING (pane_name);
91607
d1e53221c4aa * xselect.c (x_handle_dnd_message):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91327
diff changeset
1713 ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1714 }
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
1715 #endif
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1716 pane_string = (NILP (pane_name)
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1717 ? "" : (char *) SDATA (pane_name));
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1718 /* 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
1719 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
1720 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
1721 pane_string = "";
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1722
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1723 /* 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
1724 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
1725 with its items as a submenu beneath it. */
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1726 if (!keymaps && strcmp (pane_string, ""))
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1727 {
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
1728 wv = xmalloc_widget_value ();
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1729 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
1730 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
1731 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1732 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
1733 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
1734 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
1735 wv->name++;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1736 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
1737 wv->enabled = 1;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1738 wv->button_type = BUTTON_TYPE_NONE;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
1739 wv->help = Qnil;
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1740 save_wv = wv;
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1741 prev_wv = 0;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1742 }
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1743 else if (first_pane)
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1744 {
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1745 save_wv = wv;
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1746 prev_wv = 0;
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1747 }
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
1748 first_pane = 0;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1749 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
1750 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1751 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1752 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1753 /* Create a new item within current pane. */
30472
0c982ed8515f (menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents: 30420
diff changeset
1754 Lisp_Object item_name, enable, descrip, def, type, selected, help;
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1755 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1756 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1757 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1758 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1759 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1760 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1761 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1762
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
1763 #ifndef HAVE_MULTILINGUAL_MENU
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1764 if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1765 {
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
1766 item_name = ENCODE_MENU_STRING (item_name);
91607
d1e53221c4aa * xselect.c (x_handle_dnd_message):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91327
diff changeset
1767 ASET (menu_items, i + MENU_ITEMS_ITEM_NAME, item_name);
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1768 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1769
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1770 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1771 {
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
1772 descrip = ENCODE_MENU_STRING (descrip);
91607
d1e53221c4aa * xselect.c (x_handle_dnd_message):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91327
diff changeset
1773 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1774 }
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37864
diff changeset
1775 #endif /* not HAVE_MULTILINGUAL_MENU */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1776
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
1777 wv = xmalloc_widget_value ();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1778 if (prev_wv)
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1779 prev_wv->next = wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1780 else
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1781 save_wv->contents = wv;
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1782 wv->name = (char *) SDATA (item_name);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1783 if (!NILP (descrip))
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1784 wv->key = (char *) SDATA (descrip);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1785 wv->value = 0;
10167
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
1786 /* If this item has a null value,
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
1787 make the call_data null so that it won't display a box
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
1788 when the mouse is on it. */
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
1789 wv->call_data
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
1790 = (!NILP (def) ? (void *) &XVECTOR (menu_items)->contents[i] : 0);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1791 wv->enabled = !NILP (enable);
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1792
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1793 if (NILP (type))
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1794 wv->button_type = BUTTON_TYPE_NONE;
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1795 else if (EQ (type, QCtoggle))
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1796 wv->button_type = BUTTON_TYPE_TOGGLE;
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1797 else if (EQ (type, QCradio))
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1798 wv->button_type = BUTTON_TYPE_RADIO;
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1799 else
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1800 abort ();
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1801
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1802 wv->selected = !NILP (selected);
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
1803
41769
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
1804 if (! STRINGP (help))
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
1805 help = Qnil;
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
1806
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
1807 wv->help = help;
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
1808
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1809 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
1810
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1811 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
1812 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1813 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1814
9236
583bb9211b2b (popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents: 9233
diff changeset
1815 /* Deal with the title, if it is non-nil. */
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1816 if (!NILP (title))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1817 {
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
1818 widget_value *wv_title = xmalloc_widget_value ();
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
1819 widget_value *wv_sep1 = xmalloc_widget_value ();
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
1820 widget_value *wv_sep2 = xmalloc_widget_value ();
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1821
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1822 wv_sep2->name = "--";
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1823 wv_sep2->next = first_wv->contents;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
1824 wv_sep2->help = Qnil;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1825
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1826 wv_sep1->name = "--";
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1827 wv_sep1->next = wv_sep2;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
1828 wv_sep1->help = Qnil;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1829
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
1830 #ifndef HAVE_MULTILINGUAL_MENU
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
1831 if (STRING_MULTIBYTE (title))
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
1832 title = ENCODE_MENU_STRING (title);
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
1833 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1834
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
1835 wv_title->name = (char *) SDATA (title);
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
1836 wv_title->enabled = TRUE;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1837 wv_title->button_type = BUTTON_TYPE_NONE;
95730
c3a24b1a8412 (set_frame_menubar): Sync with version in xmenu.c.
Jason Rumney <jasonr@gnu.org>
parents: 95647
diff changeset
1838 wv_title->help = Qnil;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1839 wv_title->next = wv_sep1;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1840 first_wv->contents = wv_title;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1841 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1842
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1843 /* No selection has been chosen yet. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1844 menu_item_selection = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1845
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1846 /* Actually create and show the menu until popped down. */
105891
07c792840800 * xmenu.c (Fx_popup_menu): Extract event timestamp. Pass it to
Chong Yidong <cyd@stupidchicken.com>
parents: 105877
diff changeset
1847 create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp);
8414
8a8d2cdd4218 (xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents: 8269
diff changeset
1848
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1849 /* 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
1850 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
1851
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1852 /* 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
1853 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
1854 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
1855 {
11655
a9f93ce6e1b4 (xmenu_show, menubar_selection_callback): Move declaration
Karl Heuer <kwzh@gnu.org>
parents: 11614
diff changeset
1856 Lisp_Object prefix, entry;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1857
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31465
diff changeset
1858 prefix = entry = Qnil;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1859 i = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1860 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
1861 {
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1862 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
1863 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1864 subprefix_stack[submenu_depth++] = prefix;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1865 prefix = entry;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1866 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1867 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1868 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
1869 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1870 prefix = subprefix_stack[--submenu_depth];
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1871 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1872 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1873 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
1874 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1875 prefix
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1876 = 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
1877 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
1878 }
13071
2e514396cbc8 (popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents: 12747
diff changeset
1879 /* Ignore a nil in the item list.
2e514396cbc8 (popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents: 12747
diff changeset
1880 It's meaningful only for dialog boxes. */
2e514396cbc8 (popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents: 12747
diff changeset
1881 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
2e514396cbc8 (popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents: 12747
diff changeset
1882 i += 1;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1883 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1884 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1885 entry
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1886 = 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
1887 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
1888 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1889 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
1890 {
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1891 int j;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1892
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1893 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
1894 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
1895 entry = Fcons (prefix, entry);
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1896 for (j = submenu_depth - 1; j >= 0; j--)
6931
2d0ee7ef620a (xmenu_show): Fix typo in last change.
Richard M. Stallman <rms@gnu.org>
parents: 6913
diff changeset
1897 if (!NILP (subprefix_stack[j]))
6913
f167828a3ec2 (xmenu_show): Don't cons on subprefix_stck[j] if nil.
Richard M. Stallman <rms@gnu.org>
parents: 6881
diff changeset
1898 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
1899 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1900 return entry;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1901 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1902 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
1903 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1904 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1905 }
61984
2ce055c7db65 [not HAVE_X_TOOLKIT] (xmenu_show):
Richard M. Stallman <rms@gnu.org>
parents: 61620
diff changeset
1906 else if (!for_click)
2ce055c7db65 [not HAVE_X_TOOLKIT] (xmenu_show):
Richard M. Stallman <rms@gnu.org>
parents: 61620
diff changeset
1907 /* Make "Cancel" equivalent to C-g. */
2ce055c7db65 [not HAVE_X_TOOLKIT] (xmenu_show):
Richard M. Stallman <rms@gnu.org>
parents: 61620
diff changeset
1908 Fsignal (Qquit, Qnil);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1909
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1910 return Qnil;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1911 }
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1912
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1913 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1914 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
1915 dialog_selection_callback (GtkWidget *widget, gpointer client_data)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1916 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1917 /* The EMACS_INT cast avoids a warning. There's no problem
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1918 as long as pointers have enough bits to hold small integers. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1919 if ((int) (EMACS_INT) client_data != -1)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1920 menu_item_selection = (Lisp_Object *) client_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1921
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1922 popup_activated_flag = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1923 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1924
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1925 /* Pop up the dialog for frame F defined by FIRST_WV and loop until the
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1926 dialog pops down.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1927 menu_item_selection will be set to the selection. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1928 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
1929 create_and_show_dialog (FRAME_PTR f, widget_value *first_wv)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1930 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1931 GtkWidget *menu;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1932
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1933 if (! FRAME_X_P (f))
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1934 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1935
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1936 menu = xg_create_widget ("dialog", first_wv->name, f, first_wv,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1937 G_CALLBACK (dialog_selection_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1938 G_CALLBACK (popup_deactivate_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1939 0);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1940
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1941 if (menu)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1942 {
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1943 int specpdl_count = SPECPDL_INDEX ();
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
1944 record_unwind_protect (pop_down_menu, make_save_value (menu, 0));
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1945
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1946 /* Display the menu. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1947 gtk_widget_show_all (menu);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1948
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1949 /* Process events that apply to the menu. */
58170
66ace4a9a250 (pop_down_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58169
diff changeset
1950 popup_widget_loop (1, menu);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1951
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
1952 unbind_to (specpdl_count, Qnil);
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1953 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1954 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1955
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1956 #else /* not USE_GTK */
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1957 static void
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
1958 dialog_selection_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1959 {
11266
3e93d8b99b05 (menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents: 11237
diff changeset
1960 /* The EMACS_INT cast avoids a warning. There's no problem
3e93d8b99b05 (menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents: 11237
diff changeset
1961 as long as pointers have enough bits to hold small integers. */
3e93d8b99b05 (menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents: 11237
diff changeset
1962 if ((int) (EMACS_INT) client_data != -1)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1963 menu_item_selection = (Lisp_Object *) client_data;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1964
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1965 BLOCK_INPUT;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1966 lw_destroy_all_widgets (id);
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1967 UNBLOCK_INPUT;
11614
fdd0d5bdd8c6 (popup_get_selection): Use x_non_menubar_window_to_frame.
Karl Heuer <kwzh@gnu.org>
parents: 11528
diff changeset
1968 popup_activated_flag = 0;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1969 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1970
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1971
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1972 /* Pop up the dialog for frame F defined by FIRST_WV and loop until the
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1973 dialog pops down.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1974 menu_item_selection will be set to the selection. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1975 static void
109372
dd04c65fb401 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109302
diff changeset
1976 create_and_show_dialog (FRAME_PTR f, widget_value *first_wv)
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1977 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1978 LWLIB_ID dialog_id;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1979
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1980 if (!FRAME_X_P (f))
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1981 abort();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1982
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1983 dialog_id = widget_id_tick++;
109174
01e36ca71747 Fix compilation for Motif/Lesstif.
Jan D <jan.h.d@swipnet.se>
parents: 109165
diff changeset
1984 #ifdef USE_LUCID
107827
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
1985 apply_systemfont_to_dialog (f->output_data.x->widget);
aa85632b7860 Use XFT in Lucid dialogs if available.
Jan D. <jan.h.d@swipnet.se>
parents: 107804
diff changeset
1986 #endif
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1987 lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1988 f->output_data.x->widget, 1, 0,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1989 dialog_selection_callback, 0, 0);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1990 lw_modify_all_widgets (dialog_id, first_wv->contents, True);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1991 /* Display the dialog box. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1992 lw_pop_up_all_widgets (dialog_id);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1993 popup_activated_flag = 1;
72854
f295b430aa3a * xterm.c (x_initialize): Don't install Xt event timer here.
Chong Yidong <cyd@stupidchicken.com>
parents: 72757
diff changeset
1994 x_activate_timeout_atimer ();
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1995
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1996 /* Process events that apply to the dialog box.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1997 Also handle timers. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1998 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1999 int count = SPECPDL_INDEX ();
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2000 int fact = 4 * sizeof (LWLIB_ID);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2001
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2002 /* xdialog_show_unwind is responsible for popping the dialog box down. */
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2003 record_unwind_protect (pop_down_menu,
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2004 Fcons (make_number (dialog_id >> (fact)),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2005 make_number (dialog_id & ~(-1 << (fact)))));
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2006
57965
9b14127a651a * eval.c (Feval): Remove check for INPUT_BLOCKED_P.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57928
diff changeset
2007 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f),
59156
03a6e350cf4d (popup_get_selection): Remove parameter down_on_keypress.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59155
diff changeset
2008 dialog_id, 1);
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2009
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2010 unbind_to (count, Qnil);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2011 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2012 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2013
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2014 #endif /* not USE_GTK */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2015
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2016 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
2017 "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
2018 "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
2019
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2020 static Lisp_Object
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
2021 xdialog_show (FRAME_PTR f, int keymaps, Lisp_Object title, Lisp_Object header, char **error_name)
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2022 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2023 int i, nb_buttons=0;
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2024 char dialog_name[6];
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2025
25730
db88a4b84d91 (single_menu_item, Fx_popup_menu, Fx_popup_menu,
Gerd Moellmann <gerd@gnu.org>
parents: 25680
diff changeset
2026 widget_value *wv, *first_wv = 0, *prev_wv = 0;
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2027
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2028 /* Number of elements seen so far, before boundary. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2029 int left_count = 0;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2030 /* 1 means we've seen the boundary between left-hand elts and right-hand. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2031 int boundary_seen = 0;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2032
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2033 if (! FRAME_X_P (f))
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2034 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2035
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2036 *error_name = NULL;
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2037
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2038 if (menu_items_n_panes > 1)
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2039 {
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2040 *error_name = "Multiple panes in dialog box";
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2041 return Qnil;
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2042 }
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2043
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2044 /* 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
2045 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
2046 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2047 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
2048 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
2049 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
2050 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
2051 pane_string = (NILP (pane_name)
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2052 ? "" : (char *) SDATA (pane_name));
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
2053 prev_wv = xmalloc_widget_value ();
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2054 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
2055 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
2056 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
2057 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
2058 prev_wv->name = "message";
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
2059 prev_wv->help = Qnil;
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2060 first_wv = prev_wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2061
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2062 /* 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
2063 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
2064 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
2065 {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2066
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2067 /* 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
2068 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
2069 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
2070 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
2071 descrip
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2072 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2073
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2074 if (NILP (item_name))
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2075 {
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2076 free_menubar_widget_value_tree (first_wv);
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2077 *error_name = "Submenu in dialog items";
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2078 return Qnil;
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2079 }
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2080 if (EQ (item_name, Qquote))
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2081 {
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2082 /* This is the boundary between left-side elts
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2083 and right-side elts. Stop incrementing right_count. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2084 boundary_seen = 1;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2085 i++;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2086 continue;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2087 }
15912
afb0bb1cdbe6 (xdialog_show): Don't allow 9 buttons.
Richard M. Stallman <rms@gnu.org>
parents: 15839
diff changeset
2088 if (nb_buttons >= 9)
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2089 {
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2090 free_menubar_widget_value_tree (first_wv);
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2091 *error_name = "Too many dialog items";
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2092 return Qnil;
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2093 }
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2094
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
2095 wv = xmalloc_widget_value ();
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2096 prev_wv->next = wv;
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2097 wv->name = (char *) button_names[nb_buttons];
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2098 if (!NILP (descrip))
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2099 wv->key = (char *) SDATA (descrip);
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2100 wv->value = (char *) SDATA (item_name);
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2101 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
2102 wv->enabled = !NILP (enable);
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
2103 wv->help = Qnil;
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2104 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
2105
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2106 if (! boundary_seen)
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2107 left_count++;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2108
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2109 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
2110 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
2111 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2112
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2113 /* If the boundary was not specified,
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2114 by default put half on the left and half on the right. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2115 if (! boundary_seen)
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2116 left_count = nb_buttons - nb_buttons / 2;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2117
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
2118 wv = xmalloc_widget_value ();
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2119 wv->name = dialog_name;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
2120 wv->help = Qnil;
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2121
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2122 /* Frame title: 'Q' = Question, 'I' = Information.
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2123 Can also have 'E' = Error if, one day, we want
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2124 a popup for errors. */
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2125 if (NILP(header))
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2126 dialog_name[0] = 'Q';
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2127 else
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2128 dialog_name[0] = 'I';
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2129
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2130 /* Dialog boxes use a really stupid name encoding
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2131 which specifies how many buttons to use
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
2132 and how many buttons are on the right. */
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2133 dialog_name[1] = '0' + nb_buttons;
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2134 dialog_name[2] = 'B';
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2135 dialog_name[3] = 'R';
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2136 /* Number of buttons to put on the right. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2137 dialog_name[4] = '0' + nb_buttons - left_count;
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
2138 dialog_name[5] = 0;
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2139 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
2140 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
2141 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2142
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2143 /* 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
2144 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
2145
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2146 /* Actually create and show the dialog. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2147 create_and_show_dialog (f, first_wv);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2148
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2149 /* Free the widget_value objects we used to specify the contents. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2150 free_menubar_widget_value_tree (first_wv);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2151
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2152 /* Find the selected item, and its pane, to return
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2153 the proper value. */
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2154 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
2155 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2156 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
2157
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2158 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
2159 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
2160 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
2161 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2162 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
2163
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2164 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
2165 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2166 prefix
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2167 = 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
2168 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
2169 }
31465
b58d8e366faa (xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents: 31365
diff changeset
2170 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
b58d8e366faa (xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents: 31365
diff changeset
2171 {
b58d8e366faa (xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents: 31365
diff changeset
2172 /* This is the boundary between left-side elts and
b58d8e366faa (xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents: 31365
diff changeset
2173 right-side elts. */
b58d8e366faa (xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents: 31365
diff changeset
2174 ++i;
b58d8e366faa (xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents: 31365
diff changeset
2175 }
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2176 else
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2177 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2178 entry
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2179 = 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
2180 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
2181 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2182 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
2183 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2184 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
2185 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
2186 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
2187 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2188 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
2189 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2190 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
2191 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2192 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2193 }
59102
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
2194 else
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
2195 /* Make "Cancel" equivalent to C-g. */
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
2196 Fsignal (Qquit, Qnil);
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2197
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2198 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
2199 }
30299
f2cd2bf063c9 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30215
diff changeset
2200
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2201 #else /* not USE_X_TOOLKIT && not USE_GTK */
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2202
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2203 /* The frame of the last activated non-toolkit menu bar.
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2204 Used to generate menu help events. */
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2205
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2206 static struct frame *menu_help_frame;
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2207
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2208
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2209 /* Show help HELP_STRING, or clear help if HELP_STRING is null.
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2210
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2211 PANE is the pane number, and ITEM is the menu item number in
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2212 the menu (currently not used).
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2213
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2214 This cannot be done with generating a HELP_EVENT because
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2215 XMenuActivate contains a loop that doesn't let Emacs process
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2216 keyboard events. */
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2217
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2218 static void
109374
88a5b905a895 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109372
diff changeset
2219 menu_help_callback (char *help_string, int pane, int item)
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2220 {
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2221 extern Lisp_Object Qmenu_item;
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2222 Lisp_Object *first_item;
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2223 Lisp_Object pane_name;
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2224 Lisp_Object menu_object;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2225
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2226 first_item = XVECTOR (menu_items)->contents;
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2227 if (EQ (first_item[0], Qt))
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2228 pane_name = first_item[MENU_ITEMS_PANE_NAME];
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2229 else if (EQ (first_item[0], Qquote))
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2230 /* This shouldn't happen, see xmenu_show. */
81273
13e433477b6c (menu_help_callback): Use empty_unibyte_string, not empty_string.
Juanma Barranquero <lekktu@gmail.com>
parents: 77513
diff changeset
2231 pane_name = empty_unibyte_string;
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2232 else
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2233 pane_name = first_item[MENU_ITEMS_ITEM_NAME];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2234
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2235 /* (menu-item MENU-NAME PANE-NUMBER) */
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2236 menu_object = Fcons (Qmenu_item,
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2237 Fcons (pane_name,
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2238 Fcons (make_number (pane), Qnil)));
30299
f2cd2bf063c9 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30215
diff changeset
2239 show_help_echo (help_string ? build_string (help_string) : Qnil,
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
2240 Qnil, menu_object, make_number (item), 1);
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2241 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2242
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2243 static Lisp_Object
109374
88a5b905a895 Convert function definitions to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109372
diff changeset
2244 pop_down_menu (Lisp_Object arg)
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2245 {
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2246 struct Lisp_Save_Value *p1 = XSAVE_VALUE (Fcar (arg));
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2247 struct Lisp_Save_Value *p2 = XSAVE_VALUE (Fcdr (arg));
61619
489414dfb069 Remove eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 60890
diff changeset
2248
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2249 FRAME_PTR f = p1->pointer;
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2250 XMenu *menu = p2->pointer;
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2251
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2252 BLOCK_INPUT;
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2253 #ifndef MSDOS
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2254 XUngrabPointer (FRAME_X_DISPLAY (f), CurrentTime);
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2255 XUngrabKeyboard (FRAME_X_DISPLAY (f), CurrentTime);
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2256 #endif
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2257 XMenuDestroy (FRAME_X_DISPLAY (f), menu);
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2258
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2259 #ifdef HAVE_X_WINDOWS
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2260 /* Assume the mouse has moved out of the X window.
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2261 If it has actually moved in, we will get an EnterNotify. */
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2262 x_mouse_leave (FRAME_X_DISPLAY_INFO (f));
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2263
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2264 /* State that no mouse buttons are now held.
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2265 (The oldXMenu code doesn't track this info for us.)
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2266 That is not necessarily true, but the fiction leads to reasonable
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2267 results, and it is a pain to ask which are actually held now. */
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2268 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2269
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2270 #endif /* HAVE_X_WINDOWS */
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2271
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2272 UNBLOCK_INPUT;
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2273
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2274 return Qnil;
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2275 }
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2276
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2277
105931
a5db20cb0a5a xmenu.c (xmenu_show): Must not be static after 2009-11-09 changes.
Jan Djärv <jan.h.d@swipnet.se>
parents: 105923
diff changeset
2278 Lisp_Object
109440
f8f118e78387 * xmenu.c (create_and_show_popup_menu, xmenu_show): Fix type of timestamp argument.
Andreas Schwab <schwab@linux-m68k.org>
parents: 109391
diff changeset
2279 xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
f8f118e78387 * xmenu.c (create_and_show_popup_menu, xmenu_show): Fix type of timestamp argument.
Andreas Schwab <schwab@linux-m68k.org>
parents: 109391
diff changeset
2280 Lisp_Object title, char **error, EMACS_UINT timestamp)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2281 {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2282 Window root;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2283 XMenu *menu;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2284 int pane, selidx, lpane, status;
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2285 Lisp_Object entry, pane_prefix;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2286 char *datap;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2287 int ulx, uly, width, height;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2288 int dispwidth, dispheight;
58824
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2289 int i, j, lines, maxlines;
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2290 int maxwidth;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2291 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
2292 unsigned int dummy_uint;
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2293 int specpdl_count = SPECPDL_INDEX ();
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
2294
97645
229acec13840 (Fx_popup_dialog, Fx_popup_menu, xmenu_show): Allow MSDOS frames along with
Eli Zaretskii <eliz@gnu.org>
parents: 97204
diff changeset
2295 if (! FRAME_X_P (f) && ! FRAME_MSDOS_P (f))
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2296 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2297
3747
6506b2fd475a (xmenu_show): Store 0 in *ERROR at the beginning.
Richard M. Stallman <rms@gnu.org>
parents: 3501
diff changeset
2298 *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
2299 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
2300 return Qnil;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
2301
7335
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
2302 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
2303 {
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
2304 *error = "Empty menu";
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
2305 return Qnil;
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
2306 }
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
2307
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2308 /* Figure out which root window F is on. */
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2309 XGetGeometry (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &root,
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2310 &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
2311 &dummy_uint, &dummy_uint);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2312
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2313 /* Make the menu on that window. */
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2314 menu = XMenuCreate (FRAME_X_DISPLAY (f), root, "emacs");
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2315 if (menu == NULL)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2316 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2317 *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
2318 return Qnil;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2319 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2320
67743
3c879987313f (xmenu_show): Call inhibit_garbage_collection.
Richard M. Stallman <rms@gnu.org>
parents: 67703
diff changeset
2321 /* Don't GC while we prepare and show the menu,
3c879987313f (xmenu_show): Call inhibit_garbage_collection.
Richard M. Stallman <rms@gnu.org>
parents: 67703
diff changeset
2322 because we give the oldxmenu library pointers to the
3c879987313f (xmenu_show): Call inhibit_garbage_collection.
Richard M. Stallman <rms@gnu.org>
parents: 67703
diff changeset
2323 contents of strings. */
3c879987313f (xmenu_show): Call inhibit_garbage_collection.
Richard M. Stallman <rms@gnu.org>
parents: 67703
diff changeset
2324 inhibit_garbage_collection ();
3c879987313f (xmenu_show): Call inhibit_garbage_collection.
Richard M. Stallman <rms@gnu.org>
parents: 67703
diff changeset
2325
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9546
diff changeset
2326 #ifdef HAVE_X_WINDOWS
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2327 /* Adjust coordinates to relative to the outer (window manager) window. */
58824
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2328 x += FRAME_OUTER_TO_INNER_DIFF_X (f);
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2329 y += FRAME_OUTER_TO_INNER_DIFF_Y (f);
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9546
diff changeset
2330 #endif /* HAVE_X_WINDOWS */
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2331
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2332 /* Adjust coordinates to be root-window-relative. */
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
2333 x += f->left_pos;
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
2334 y += f->top_pos;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2335
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2336 /* Create all the necessary panes and their items. */
58824
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2337 maxlines = lines = i = 0;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2338 while (i < menu_items_used)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2339 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2340 if (EQ (XVECTOR (menu_items)->contents[i], Qt))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2341 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2342 /* 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
2343 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
2344 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
2345
58824
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2346 maxlines = max (maxlines, lines);
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2347 lines = 0;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2348 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
2349 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
2350 pane_string = (NILP (pane_name)
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2351 ? "" : (char *) SDATA (pane_name));
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2352 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
2353 pane_string++;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2354
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2355 lpane = XMenuAddPane (FRAME_X_DISPLAY (f), menu, pane_string, TRUE);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2356 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
2357 {
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2358 XMenuDestroy (FRAME_X_DISPLAY (f), menu);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2359 *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
2360 return Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2361 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2362 i += MENU_ITEMS_PANE_LENGTH;
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2363
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2364 /* Find the width of the widest item in this pane. */
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2365 maxwidth = 0;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2366 j = i;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2367 while (j < menu_items_used)
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2368 {
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2369 Lisp_Object item;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2370 item = XVECTOR (menu_items)->contents[j];
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2371 if (EQ (item, Qt))
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2372 break;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2373 if (NILP (item))
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2374 {
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2375 j++;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2376 continue;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2377 }
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2378 width = SBYTES (item);
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2379 if (width > maxwidth)
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2380 maxwidth = width;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2381
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2382 j += MENU_ITEMS_ITEM_LENGTH;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2383 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2384 }
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2385 /* Ignore a nil in the item list.
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2386 It's meaningful only for dialog boxes. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2387 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2388 i += 1;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2389 else
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2390 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2391 /* Create a new item within current pane. */
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2392 Lisp_Object item_name, enable, descrip, help;
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2393 unsigned char *item_data;
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2394 char *help_string;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2395
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2396 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
2397 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
2398 descrip
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2399 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2400 help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP];
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2401 help_string = STRINGP (help) ? SDATA (help) : NULL;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2402
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2403 if (!NILP (descrip))
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2404 {
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2405 int gap = maxwidth - SBYTES (item_name);
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2406 /* if alloca is fast, use that to make the space,
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2407 to reduce gc needs. */
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2408 item_data
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2409 = (unsigned char *) alloca (maxwidth
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2410 + SBYTES (descrip) + 1);
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109126
diff changeset
2411 memcpy (item_data, SDATA (item_name), SBYTES (item_name));
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2412 for (j = SCHARS (item_name); j < maxwidth; j++)
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2413 item_data[j] = ' ';
109165
750db9f3e6d8 Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
Andreas Schwab <schwab@linux-m68k.org>
parents: 109126
diff changeset
2414 memcpy (item_data + j, SDATA (descrip), SBYTES (descrip));
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2415 item_data[j + SBYTES (descrip)] = 0;
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2416 }
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2417 else
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
2418 item_data = SDATA (item_name);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2419
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2420 if (XMenuAddSelection (FRAME_X_DISPLAY (f),
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2421 menu, lpane, 0, item_data,
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2422 !NILP (enable), help_string)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2423 == XM_FAILURE)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2424 {
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2425 XMenuDestroy (FRAME_X_DISPLAY (f), menu);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2426 *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
2427 return Qnil;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2428 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2429 i += MENU_ITEMS_ITEM_LENGTH;
58824
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2430 lines++;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2431 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2432 }
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2433
58824
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2434 maxlines = max (maxlines, lines);
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2435
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2436 /* All set and ready to fly. */
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2437 XMenuRecompute (FRAME_X_DISPLAY (f), menu);
37255
ff709975abaf (xmenu_show): Use FRAME_X_SCREEN_NUMBER.
Gerd Moellmann <gerd@gnu.org>
parents: 37211
diff changeset
2438 dispwidth = DisplayWidth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f));
ff709975abaf (xmenu_show): Use FRAME_X_SCREEN_NUMBER.
Gerd Moellmann <gerd@gnu.org>
parents: 37211
diff changeset
2439 dispheight = DisplayHeight (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f));
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2440 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
2441 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
2442 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
2443 y = max (y, 1);
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2444 XMenuLocate (FRAME_X_DISPLAY (f), menu, 0, 0, x, y,
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2445 &ulx, &uly, &width, &height);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2446 if (ulx+width > dispwidth)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2447 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2448 x -= (ulx + width) - dispwidth;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2449 ulx = dispwidth - width;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2450 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2451 if (uly+height > dispheight)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2452 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2453 y -= (uly + height) - dispheight;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2454 uly = dispheight - height;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2455 }
98035
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2456 #ifndef HAVE_X_WINDOWS
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2457 if (FRAME_HAS_MINIBUF_P (f) && uly+height > dispheight - 1)
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2458 {
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2459 /* Move the menu away of the echo area, to avoid overwriting the
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2460 menu with help echo messages or vice versa. */
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2461 if (BUFFERP (echo_area_buffer[0]) && WINDOWP (echo_area_window))
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2462 {
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2463 y -= WINDOW_TOTAL_LINES (XWINDOW (echo_area_window));
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2464 uly -= WINDOW_TOTAL_LINES (XWINDOW (echo_area_window));
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2465 }
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2466 else
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2467 {
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2468 y--;
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2469 uly--;
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2470 }
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2471 }
611a022eaebb (xmenu_show) [!HAVE_X_WINDOWS]: If frame has a minibuffer, don't let lower
Eli Zaretskii <eliz@gnu.org>
parents: 97645
diff changeset
2472 #endif
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2473 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
2474 if (uly < 0) y -= uly;
6526
95661fd7a320 (xmenu_show): Enable asynchronous events.
Karl Heuer <kwzh@gnu.org>
parents: 6481
diff changeset
2475
58824
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2476 if (! for_click)
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2477 {
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2478 /* If position was not given by a mouse click, adjust so upper left
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2479 corner of the menu as a whole ends up at given coordinates. This
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2480 is what x-popup-menu says in its documentation. */
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2481 x += width/2;
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2482 y += 1.5*height/(maxlines+2);
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2483 }
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
2484
6526
95661fd7a320 (xmenu_show): Enable asynchronous events.
Karl Heuer <kwzh@gnu.org>
parents: 6481
diff changeset
2485 XMenuSetAEQ (menu, TRUE);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2486 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
2487 pane = selidx = 0;
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2488
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
2489 #ifndef MSDOS
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
2490 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f));
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
2491 #endif
61619
489414dfb069 Remove eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 60890
diff changeset
2492
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2493 record_unwind_protect (pop_down_menu,
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2494 Fcons (make_save_value (f, 0),
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2495 make_save_value (menu, 0)));
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
2496
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2497 /* Help display under X won't work because XMenuActivate contains
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2498 a loop that doesn't give Emacs a chance to process it. */
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
2499 menu_help_frame = f;
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
2500 status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx,
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2501 x, y, ButtonReleaseMask, &datap,
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2502 menu_help_callback);
10167
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
2503
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2504 switch (status)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2505 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2506 case XM_SUCCESS:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2507 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2508 fprintf (stderr, "pane= %d line = %d\n", panes, selidx);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2509 #endif
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2510
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2511 /* 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
2512 i = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2513 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
2514 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2515 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
2516 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2517 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
2518 pane_prefix
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2519 = 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
2520 pane--;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2521 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
2522 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2523 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2524 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2525 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
2526 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2527 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
2528 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2529 entry
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2530 = 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
2531 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
2532 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2533 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
2534 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
2535 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
2536 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2537 break;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2538 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2539 selidx--;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2540 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2541 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
2542 }
2747
f258c79c9162 (Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents: 2514
diff changeset
2543 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2544 break;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2545
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2546 case XM_FAILURE:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2547 *error = "Can't activate menu";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2548 case XM_IA_SELECT:
59102
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
2549 entry = Qnil;
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
2550 break;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2551 case XM_NO_SELECT:
61984
2ce055c7db65 [not HAVE_X_TOOLKIT] (xmenu_show):
Richard M. Stallman <rms@gnu.org>
parents: 61620
diff changeset
2552 /* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means
2ce055c7db65 [not HAVE_X_TOOLKIT] (xmenu_show):
Richard M. Stallman <rms@gnu.org>
parents: 61620
diff changeset
2553 the menu was invoked with a mouse event as POSITION). */
59102
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
2554 if (! for_click)
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
2555 Fsignal (Qquit, Qnil);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2556 entry = Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2557 break;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2558 }
58197
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2559
6c24ca598cb1 * xmenu.c (unuse_menu_items, pop_down_menu): Arg is of type
Jan Djärv <jan.h.d@swipnet.se>
parents: 58171
diff changeset
2560 unbind_to (specpdl_count, Qnil);
7208
2d3c771ff861 (xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents: 7175
diff changeset
2561
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2562 return entry;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2563 }
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2564
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2565 #endif /* not USE_X_TOOLKIT */
14741
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
2566
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
2567 #endif /* HAVE_MENUS */
73788
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2568
73941
b662c7bb9e5f (popup_activated): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73788
diff changeset
2569 /* Detect if a dialog or menu has been posted. */
b662c7bb9e5f (popup_activated): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73788
diff changeset
2570
b662c7bb9e5f (popup_activated): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73788
diff changeset
2571 int
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
2572 popup_activated (void)
73941
b662c7bb9e5f (popup_activated): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73788
diff changeset
2573 {
b662c7bb9e5f (popup_activated): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73788
diff changeset
2574 return popup_activated_flag;
b662c7bb9e5f (popup_activated): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73788
diff changeset
2575 }
73788
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2576
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2577 /* The following is used by delayed window autoselection. */
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2578
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2579 DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_p, 0, 0, 0,
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2580 doc: /* Return t if a menu or popup dialog is active. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109174
diff changeset
2581 (void)
73788
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2582 {
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2583 #ifdef HAVE_MENUS
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2584 return (popup_activated ()) ? Qt : Qnil;
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2585 #else
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2586 return Qnil;
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2587 #endif /* HAVE_MENUS */
177184091f28 (Fmenu_or_popup_active_p): Define outside HAVE_MENUS.
Chong Yidong <cyd@stupidchicken.com>
parents: 73715
diff changeset
2588 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2589
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21268
diff changeset
2590 void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
2591 syms_of_xmenu (void)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2592 {
105877
21bdda3ded62 * xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105693
diff changeset
2593 Qdebug_on_next_call = intern_c_string ("debug-on-next-call");
12625
e2831d2f5b09 (syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents: 12432
diff changeset
2594 staticpro (&Qdebug_on_next_call);
e2831d2f5b09 (syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents: 12432
diff changeset
2595
9336
d5ffd9c9edb0 (widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents: 9236
diff changeset
2596 #ifdef USE_X_TOOLKIT
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2597 widget_id_tick = (1<<16);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2598 next_menubar_widget_id = 1;
9336
d5ffd9c9edb0 (widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents: 9236
diff changeset
2599 #endif
d5ffd9c9edb0 (widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents: 9236
diff changeset
2600
73697
54a6e7ed953c (Fmenu_or_popup_active_p): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 73662
diff changeset
2601 defsubr (&Smenu_or_popup_active_p);
71057
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
2602
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
2603 #if defined (USE_GTK) || defined (USE_X_TOOLKIT)
83542
2d56e13fd23d Merged from emacs@sv.gnu.org
Karoly Lorentey <lorentey@elte.hu>
parents: 83537 73320
diff changeset
2604 defsubr (&Sx_menu_bar_open_internal);
105877
21bdda3ded62 * xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105693
diff changeset
2605 Ffset (intern_c_string ("accelerate-menu"),
21bdda3ded62 * xterm.c (syms_of_xterm):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105693
diff changeset
2606 intern_c_string (Sx_menu_bar_open_internal.symbol_name));
71057
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
2607 #endif
07d4cb17def5 (Fmenu_bar_start): New function for USE_GTK and USE_X_TOOLKIT.
Jan Djärv <jan.h.d@swipnet.se>
parents: 70328
diff changeset
2608
14741
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
2609 #ifdef HAVE_MENUS
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
2610 defsubr (&Sx_popup_dialog);
14741
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
2611 #endif
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2612 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51575
diff changeset
2613
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51575
diff changeset
2614 /* arch-tag: 92ea573c-398e-496e-ac73-2436f7d63242
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51575
diff changeset
2615 (do not change this comment) */