annotate src/xmenu.c @ 83542:2d56e13fd23d

Merged from emacs@sv.gnu.org Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-413 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-414 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-415 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-416 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-417 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-418 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-419 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-420 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-421 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-422 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-423 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-424 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-425 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-426 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-427 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-428 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-429 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-430 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-431 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-432 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-433 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-434 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-435 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-436 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-437 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-438 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-439 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-440 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-441 lisp/url/url-methods.el: Fix format error when http_proxy is empty string * emacs@sv.gnu.org/emacs--devo--0--patch-442 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-443 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-444 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-445 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-446 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-447 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-448 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-449 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-450 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-451 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-452 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-453 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-454 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-455 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-456 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-457 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-458 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-459 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-460 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-461 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-462 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-463 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-464 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-465 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-466 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-467 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-468 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-469 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-470 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-471 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-472 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-473 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-128 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-129 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-130 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-131 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-132 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-133 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-134 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-135 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-136 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-137 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-138 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-139 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-140 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-141 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-142 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-143 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-144 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-145 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-146 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-147 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-148 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-149 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-582
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 14 Oct 2006 17:36:28 +0000
parents c19f348befac 332f0639af48
children c71725faff1a
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,
68651
3bd95f4f2941 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 67743
diff changeset
3 2004, 2005, 2006 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
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 GNU Emacs is free software; you can redistribute it and/or modify
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
1437
36ef55ecb265 * frame.c (make_frame_without_minibuffer, Fwindow_frame): Use
Jim Blandy <jimb@redhat.com>
parents: 1304
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 any later version.
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
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 along with GNU Emacs; see the file COPYING. If not, write to
64084
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63147
diff changeset
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63147
diff changeset
20 Boston, MA 02110-1301, USA. */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
40239
5fda2888718a Spell the name of Emacs properly (GNU Emacs instead of gnuemacs).
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
22 /* X pop-up deck-of-cards menu facility for GNU Emacs.
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 *
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 * Written by Jon Arnold and Roman Budzianowski
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 * Mods and rewrite by Robert Krawitz
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 *
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
29 /* 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
30 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
31
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
32 /* 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
33
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26036
diff changeset
34 #include <config.h>
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 26036
diff changeset
35
62216
0c2ce5566afa Don't include signal.h.
Richard M. Stallman <rms@gnu.org>
parents: 62090
diff changeset
36 #if 0 /* Why was this included? And without syssignal.h? */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 /* On 4.3 this loses if it comes after xterm.h. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 #include <signal.h>
62216
0c2ce5566afa Don't include signal.h.
Richard M. Stallman <rms@gnu.org>
parents: 62090
diff changeset
39 #endif
7900
60795e826dad Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents: 7871
diff changeset
40
60795e826dad Put stdio.h after config.h.
Richard M. Stallman <rms@gnu.org>
parents: 7871
diff changeset
41 #include <stdio.h>
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39914
diff changeset
42
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 #include "lisp.h"
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32179
diff changeset
44 #include "keyboard.h"
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
45 #include "keymap.h"
770
4de9c9a62bda entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
46 #include "frame.h"
83004
7900111db01c Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents: 53325
diff changeset
47 #include "termhooks.h"
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 #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
49 #include "blockinput.h"
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
50 #include "buffer.h"
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
51 #include "charset.h"
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
52 #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
53 #include "sysselect.h"
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54
10502
1b08df5c5e4a [MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents: 10167
diff changeset
55 #ifdef MSDOS
1b08df5c5e4a [MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents: 10167
diff changeset
56 #include "msdos.h"
1b08df5c5e4a [MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents: 10167
diff changeset
57 #endif
1b08df5c5e4a [MSDOS]: #include msdos.h.
Richard M. Stallman <rms@gnu.org>
parents: 10167
diff changeset
58
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9546
diff changeset
59 #ifdef HAVE_X_WINDOWS
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 /* This may include sys/types.h, and that somehow loses
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 if this is not done before the other system files. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 #include "xterm.h"
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9546
diff changeset
63 #endif
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 /* Load sys/types.h if not already loaded.
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 In some systems loading it twice is suicidal. */
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 #ifndef makedev
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 #include <sys/types.h>
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 #endif
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 #include "dispextern.h"
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9546
diff changeset
73 #ifdef HAVE_X_WINDOWS
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
74 /* Defining HAVE_MULTILINGUAL_MENU would mean that the toolkit menu
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
75 code accepts the Emacs internal encoding. */
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
76 #undef HAVE_MULTILINGUAL_MENU
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
77 #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
78 #include "widget.h"
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
79 #include <X11/Xlib.h>
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
80 #include <X11/IntrinsicP.h>
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
81 #include <X11/CoreP.h>
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
82 #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
83 #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
84 #ifdef USE_LUCID
11898
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
85 #include <X11/Xaw/Paned.h>
13489
ddf90bfd3744 Don't include Xaw/Paned.h unless USE_LUCID is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13071
diff changeset
86 #endif /* USE_LUCID */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
87 #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
88 #else /* not USE_X_TOOLKIT */
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
89 #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
90 #include "../oldXMenu/XMenu.h"
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
91 #endif
10167
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
92 #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
93 #endif /* HAVE_X_WINDOWS */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
94
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 #ifndef TRUE
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 #define TRUE 1
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 #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
98 #endif /* no TRUE */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99
12625
e2831d2f5b09 (syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents: 12432
diff changeset
100 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
101
72757
6db6c056fc46 (Vmenu_updating_frame): Don't define here.
Richard M. Stallman <rms@gnu.org>
parents: 71134
diff changeset
102 extern Lisp_Object Vmenu_updating_frame;
6db6c056fc46 (Vmenu_updating_frame): Don't define here.
Richard M. Stallman <rms@gnu.org>
parents: 71134
diff changeset
103
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
104 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
105
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
106 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
107
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
108 extern Lisp_Object Voverriding_local_map;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
109 extern Lisp_Object Voverriding_local_map_menu_flag;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
110
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
111 extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
112
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
113 extern Lisp_Object Qmenu_bar_update_hook;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
114
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
115 #ifdef USE_X_TOOLKIT
57814
1f473607c4a9 * xmenu.c: Add prototypes for forward function declarations.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56959
diff changeset
116 extern void set_frame_menubar P_ ((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
117 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
118
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
119 static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, Lisp_Object,
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
120 char **));
57814
1f473607c4a9 * xmenu.c: Add prototypes for forward function declarations.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56959
diff changeset
121 static void popup_get_selection P_ ((XEvent *, struct x_display_info *,
59156
03a6e350cf4d (popup_get_selection): Remove parameter down_on_keypress.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59155
diff changeset
122 LWLIB_ID, int));
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
123
40239
5fda2888718a Spell the name of Emacs properly (GNU Emacs instead of gnuemacs).
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
124 /* Define HAVE_BOXES if menus can handle radio and toggle buttons. */
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
125
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
126 #define HAVE_BOXES 1
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
127 #endif /* USE_X_TOOLKIT */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
128
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
129 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
130 #include "gtkutil.h"
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
131 #define HAVE_BOXES 1
57814
1f473607c4a9 * xmenu.c: Add prototypes for forward function declarations.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56959
diff changeset
132 extern void set_frame_menubar P_ ((FRAME_PTR, int, int));
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
133 static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, Lisp_Object,
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
134 char **));
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
135 #endif
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
136
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
137 /* This is how to deal with multibyte text if HAVE_MULTILINGUAL_MENU
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
138 isn't defined. The use of HAVE_MULTILINGUAL_MENU could probably be
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
139 confined to an extended version of this with sections of code below
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
140 using it unconditionally. */
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
141 #ifdef USE_GTK
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
142 /* gtk just uses utf-8. */
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
143 # define ENCODE_MENU_STRING(str) ENCODE_UTF_8 (str)
60658
2b7e54e81973 (ENCODE_MENU_STRING) [HAVE_X_I18N]: Use ENCODE_SYSTEM.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60583
diff changeset
144 #elif defined HAVE_X_I18N
2b7e54e81973 (ENCODE_MENU_STRING) [HAVE_X_I18N]: Use ENCODE_SYSTEM.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60583
diff changeset
145 # define ENCODE_MENU_STRING(str) ENCODE_SYSTEM (str)
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
146 #else
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
147 # define ENCODE_MENU_STRING(str) string_make_unibyte (str)
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
148 #endif
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
149
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
150 static void push_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
151 Lisp_Object, Lisp_Object, Lisp_Object,
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
152 Lisp_Object, Lisp_Object));
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
153 static int update_frame_menubar P_ ((struct frame *));
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
154 static Lisp_Object xmenu_show P_ ((struct frame *, int, int, int, int,
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
155 Lisp_Object, char **));
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
156 static void keymap_panes P_ ((Lisp_Object *, int, int));
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
157 static void single_keymap_panes P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
158 int, int));
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
159 static void list_of_panes P_ ((Lisp_Object));
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
160 static void list_of_items P_ ((Lisp_Object));
48912
b0b74923fe41 (popup_get_selection): Now static. New arg DO_TIMERS.
Richard M. Stallman <rms@gnu.org>
parents: 48329
diff changeset
161
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
162
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
163 /* This holds a Lisp vector that holds the results of decoding
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
164 the keymaps or alist-of-alists that specify a menu.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
165
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
166 It describes the panes and items within the panes.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
167
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
168 Each pane is described by 3 elements in the vector:
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
169 t, the pane name, the pane's prefix key.
10167
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
170 Then follow the pane's items, with 5 elements per item:
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
171 the item string, the enable flag, the item's value,
10167
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
172 the definition, and the equivalent keyboard key's description string.
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
173
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
174 In some cases, multiple levels of menus may be described.
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
175 A single vector slot containing nil indicates the start of a submenu.
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
176 A single vector slot containing lambda indicates the end of a submenu.
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
177 The submenu follows a menu item which is the way to reach the submenu.
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
178
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
179 A single vector slot containing quote indicates that the
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
180 following items should appear on the right of a dialog box.
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
181
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
182 Using a Lisp vector to hold this information while we decode it
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
183 takes care of protecting all the data from GC. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
184
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
185 #define MENU_ITEMS_PANE_NAME 1
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
186 #define MENU_ITEMS_PANE_PREFIX 2
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
187 #define MENU_ITEMS_PANE_LENGTH 3
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
188
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
189 enum menu_item_idx
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
190 {
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
191 MENU_ITEMS_ITEM_NAME = 0,
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
192 MENU_ITEMS_ITEM_ENABLE,
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
193 MENU_ITEMS_ITEM_VALUE,
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
194 MENU_ITEMS_ITEM_EQUIV_KEY,
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
195 MENU_ITEMS_ITEM_DEFINITION,
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
196 MENU_ITEMS_ITEM_TYPE,
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
197 MENU_ITEMS_ITEM_SELECTED,
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
198 MENU_ITEMS_ITEM_HELP,
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
199 MENU_ITEMS_ITEM_LENGTH
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
200 };
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
201
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
202 static Lisp_Object menu_items;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
203
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
204 /* If non-nil, means that the global vars defined here are already in use.
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
205 Used to detect cases where we try to re-enter this non-reentrant code. */
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
206 static Lisp_Object menu_items_inuse;
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
207
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
208 /* Number of slots currently allocated in menu_items. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
209 static int menu_items_allocated;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
210
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
211 /* This is the index in menu_items of the first empty slot. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
212 static int menu_items_used;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
213
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
214 /* The number of panes currently recorded in menu_items,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
215 excluding those within submenus. */
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
216 static int menu_items_n_panes;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
217
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
218 /* Current depth within submenus. */
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
219 static int menu_items_submenu_depth;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
220
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
221 /* 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
222 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
223 static int popup_activated_flag;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
224
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
225 static int next_menubar_widget_id;
15792
feeb1f7c1cec (pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15785
diff changeset
226
15807
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
227 /* This is set nonzero after the user activates the menu bar, and set
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
228 to zero again after the menu bars are redisplayed by prepare_menu_bar.
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
229 While it is nonzero, all calls to set_frame_menubar go deep.
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
230
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
231 I don't understand why this is needed, but it does seem to be
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
232 needed on Motif, according to Marcus Daniels <marcus@sysc.pdx.edu>. */
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
233
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
234 int pending_menu_activation;
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
235
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
236 #ifdef USE_X_TOOLKIT
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
237
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
238 /* 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
239
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
240 static struct frame *
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
241 menubar_id_to_frame (id)
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
242 LWLIB_ID id;
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
243 {
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
244 Lisp_Object tail, frame;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
245 FRAME_PTR f;
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
246
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25322
diff changeset
247 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
248 {
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25322
diff changeset
249 frame = XCAR (tail);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
250 if (!GC_FRAMEP (frame))
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
251 continue;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
252 f = XFRAME (frame);
26729
f5dded41adcc Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents: 26088
diff changeset
253 if (!FRAME_WINDOW_P (f))
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
254 continue;
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
255 if (f->output_data.x->id == id)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
256 return f;
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
257 }
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
258 return 0;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
259 }
11237
7c968b691ff0 (frame_vector): New static variable.
Richard M. Stallman <rms@gnu.org>
parents: 11125
diff changeset
260
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
261 #endif
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
262
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
263 /* Initialize the menu_items structure if we haven't already done so.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
264 Also mark it as currently empty. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
265
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
266 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
267 init_menu_items ()
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
268 {
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
269 if (!NILP (menu_items_inuse))
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
270 error ("Trying to use a menu from within a menu-entry");
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
271
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
272 if (NILP (menu_items))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
273 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
274 menu_items_allocated = 60;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
275 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
276 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
277
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
278 menu_items_inuse = Qt;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
279 menu_items_used = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
280 menu_items_n_panes = 0;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
281 menu_items_submenu_depth = 0;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
282 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
283
41769
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
284 /* Call at the end of generating the data in menu_items. */
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
285
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
286 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
287 finish_menu_items ()
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
288 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
289 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
290
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
291 static Lisp_Object
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
292 unuse_menu_items (dummy)
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
293 Lisp_Object dummy;
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
294 {
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
295 return menu_items_inuse = Qnil;
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
296 }
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
297
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
298 /* Call when finished using the data for the current menu
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
299 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
300
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
301 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
302 discard_menu_items ()
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
303 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
304 /* Free the structure if it is especially large.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
305 Otherwise, hold on to it, to save time. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
306 if (menu_items_allocated > 200)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
307 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
308 menu_items = Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
309 menu_items_allocated = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
310 }
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
311 xassert (NILP (menu_items_inuse));
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
312 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
313
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
314 /* This undoes save_menu_items, and it is called by the specpdl unwind
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
315 mechanism. */
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
316
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
317 static Lisp_Object
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
318 restore_menu_items (saved)
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
319 Lisp_Object saved;
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
320 {
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
321 menu_items = XCAR (saved);
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
322 menu_items_inuse = (! NILP (menu_items) ? Qt : Qnil);
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
323 menu_items_allocated = (VECTORP (menu_items) ? ASIZE (menu_items) : 0);
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
324 saved = XCDR (saved);
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
325 menu_items_used = XINT (XCAR (saved));
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
326 saved = XCDR (saved);
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
327 menu_items_n_panes = XINT (XCAR (saved));
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
328 saved = XCDR (saved);
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
329 menu_items_submenu_depth = XINT (XCAR (saved));
70328
cd5b1fdef8d6 (restore_menu_items): Return a value.
Andreas Schwab <schwab@suse.de>
parents: 70086
diff changeset
330 return Qnil;
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
331 }
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
332
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
333 /* Push the whole state of menu_items processing onto the specpdl.
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
334 It will be restored when the specpdl is unwound. */
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
335
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
336 static void
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
337 save_menu_items ()
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
338 {
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
339 Lisp_Object saved = list4 (!NILP (menu_items_inuse) ? menu_items : Qnil,
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
340 make_number (menu_items_used),
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
341 make_number (menu_items_n_panes),
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
342 make_number (menu_items_submenu_depth));
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
343 record_unwind_protect (restore_menu_items, saved);
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
344 menu_items_inuse = Qnil;
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
345 menu_items = Qnil;
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
346 }
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
347
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
348 /* Make the menu_items vector twice as large. */
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
349
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
350 static void
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
351 grow_menu_items ()
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
352 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
353 Lisp_Object old;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
354 int old_size = menu_items_allocated;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
355 old = menu_items;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
356
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
357 menu_items_allocated *= 2;
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
358
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
359 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
360 bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
361 old_size * sizeof (Lisp_Object));
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
362 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
363
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
364 /* Begin a submenu. */
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
365
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
366 static void
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
367 push_submenu_start ()
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
368 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
369 if (menu_items_used + 1 > menu_items_allocated)
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
370 grow_menu_items ();
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
371
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
372 XVECTOR (menu_items)->contents[menu_items_used++] = Qnil;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
373 menu_items_submenu_depth++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
374 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
375
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
376 /* End a submenu. */
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
377
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
378 static void
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
379 push_submenu_end ()
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
380 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
381 if (menu_items_used + 1 > menu_items_allocated)
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
382 grow_menu_items ();
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
383
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
384 XVECTOR (menu_items)->contents[menu_items_used++] = Qlambda;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
385 menu_items_submenu_depth--;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
386 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
387
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
388 /* Indicate boundary between left and right. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
389
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
390 static void
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
391 push_left_right_boundary ()
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
392 {
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
393 if (menu_items_used + 1 > menu_items_allocated)
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
394 grow_menu_items ();
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
395
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
396 XVECTOR (menu_items)->contents[menu_items_used++] = Qquote;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
397 }
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
398
40239
5fda2888718a Spell the name of Emacs properly (GNU Emacs instead of gnuemacs).
Pavel Janík <Pavel@Janik.cz>
parents: 39988
diff changeset
399 /* Start a new menu pane in menu_items.
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
400 NAME is the pane name. PREFIX_VEC is a prefix key for this pane. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
401
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
402 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
403 push_menu_pane (name, prefix_vec)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
404 Lisp_Object name, prefix_vec;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
405 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
406 if (menu_items_used + MENU_ITEMS_PANE_LENGTH > menu_items_allocated)
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
407 grow_menu_items ();
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
408
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
409 if (menu_items_submenu_depth == 0)
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
410 menu_items_n_panes++;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
411 XVECTOR (menu_items)->contents[menu_items_used++] = Qt;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
412 XVECTOR (menu_items)->contents[menu_items_used++] = name;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
413 XVECTOR (menu_items)->contents[menu_items_used++] = prefix_vec;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
414 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
416 /* Push one menu item into the current pane. NAME is the string to
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
417 display. ENABLE if non-nil means this item can be selected. KEY
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
418 is the key generated by choosing this item, or nil if this item
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
419 doesn't really have a definition. DEF is the definition of this
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
420 item. EQUIV is the textual description of the keyboard equivalent
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
421 for this item (or nil if none). TYPE is the type of this menu
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
422 item, one of nil, `toggle' or `radio'. */
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
423
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
424 static void
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
425 push_menu_item (name, enable, key, def, equiv, type, selected, help)
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
426 Lisp_Object name, enable, key, def, equiv, type, selected, help;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
427 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
428 if (menu_items_used + MENU_ITEMS_ITEM_LENGTH > menu_items_allocated)
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
429 grow_menu_items ();
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
430
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
431 XVECTOR (menu_items)->contents[menu_items_used++] = name;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
432 XVECTOR (menu_items)->contents[menu_items_used++] = enable;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
433 XVECTOR (menu_items)->contents[menu_items_used++] = key;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
434 XVECTOR (menu_items)->contents[menu_items_used++] = equiv;
10167
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
435 XVECTOR (menu_items)->contents[menu_items_used++] = def;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
436 XVECTOR (menu_items)->contents[menu_items_used++] = type;
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
437 XVECTOR (menu_items)->contents[menu_items_used++] = selected;
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
438 XVECTOR (menu_items)->contents[menu_items_used++] = help;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
439 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
440
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
441 /* Look through KEYMAPS, a vector of keymaps that is NMAPS long,
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
442 and generate menu panes for them in menu_items.
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
443 If NOTREAL is nonzero,
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
444 don't bother really computing whether an item is enabled. */
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
445
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
446 static void
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
447 keymap_panes (keymaps, nmaps, notreal)
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
448 Lisp_Object *keymaps;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
449 int nmaps;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
450 int notreal;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
451 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
452 int mapno;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
453
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
454 init_menu_items ();
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
455
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
456 /* Loop over the given keymaps, making a pane for each map.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
457 But don't make a pane that is empty--ignore that map instead.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
458 P is the number of panes we have made so far. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
459 for (mapno = 0; mapno < nmaps; mapno++)
30420
3ed29d254c6c (keymap_panes): Pass the keymap's prompt as the pane
Eli Zaretskii <eliz@gnu.org>
parents: 30363
diff changeset
460 single_keymap_panes (keymaps[mapno],
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
461 Fkeymap_prompt (keymaps[mapno]), Qnil, notreal, 10);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
462
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
463 finish_menu_items ();
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
464 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
465
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
466 /* Args passed between single_keymap_panes and single_menu_item. */
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
467 struct skp
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
468 {
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
469 Lisp_Object pending_maps;
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
470 int maxdepth, notreal;
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
471 int notbuttons;
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
472 };
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
473
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
474 static void single_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
50938
20b3d6c3c7e5 (single_menu_item): Change last parameter to void* to
Andreas Schwab <schwab@suse.de>
parents: 50803
diff changeset
475 void *));
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
476
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
477 /* This is a recursive subroutine of keymap_panes.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
478 It handles one keymap, KEYMAP.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
479 The other arguments are passed along
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
480 or point to local variables of the previous function.
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
481 If NOTREAL is nonzero, only check for equivalent key bindings, don't
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
482 evaluate expressions in menu items and don't make any menu.
16752
6409ef81a2a8 (single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents: 16729
diff changeset
483
6409ef81a2a8 (single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents: 16729
diff changeset
484 If we encounter submenus deeper than MAXDEPTH levels, ignore them. */
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
485
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
486 static void
16752
6409ef81a2a8 (single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents: 16729
diff changeset
487 single_keymap_panes (keymap, pane_name, prefix, notreal, maxdepth)
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
488 Lisp_Object keymap;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
489 Lisp_Object pane_name;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
490 Lisp_Object prefix;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
491 int notreal;
16752
6409ef81a2a8 (single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents: 16729
diff changeset
492 int maxdepth;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 {
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
494 struct skp skp;
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
495 struct gcpro gcpro1;
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
496
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
497 skp.pending_maps = Qnil;
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
498 skp.maxdepth = maxdepth;
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
499 skp.notreal = notreal;
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
500 skp.notbuttons = 0;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
501
16752
6409ef81a2a8 (single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents: 16729
diff changeset
502 if (maxdepth <= 0)
6409ef81a2a8 (single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents: 16729
diff changeset
503 return;
6409ef81a2a8 (single_keymap_panes): New arg DEPTH.
Richard M. Stallman <rms@gnu.org>
parents: 16729
diff changeset
504
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
505 push_menu_pane (pane_name, prefix);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
506
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
507 #ifndef HAVE_BOXES
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
508 /* Remember index for first item in this pane so we can go back and
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
509 add a prefix when (if) we see the first button. After that, notbuttons
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
510 is set to 0, to mark that we have seen a button and all non button
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
511 items need a prefix. */
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
512 skp.notbuttons = menu_items_used;
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
513 #endif
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
514
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
515 GCPRO1 (skp.pending_maps);
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
516 map_keymap (keymap, single_menu_item, Qnil, &skp, 1);
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
517 UNGCPRO;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
518
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
519 /* Process now any submenus which want to be panes at this level. */
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
520 while (CONSP (skp.pending_maps))
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
521 {
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
522 Lisp_Object elt, eltcdr, string;
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
523 elt = XCAR (skp.pending_maps);
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25322
diff changeset
524 eltcdr = XCDR (elt);
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25322
diff changeset
525 string = XCAR (eltcdr);
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
526 /* We no longer discard the @ from the beginning of the string here.
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
527 Instead, we do this in xmenu_show. */
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
528 single_keymap_panes (Fcar (elt), string,
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 25322
diff changeset
529 XCDR (eltcdr), notreal, maxdepth - 1);
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
530 skp.pending_maps = XCDR (skp.pending_maps);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
531 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
533
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
534 /* This is a subroutine of single_keymap_panes that handles one
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
535 keymap entry.
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
536 KEY is a key in a keymap and ITEM is its binding.
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
537 SKP->PENDING_MAPS_PTR is a list of keymaps waiting to be made into
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
538 separate panes.
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
539 If SKP->NOTREAL is nonzero, only check for equivalent key bindings, don't
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
540 evaluate expressions in menu items and don't make any menu.
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
541 If we encounter submenus deeper than SKP->MAXDEPTH levels, ignore them.
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
542 SKP->NOTBUTTONS is only used when simulating toggle boxes and radio
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
543 buttons. It keeps track of if we have seen a button in this menu or
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
544 not. */
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
545
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
546 static void
50938
20b3d6c3c7e5 (single_menu_item): Change last parameter to void* to
Andreas Schwab <schwab@suse.de>
parents: 50803
diff changeset
547 single_menu_item (key, item, dummy, skp_v)
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
548 Lisp_Object key, item, dummy;
50938
20b3d6c3c7e5 (single_menu_item): Change last parameter to void* to
Andreas Schwab <schwab@suse.de>
parents: 50803
diff changeset
549 void *skp_v;
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
550 {
25730
db88a4b84d91 (single_menu_item, Fx_popup_menu, Fx_popup_menu,
Gerd Moellmann <gerd@gnu.org>
parents: 25680
diff changeset
551 Lisp_Object map, item_string, enabled;
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
552 struct gcpro gcpro1, gcpro2;
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
553 int res;
50938
20b3d6c3c7e5 (single_menu_item): Change last parameter to void* to
Andreas Schwab <schwab@suse.de>
parents: 50803
diff changeset
554 struct skp *skp = skp_v;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
555
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
556 /* Parse the menu item and leave the result in item_properties. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
557 GCPRO2 (key, item);
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
558 res = parse_menu_item (item, skp->notreal, 0);
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
559 UNGCPRO;
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
560 if (!res)
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
561 return; /* Not a menu item. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
562
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
563 map = XVECTOR (item_properties)->contents[ITEM_PROPERTY_MAP];
58171
e08eaff3b8ab (pop_down_menu): Return nil.
Kim F. Storm <storm@cua.dk>
parents: 58170
diff changeset
564
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
565 if (skp->notreal)
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
566 {
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
567 /* We don't want to make a menu, just traverse the keymaps to
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
568 precompute equivalent key bindings. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
569 if (!NILP (map))
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
570 single_keymap_panes (map, Qnil, key, 1, skp->maxdepth - 1);
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
571 return;
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
572 }
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
573
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
574 enabled = XVECTOR (item_properties)->contents[ITEM_PROPERTY_ENABLE];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
575 item_string = XVECTOR (item_properties)->contents[ITEM_PROPERTY_NAME];
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
576
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
577 if (!NILP (map) && SREF (item_string, 0) == '@')
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
578 {
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
579 if (!NILP (enabled))
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
580 /* An enabled separate pane. Remember this to handle it later. */
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
581 skp->pending_maps = Fcons (Fcons (map, Fcons (item_string, key)),
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
582 skp->pending_maps);
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
583 return;
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
584 }
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
585
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
586 #ifndef HAVE_BOXES
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
587 /* Simulate radio buttons and toggle boxes by putting a prefix in
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
588 front of them. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
589 {
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
590 Lisp_Object prefix = Qnil;
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
591 Lisp_Object type = XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE];
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
592 if (!NILP (type))
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
593 {
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
594 Lisp_Object selected
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
595 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED];
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
596
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
597 if (skp->notbuttons)
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
598 /* The first button. Line up previous items in this menu. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
599 {
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
600 int index = skp->notbuttons; /* Index for first item this menu. */
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
601 int submenu = 0;
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
602 Lisp_Object tem;
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
603 while (index < menu_items_used)
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
604 {
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
605 tem
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
606 = XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME];
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
607 if (NILP (tem))
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
608 {
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
609 index++;
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
610 submenu++; /* Skip sub menu. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
611 }
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
612 else if (EQ (tem, Qlambda))
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
613 {
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
614 index++;
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
615 submenu--; /* End sub menu. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
616 }
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
617 else if (EQ (tem, Qt))
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
618 index += 3; /* Skip new pane marker. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
619 else if (EQ (tem, Qquote))
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
620 index++; /* Skip a left, right divider. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
621 else
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
622 {
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
623 if (!submenu && SREF (tem, 0) != '\0'
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
624 && SREF (tem, 0) != '-')
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
625 XVECTOR (menu_items)->contents[index + MENU_ITEMS_ITEM_NAME]
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
626 = concat2 (build_string (" "), tem);
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
627 index += MENU_ITEMS_ITEM_LENGTH;
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
628 }
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
629 }
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
630 skp->notbuttons = 0;
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
631 }
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
632
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
633 /* Calculate prefix, if any, for this item. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
634 if (EQ (type, QCtoggle))
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
635 prefix = build_string (NILP (selected) ? "[ ] " : "[X] ");
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
636 else if (EQ (type, QCradio))
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
637 prefix = build_string (NILP (selected) ? "( ) " : "(*) ");
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
638 }
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
639 /* Not a button. If we have earlier buttons, then we need a prefix. */
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
640 else if (!skp->notbuttons && SREF (item_string, 0) != '\0'
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
641 && SREF (item_string, 0) != '-')
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
642 prefix = build_string (" ");
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
643
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
644 if (!NILP (prefix))
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
645 item_string = concat2 (prefix, item_string);
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
646 }
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
647 #endif /* not HAVE_BOXES */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
648
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
649 #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
53069
1218a42792ea Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52981
diff changeset
650 if (!NILP (map))
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
651 /* Indicate visually that this is a submenu. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
652 item_string = concat2 (item_string, build_string (" >"));
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
653 #endif
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
654
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
655 push_menu_item (item_string, enabled, key,
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
656 XVECTOR (item_properties)->contents[ITEM_PROPERTY_DEF],
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
657 XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ],
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
658 XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE],
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
659 XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED],
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
660 XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]);
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
661
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
662 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
663 /* Display a submenu using the toolkit. */
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
664 if (! (NILP (map) || NILP (enabled)))
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
665 {
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
666 push_submenu_start ();
50803
140fa7af01db (struct skp): New struct, to pass args through map_keymap.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49651
diff changeset
667 single_keymap_panes (map, Qnil, key, 0, skp->maxdepth - 1);
21242
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
668 push_submenu_end ();
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
669 }
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
670 #endif
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
671 }
10e1764f84b8 Don't include puresize.h any more as code that needs it
Richard M. Stallman <rms@gnu.org>
parents: 21178
diff changeset
672
14036
621a575db6f7 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13821
diff changeset
673 /* Push all the panes and items of a menu described by the
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
674 alist-of-alists MENU.
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
675 This handles old-fashioned calls to x-popup-menu. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
676
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
677 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
678 list_of_panes (menu)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
679 Lisp_Object menu;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
680 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
681 Lisp_Object tail;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
682
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
683 init_menu_items ();
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
684
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
685 for (tail = menu; CONSP (tail); tail = XCDR (tail))
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
686 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
687 Lisp_Object elt, pane_name, pane_data;
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
688 elt = XCAR (tail);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
689 pane_name = Fcar (elt);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
690 CHECK_STRING (pane_name);
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
691 push_menu_pane (ENCODE_MENU_STRING (pane_name), Qnil);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
692 pane_data = Fcdr (elt);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
693 CHECK_CONS (pane_data);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
694 list_of_items (pane_data);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
695 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
697 finish_menu_items ();
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
698 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
699
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
700 /* Push the items in a single pane defined by the alist PANE. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
701
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
702 static void
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
703 list_of_items (pane)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
704 Lisp_Object pane;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
705 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
706 Lisp_Object tail, item, item1;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
707
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
708 for (tail = pane; CONSP (tail); tail = XCDR (tail))
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
709 {
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
710 item = XCAR (tail);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
711 if (STRINGP (item))
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
712 push_menu_item (ENCODE_MENU_STRING (item), Qnil, Qnil, Qt,
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
713 Qnil, Qnil, Qnil, Qnil);
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
714 else if (CONSP (item))
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
715 {
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
716 item1 = XCAR (item);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
717 CHECK_STRING (item1);
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
718 push_menu_item (ENCODE_MENU_STRING (item1), Qt, XCDR (item),
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
719 Qt, Qnil, Qnil, Qnil, Qnil);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
720 }
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
721 else
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
722 push_left_right_boundary ();
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
723
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
724 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
725 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
726
49302
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
727 #ifdef HAVE_X_WINDOWS
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
728 /* 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
729 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
730 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
731 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
732 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
733 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
734 sure it is the edit window. */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
735 static void
53069
1218a42792ea Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52981
diff changeset
736 mouse_position_for_popup (f, x, y)
49302
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
737 FRAME_PTR f;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
738 int *x;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
739 int *y;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
740 {
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
741 Window root, dummy_window;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
742 int dummy;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
743
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
744 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
745 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
746
49302
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
747 BLOCK_INPUT;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
748
49302
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
749 XQueryPointer (FRAME_X_DISPLAY (f),
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
750 DefaultRootWindow (FRAME_X_DISPLAY (f)),
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
751
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
752 /* 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
753 &root,
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
754
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
755 /* 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
756 &dummy_window,
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
757
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
758 /* 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
759 x, y,
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
760
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
761 /* 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
762 &dummy, &dummy,
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
763
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
764 /* 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
765 we don't care. */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
766 (unsigned int *) &dummy);
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
767
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
768 UNBLOCK_INPUT;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
769
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
770 /* 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
771 coordinates. Translate. */
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
772 *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
773 *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
774 }
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
775
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
776 #endif /* HAVE_X_WINDOWS */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
777
6424
b3d22929b7c1 (Fx_popup_dialog, Fx_popup_menu): Require 2 args.
Richard M. Stallman <rms@gnu.org>
parents: 6406
diff changeset
778 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0,
40993
63f97168400b (x-popup-menu): Reindent.
Pavel Janík <Pavel@Janik.cz>
parents: 40656
diff changeset
779 doc: /* Pop up a deck-of-cards menu and return user's selection.
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
780 POSITION is a position specification. This is either a mouse button event
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
781 or a list ((XOFFSET YOFFSET) WINDOW)
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
782 where XOFFSET and YOFFSET are positions in pixels from the top left
62012
76ffd04afaae (Fx_popup_menu): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61984
diff changeset
783 corner of WINDOW. (WINDOW may be a window or a frame object.)
58824
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
784 This controls the position of the top left of the menu as a whole.
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
785 If POSITION is t, it means to use the current mouse position.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
786
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
787 MENU is a specifier for a menu. For the simplest case, MENU is a keymap.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
788 The menu items come from key bindings that have a menu string as well as
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
789 a definition; actually, the "definition" in such a key binding looks like
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
790 \(STRING . REAL-DEFINITION). To give the menu a title, put a string into
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
791 the keymap as a top-level element.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
792
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
793 If REAL-DEFINITION is nil, that puts a nonselectable string in the menu.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
794 Otherwise, REAL-DEFINITION should be a valid key binding definition.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
795
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
796 You can also use a list of keymaps as MENU.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
797 Then each keymap makes a separate pane.
62012
76ffd04afaae (Fx_popup_menu): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61984
diff changeset
798
76ffd04afaae (Fx_popup_menu): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61984
diff changeset
799 When MENU is a keymap or a list of keymaps, the return value is the
76ffd04afaae (Fx_popup_menu): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61984
diff changeset
800 list of events corresponding to the user's choice. Note that
76ffd04afaae (Fx_popup_menu): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61984
diff changeset
801 `x-popup-menu' does not actually execute the command bound to that
76ffd04afaae (Fx_popup_menu): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61984
diff changeset
802 sequence of events.
39914
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
803
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
804 Alternatively, you can specify a menu of multiple panes
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
805 with a list of the form (TITLE PANE1 PANE2...),
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
806 where each pane is a list of form (TITLE ITEM1 ITEM2...).
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
807 Each ITEM is normally a cons cell (STRING . VALUE);
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
808 but a string can appear as an item--that makes a nonselectable line
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
809 in the menu.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
810 With this form of menu, the return value is VALUE from the chosen item.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
811
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
812 If POSITION is nil, don't display the menu at all, just precalculate the
62090
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
813 cached information about equivalent key sequences.
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
814
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
815 If the user gets rid of the menu without making a valid choice, for
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
816 instance by clicking the mouse away from a valid choice or by typing
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
817 keyboard input, then this normally results in a quit and
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
818 `x-popup-menu' does not return. But if POSITION is a mouse button
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
819 event (indicating that the user invoked the menu with the mouse) then
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
820 no quit occurs and `x-popup-menu' returns nil. */)
39988
eac4e9ae201c Change doc-string comments to `new style' [w/`doc:' keyword].
Miles Bader <miles@gnu.org>
parents: 39914
diff changeset
821 (position, menu)
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
822 Lisp_Object position, menu;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
823 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
824 Lisp_Object keymap, tem;
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31465
diff changeset
825 int xpos = 0, ypos = 0;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
826 Lisp_Object title;
61620
8449711f0c1c (Fx_popup_menu): Initialize error_name to NULL.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 61619
diff changeset
827 char *error_name = NULL;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
828 Lisp_Object selection;
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
829 FRAME_PTR f = NULL;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
830 Lisp_Object x, y, window;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
831 int keymaps = 0;
10757
2829c9840b0e (xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents: 10716
diff changeset
832 int for_click = 0;
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
833 int specpdl_count = SPECPDL_INDEX ();
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
834 struct gcpro gcpro1;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
835
14741
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
836 #ifdef HAVE_MENUS
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
837 if (! NILP (position))
2147
1b6e54507323 (Fx_popup_menu): Allow a frame instead of a window, in arg.
Richard M. Stallman <rms@gnu.org>
parents: 2135
diff changeset
838 {
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
839 int get_current_pos_p = 0;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
840 check_x ();
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
841
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
842 /* Decode the first argument: find the window and the coordinates. */
11614
fdd0d5bdd8c6 (popup_get_selection): Use x_non_menubar_window_to_frame.
Karl Heuer <kwzh@gnu.org>
parents: 11528
diff changeset
843 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
844 || (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
845 || EQ (XCAR (position), Qtool_bar))))
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
846 {
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
847 get_current_pos_p = 1;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
848 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
849 else
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
850 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
851 tem = Fcar (position);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
852 if (CONSP (tem))
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 window = Fcar (Fcdr (position));
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
855 x = XCAR (tem);
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
856 y = Fcar (XCDR (tem));
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
857 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
858 else
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 for_click = 1;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
861 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
862 window = Fcar (tem); /* POSN_WINDOW (tem) */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
863 tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
864 x = Fcar (tem);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
865 y = Fcdr (tem);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
866 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
867
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
868 /* If a click happens in an external tool bar or a detached
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
869 tool bar, x and y is NIL. In that case, use the current
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
870 mouse position. This happens for the help button in the
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
871 tool bar. Ideally popup-menu should pass NIL to
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
872 this function, but it doesn't. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
873 if (NILP (x) && NILP (y))
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
874 get_current_pos_p = 1;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
875 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
876
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
877 if (get_current_pos_p)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
878 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
879 /* 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
880 FRAME_PTR new_f = SELECTED_FRAME ();
49302
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
881 #ifdef HAVE_X_WINDOWS
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
882 /* Can't use mouse_position_hook for X since it returns
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
883 coordinates relative to the window the mouse is in,
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
884 we need coordinates relative to the edit widget always. */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
885 if (new_f != 0)
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
886 {
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
887 int cur_x, cur_y;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
888
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
889 mouse_position_for_popup (new_f, &cur_x, &cur_y);
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
890 /* cur_x/y may be negative, so use make_number. */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
891 x = make_number (cur_x);
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
892 y = make_number (cur_y);
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
893 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
894
49302
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
895 #else /* not HAVE_X_WINDOWS */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
896 Lisp_Object bar_window;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
897 enum scroll_bar_part part;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
898 unsigned long time;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
899
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
900 if (mouse_position_hook)
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
901 (*mouse_position_hook) (&new_f, 1, &bar_window,
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
902 &part, &x, &y, &time);
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
903 #endif /* not HAVE_X_WINDOWS */
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
904
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
905 if (new_f != 0)
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
906 XSETFRAME (window, new_f);
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
907 else
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
908 {
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
909 window = selected_window;
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
910 XSETFASTINT (x, 0);
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
911 XSETFASTINT (y, 0);
17a9a82ad89f (mouse_position_for_popup): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49116
diff changeset
912 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
913 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
914
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
915 CHECK_NUMBER (x);
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
916 CHECK_NUMBER (y);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
917
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
918 /* Decode where to put the menu. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
919
9102
7a73653817de (menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents: 8849
diff changeset
920 if (FRAMEP (window))
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
921 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
922 f = XFRAME (window);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
923 xpos = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
924 ypos = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
925 }
9102
7a73653817de (menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents: 8849
diff changeset
926 else if (WINDOWP (window))
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
927 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
928 CHECK_LIVE_WINDOW (window);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
929 f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
930
51212
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
931 xpos = WINDOW_LEFT_EDGE_X (XWINDOW (window));
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
932 ypos = WINDOW_TOP_EDGE_Y (XWINDOW (window));
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
933 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
934 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
935 /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
936 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
937 CHECK_WINDOW (window);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
938
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
939 xpos += XINT (x);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
940 ypos += XINT (y);
67703
7ae48da37b8f (Fx_popup_menu): Set Vmenu_updating_frame to f if
Juri Linkov <juri@jurta.org>
parents: 67527
diff changeset
941
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
942 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
943 error ("Can not put X menu on non-X terminal");
83423
b64b7e867d0a Merged from miles@gnu.org--gnu-2005 (patch 677)
Karoly Lorentey <lorentey@elte.hu>
parents: 83414 67703
diff changeset
944
67703
7ae48da37b8f (Fx_popup_menu): Set Vmenu_updating_frame to f if
Juri Linkov <juri@jurta.org>
parents: 67527
diff changeset
945 XSETFRAME (Vmenu_updating_frame, f);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
946 }
67703
7ae48da37b8f (Fx_popup_menu): Set Vmenu_updating_frame to f if
Juri Linkov <juri@jurta.org>
parents: 67527
diff changeset
947 else
7ae48da37b8f (Fx_popup_menu): Set Vmenu_updating_frame to f if
Juri Linkov <juri@jurta.org>
parents: 67527
diff changeset
948 Vmenu_updating_frame = Qnil;
14741
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
949 #endif /* HAVE_MENUS */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
950
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
951 record_unwind_protect (unuse_menu_items, Qnil);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
952 title = Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
953 GCPRO1 (title);
4627
340c18d50337 (Fx_popup_menu): Adjust coords so they are relative to the inner window.
Richard M. Stallman <rms@gnu.org>
parents: 3747
diff changeset
954
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
955 /* Decode the menu items from what was specified. */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
956
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32179
diff changeset
957 keymap = get_keymap (menu, 0, 0);
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32179
diff changeset
958 if (CONSP (keymap))
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
959 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
960 /* We were given a keymap. Extract menu info from the keymap. */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
961 Lisp_Object prompt;
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
962
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
963 /* Extract the detailed info to make one pane. */
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
964 keymap_panes (&menu, 1, NILP (position));
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
965
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
966 /* Search for a string appearing directly as an element of the keymap.
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
967 That string is the title of the menu. */
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
968 prompt = Fkeymap_prompt (keymap);
16411
939831bf2103 (Fx_popup_menu): Give the menu a title when the menu is a single keymap.
Richard M. Stallman <rms@gnu.org>
parents: 15943
diff changeset
969 if (NILP (title) && !NILP (prompt))
939831bf2103 (Fx_popup_menu): Give the menu a title when the menu is a single keymap.
Richard M. Stallman <rms@gnu.org>
parents: 15943
diff changeset
970 title = prompt;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
971
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
972 /* Make that be the pane title of the first pane. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
973 if (!NILP (prompt) && menu_items_n_panes >= 0)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
974 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = prompt;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
975
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
976 keymaps = 1;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
977 }
32988
c3435dc00ed7 * lisp.h (KEYMAPP): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32179
diff changeset
978 else if (CONSP (menu) && KEYMAPP (XCAR (menu)))
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
979 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
980 /* We were given a list of keymaps. */
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
981 int nmaps = XFASTINT (Flength (menu));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
982 Lisp_Object *maps
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
983 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object));
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
984 int i;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
985
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
986 title = Qnil;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
987
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
988 /* The first keymap that has a prompt string
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
989 supplies the menu title. */
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
990 for (tem = menu, i = 0; CONSP (tem); tem = XCDR (tem))
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
991 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
992 Lisp_Object prompt;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
993
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
994 maps[i++] = keymap = get_keymap (XCAR (tem), 1, 0);
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
995
39690
38c1890338cc (keymap_panes, Fx_popup_menu): Use Fkeymap_prompt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39682
diff changeset
996 prompt = Fkeymap_prompt (keymap);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
997 if (NILP (title) && !NILP (prompt))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
998 title = prompt;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
999 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
1000
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
1001 /* Extract the detailed info to make one pane. */
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
1002 keymap_panes (maps, nmaps, NILP (position));
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1003
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1004 /* Make the title be the pane title of the first pane. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1005 if (!NILP (title) && menu_items_n_panes >= 0)
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1006 XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME] = title;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1007
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1008 keymaps = 1;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
1009 }
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
1010 else
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
1011 {
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
1012 /* We were given an old-fashioned menu. */
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1013 title = Fcar (menu);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
1014 CHECK_STRING (title);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1015
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1016 list_of_panes (Fcdr (menu));
1828
1463592a6463 * xmenu.c (Fx_popup_menu): Don't forget to turn the frame-relative
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1017
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1018 keymaps = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1019 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1020
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
1021 unbind_to (specpdl_count, Qnil);
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
1022
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1023 if (NILP (position))
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1024 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1025 discard_menu_items ();
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1026 UNGCPRO;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1027 return Qnil;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1028 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1029
14741
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
1030 #ifdef HAVE_MENUS
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1031 /* Display them in a menu. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1032 BLOCK_INPUT;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1033
11491
272baf4a077a (xmenu_show, xdialog_show): Delete menubarp arg.
Richard M. Stallman <rms@gnu.org>
parents: 11449
diff changeset
1034 selection = xmenu_show (f, xpos, ypos, for_click,
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1035 keymaps, title, &error_name);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1036 UNBLOCK_INPUT;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1037
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1038 discard_menu_items ();
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1039
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1040 UNGCPRO;
14741
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
1041 #endif /* HAVE_MENUS */
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1042
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1043 if (error_name) error (error_name);
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1044 return selection;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1045 }
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1046
14741
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
1047 #ifdef HAVE_MENUS
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
1048
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
1049 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
1050 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
1051 POSITION specifies which frame to use.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
1052 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
1053 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
1054 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
1055
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
1056 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
1057 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
1058 Each ITEM is a cons cell (STRING . VALUE).
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
1059 The return value is VALUE from the chosen item.
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
1060
91951fb5b9e5 Put doc strings in comments.
Gerd Moellmann <gerd@gnu.org>
parents: 39690
diff changeset
1061 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
1062 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
1063 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
1064 \(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
1065
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
1066 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
1067 otherwise it is "Question".
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
1068
62090
cd1e4bc8e488 (Fx_popup_menu, Fx_popup_dialog): Doc fixes.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62012
diff changeset
1069 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
1070 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
1071 `x-popup-dialog' does not return. */)
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
1072 (position, contents, header)
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
1073 Lisp_Object position, contents, 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
1074 {
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
1075 FRAME_PTR f = NULL;
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1076 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
1077
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1078 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
1079
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1080 /* 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
1081 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
1082 || (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
1083 || 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
1084 {
6653
14a0a3fe93fd (Fx_popup_dialog): If POSITION is t, use selected frame.
Richard M. Stallman <rms@gnu.org>
parents: 6625
diff changeset
1085 #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
1086 /* 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
1087 FRAME_PTR new_f = SELECTED_FRAME ();
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1088 Lisp_Object bar_window;
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
1089 enum scroll_bar_part part;
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1090 unsigned long time;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1091 Lisp_Object x, y;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1092
11125
dc78213dd2b3 (Fx_popup_menu): Pass 1 for `insist' arg.
Richard M. Stallman <rms@gnu.org>
parents: 10835
diff changeset
1093 (*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
1094
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1095 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
1096 XSETFRAME (window, new_f);
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1097 else
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1098 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
1099 #endif
11907
0f03ad1cac1e (Fx_popup_dialog): Treat (menu-bar) like t, for POSITION.
Karl Heuer <kwzh@gnu.org>
parents: 11898
diff changeset
1100 window = selected_window;
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1101 }
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1102 else if (CONSP (position))
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1103 {
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1104 Lisp_Object tem;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1105 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
1106 if (CONSP (tem))
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1107 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
1108 else
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
1109 {
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1110 tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1111 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
1112 }
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1113 }
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1114 else if (WINDOWP (position) || FRAMEP (position))
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1115 window = position;
15807
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
1116 else
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
1117 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
1118
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1119 /* 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
1120
9102
7a73653817de (menu_item_enabled_p, single_keymap_panes, Fx_popup_menu, Fx_popup_dialog):
Karl Heuer <kwzh@gnu.org>
parents: 8849
diff changeset
1121 if (FRAMEP (window))
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1122 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
1123 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
1124 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
1125 CHECK_LIVE_WINDOW (window);
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1126 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
1127 }
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1128 else
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1129 /* ??? 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
1130 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
1131 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
1132
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1133 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
1134 error ("Can not put X dialog on non-X terminal");
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1135
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1136 #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
1137 /* Display a menu with these alternatives
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1138 in the middle of frame F. */
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1139 {
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1140 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
1141 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
1142 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
1143 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
1144 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
1145
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1146 return Fx_popup_menu (newpos,
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1147 Fcons (Fcar (contents), Fcons (contents, Qnil)));
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1148 }
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1149 #else
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1150 {
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1151 Lisp_Object title;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1152 char *error_name;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1153 Lisp_Object selection;
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
1154 int specpdl_count = SPECPDL_INDEX ();
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1155
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1156 /* 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
1157 title = Fcar (contents);
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 40477
diff changeset
1158 CHECK_STRING (title);
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
1159 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
1160
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
1161 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
1162 /* 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
1163 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
1164 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
1165 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
1166
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1167 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
1168
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1169 /* Display them in a dialog box. */
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1170 BLOCK_INPUT;
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
1171 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
1172 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
1173
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
1174 unbind_to (specpdl_count, Qnil);
6439
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1175 discard_menu_items ();
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1176
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1177 if (error_name) error (error_name);
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1178 return selection;
463b12ba8260 (xdialog_show): Delete args x, y.
Richard M. Stallman <rms@gnu.org>
parents: 6426
diff changeset
1179 }
6325
d6817c9c0413 Undo previous change. Instead:
Richard M. Stallman <rms@gnu.org>
parents: 6324
diff changeset
1180 #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
1181 }
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1182
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1183
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1184 #ifndef MSDOS
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1185
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
1186 /* 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
1187
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
1188 void
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
1189 x_menu_set_in_use (in_use)
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
1190 int in_use;
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
1191 {
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
1192 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
1193 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
1194 #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
1195 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
1196 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
1197 #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
1198 }
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
1199
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1200 /* 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
1201
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
1202 void
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1203 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
1204 {
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1205 extern EMACS_TIME timer_check P_ ((int));
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1206
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1207 /* 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
1208 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
1209 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
1210 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
1211
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1212 while (
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1213 #ifdef USE_X_TOOLKIT
58170
66ace4a9a250 (pop_down_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58169
diff changeset
1214 ! 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
1215 #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
1216 ! 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
1217 #else
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1218 ! 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
1219 #endif
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1220 )
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1221 {
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1222 EMACS_TIME next_time = timer_check (1);
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1223 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
1224 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
1225 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
1226 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
1227 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
1228
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1229 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
1230 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
1231 {
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1232 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
1233 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
1234 if (fd > n) n = fd;
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1235 }
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1236
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1237 if (secs < 0 || (secs == 0 && usecs == 0))
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1238 {
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1239 /* Sometimes timer_check returns -1 (no timers) even if there are
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1240 timers. So do a timeout anyway. */
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1241 EMACS_SET_SECS (next_time, 1);
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1242 EMACS_SET_USECS (next_time, 0);
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1243 }
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1244
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1245 select (n + 1, &read_fds, (SELECT_TYPE *)0, (SELECT_TYPE *)0, &next_time);
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1246 }
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1247 }
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1248 #endif /* ! MSDOS */
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1249
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1250
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1251 #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
1252
58170
66ace4a9a250 (pop_down_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58169
diff changeset
1253 #ifdef USE_X_TOOLKIT
66ace4a9a250 (pop_down_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58169
diff changeset
1254
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1255 /* 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
1256 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
1257 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
1258
11954
4117d74ba254 (popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents: 11918
diff changeset
1259 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
1260 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
1261
48912
b0b74923fe41 (popup_get_selection): Now static. New arg DO_TIMERS.
Richard M. Stallman <rms@gnu.org>
parents: 48329
diff changeset
1262 static void
59156
03a6e350cf4d (popup_get_selection): Remove parameter down_on_keypress.
Jan Djärv <jan.h.d@swipnet.se>
parents: 59155
diff changeset
1263 popup_get_selection (initial_event, dpyinfo, id, do_timers)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1264 XEvent *initial_event;
11449
fca5a32f7806 (popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents: 11266
diff changeset
1265 struct x_display_info *dpyinfo;
11954
4117d74ba254 (popup_get_selection): Force deactivation if key pressed.
Karl Heuer <kwzh@gnu.org>
parents: 11918
diff changeset
1266 LWLIB_ID id;
57965
9b14127a651a * eval.c (Feval): Remove check for INPUT_BLOCKED_P.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57928
diff changeset
1267 int do_timers;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1268 {
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1269 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
1270
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
1271 while (popup_activated_flag)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1272 {
59107
d264cb5b989f Indentation fix.
Richard M. Stallman <rms@gnu.org>
parents: 59102
diff changeset
1273 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
1274 {
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
1275 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
1276 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
1277 }
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
1278 else
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1279 {
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1280 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
1281 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
1282 }
49116
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
1283
15628
f74c79dcaf8d (popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents: 15428
diff changeset
1284 /* 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
1285 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
1286 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
1287 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
1288 && 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
1289 {
f74c79dcaf8d (popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents: 15428
diff changeset
1290 dpyinfo->grabbed &= ~(1 << event.xbutton.button);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1291 #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
1292 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
1293 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
1294 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
1295 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
1296 /* 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
1297 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
1298 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
1299 event.xbutton.state = 0;
15839
e66ccb471d26 (xmenu_show): Set dummy.state.
Richard M. Stallman <rms@gnu.org>
parents: 15807
diff changeset
1300 #endif
15628
f74c79dcaf8d (popup_get_selection): For a ButtonRelease on the proper
Karl Heuer <kwzh@gnu.org>
parents: 15428
diff changeset
1301 }
59155
6690f246cffe * xmenu.c (popup_get_selection): Only pop down dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents: 59107
diff changeset
1302 /* 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
1303 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
1304 && 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
1305 {
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
1306 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
1307
59155
6690f246cffe * xmenu.c (popup_get_selection): Only pop down dialogs
Jan Djärv <jan.h.d@swipnet.se>
parents: 59107
diff changeset
1308 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
1309 || 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
1310 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
1311 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1312
49116
8c37b25a7f02 (Fx_popup_menu): If popping up at mouse position,
Jan Djärv <jan.h.d@swipnet.se>
parents: 48946
diff changeset
1313 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
1314 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1315 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1316
83542
2d56e13fd23d Merged from emacs@sv.gnu.org
Karoly Lorentey <lorentey@elte.hu>
parents: 83537 73320
diff changeset
1317 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
1318 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
1319 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
1320 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
1321 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
1322
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
1323 If FRAME is nil or not given, use the selected 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
1324 (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
1325 Lisp_Object 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
1326 {
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
1327 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
1328 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
1329 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
1330 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
1331
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
1332 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
1333 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
1334
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
1335 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
1336 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
1337 {
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
1338 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
1339 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
1340
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
1341 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
1342 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
1343 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
1344 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
1345 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
1346 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
1347 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
1348 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
1349 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
1350
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
1351 #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
1352 {
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
1353 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
1354 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
1355 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
1356 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
1357 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
1358 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
1359 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
1360 }
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
1361 #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
1362
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
1363 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
1364 /* 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
1365 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
1366
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
1367 /* 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
1368 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
1369 &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
1370
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
1371 /* 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
1372 &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
1373 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
1374 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
1375
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
1376 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
1377 {
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
1378 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
1379 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
1380
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
1381 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
1382 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
1383 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
1384 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
1385 }
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
1386 }
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
1387
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
1388 UNBLOCK_INPUT;
71094
bff9557e8c24 (Fmenu_bar_start): Return a value.
Andreas Schwab <schwab@suse.de>
parents: 71057
diff changeset
1389
bff9557e8c24 (Fmenu_bar_start): Return a value.
Andreas Schwab <schwab@suse.de>
parents: 71057
diff changeset
1390 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
1391 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1392 #endif /* USE_X_TOOLKIT */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1393
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
1394
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1395 #ifdef USE_GTK
83542
2d56e13fd23d Merged from emacs@sv.gnu.org
Karoly Lorentey <lorentey@elte.hu>
parents: 83537 73320
diff changeset
1396 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
1397 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
1398 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
1399 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
1400 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
1401
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
1402 If FRAME is nil or not given, use the selected 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
1403 (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
1404 Lisp_Object 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
1405 {
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
1406 GtkWidget *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
1407 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
1408 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
1409
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
1410 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
1411 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
1412
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
1413 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
1414 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
1415 {
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
1416 /* 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
1417 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
1418
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
1419 gtk_menu_shell_select_item (GTK_MENU_SHELL (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
1420 GTK_WIDGET (children->data));
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
1421
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
1422 popup_activated_flag = 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
1423 g_list_free (children);
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
1424 }
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
1425 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
1426
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
1427 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
1428 }
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
1429
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1430 /* 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
1431 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
1432
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1433 static void
58170
66ace4a9a250 (pop_down_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58169
diff changeset
1434 popup_widget_loop (do_timers, widget)
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1435 int do_timers;
58170
66ace4a9a250 (pop_down_menu): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58169
diff changeset
1436 GtkWidget *widget;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1437 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1438 ++popup_activated_flag;
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 /* Process events in the Gtk event loop until done. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1441 while (popup_activated_flag)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1442 {
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
1443 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
1444 gtk_main_iteration ();
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1445 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1446 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1447 #endif
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1448
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1449 /* Activate the menu bar of frame F.
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1450 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
1451 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
1452
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1453 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
1454 that was saved in saved_menu_event.
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1455 That makes the toolkit do its thing.
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1456
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1457 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
1458
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1459 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
1460 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
1461 execute Lisp code. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1462
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21268
diff changeset
1463 void
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1464 x_activate_menubar (f)
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1465 FRAME_PTR f;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1466 {
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1467 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
1468 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
1469
15710
85d87cd0f655 (x_activate_menubar): Allow any event, not just ButtonPress.
Karl Heuer <kwzh@gnu.org>
parents: 15628
diff changeset
1470 if (!f->output_data.x->saved_menu_event->type)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1471 return;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1472
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1473 #ifdef USE_GTK
53069
1218a42792ea Implement multiple display handling for GTK.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52981
diff changeset
1474 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
1475 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
1476 return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1477 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1478
15807
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
1479 set_frame_menubar (f, 0, 1);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1480 BLOCK_INPUT;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1481 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1482 XPutBackEvent (f->output_data.x->display_info->display,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1483 f->output_data.x->saved_menu_event);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1484 popup_activated_flag = 1;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1485 #else
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
1486 XtDispatchEvent (f->output_data.x->saved_menu_event);
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1487 #endif
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1488 UNBLOCK_INPUT;
15807
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
1489 #ifdef USE_MOTIF
15792
feeb1f7c1cec (pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15785
diff changeset
1490 if (f->output_data.x->saved_menu_event->type == ButtonRelease)
feeb1f7c1cec (pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15785
diff changeset
1491 pending_menu_activation = 1;
15807
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
1492 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1493
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1494 /* 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
1495 f->output_data.x->saved_menu_event->type = 0;
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1496 }
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
1497
9236
583bb9211b2b (popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents: 9233
diff changeset
1498 /* Detect if a dialog or menu has been posted. */
11449
fca5a32f7806 (popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents: 11266
diff changeset
1499
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1500 int
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1501 popup_activated ()
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1502 {
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1503 return popup_activated_flag;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1504 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1505
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1506 /* 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
1507 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
1508
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1509 #ifndef USE_GTK
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1510 static void
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1511 popup_activate_callback (widget, id, client_data)
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1512 Widget widget;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1513 LWLIB_ID id;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1514 XtPointer client_data;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1515 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1516 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
1517 #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
1518 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
1519 #endif
27425
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
1520 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1521 #endif
27425
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
1522
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
1523 /* 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
1524 used and has been unposted. */
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
1525
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1526 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1527 static void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1528 popup_deactivate_callback (widget, client_data)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1529 GtkWidget *widget;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1530 gpointer client_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1531 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1532 popup_activated_flag = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1533 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1534 #else
27425
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
1535 static void
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
1536 popup_deactivate_callback (widget, id, client_data)
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
1537 Widget widget;
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
1538 LWLIB_ID id;
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
1539 XtPointer client_data;
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
1540 {
e575223479a1 (popup_activated_flag): Make externally visible.
Gerd Moellmann <gerd@gnu.org>
parents: 27341
diff changeset
1541 popup_activated_flag = 0;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1542 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1543 #endif
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1544
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1545
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1546 /* 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
1547 for that widget.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1548 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
1549 static void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1550 show_help_event (f, widget, help)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1551 FRAME_PTR f;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1552 xt_or_gtk_widget widget;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1553 Lisp_Object help;
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1554 {
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1555 Lisp_Object frame;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1556
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1557 if (f)
30472
0c982ed8515f (menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents: 30420
diff changeset
1558 {
0c982ed8515f (menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents: 30420
diff changeset
1559 XSETFRAME (frame, f);
0c982ed8515f (menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents: 30420
diff changeset
1560 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
1561 }
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1562 else
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1563 {
53325
8e8832ef3963 (show_help_event): Remove unused code.
Kim F. Storm <storm@cua.dk>
parents: 53069
diff changeset
1564 #if 0 /* This code doesn't do anything useful. ++kfs */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1565 /* 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
1566 widget. See which frame that is. */
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1567 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
1568 Lisp_Object tail;
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1569
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1570 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1571 {
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1572 frame = XCAR (tail);
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1573 if (GC_FRAMEP (frame)
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1574 && (f = XFRAME (frame),
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1575 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
1576 break;
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1577 }
53325
8e8832ef3963 (show_help_event): Remove unused code.
Kim F. Storm <storm@cua.dk>
parents: 53069
diff changeset
1578 #endif
30472
0c982ed8515f (menu_highlight_callback): Call show_help_echo directly
Gerd Moellmann <gerd@gnu.org>
parents: 30420
diff changeset
1579 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
1580 }
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1581 }
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1582
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1583 /* Callback called when menu items are highlighted/unhighlighted
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1584 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
1585 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
1586 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
1587 unhighlighting. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1588
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1589 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1590 void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1591 menu_highlight_callback (widget, call_data)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1592 GtkWidget *widget;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1593 gpointer call_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1594 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1595 xg_menu_item_cb_data *cb_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1596 Lisp_Object help;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1597
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1598 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
1599 XG_ITEM_DATA);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1600 if (! cb_data) return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1601
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1602 help = call_data ? cb_data->help : Qnil;
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 /* 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
1605 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
1606 popup is popped down. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1607 if (popup_activated_flag <= 1)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1608 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
1609 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1610 #else
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1611 void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1612 menu_highlight_callback (widget, id, call_data)
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1613 Widget widget;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1614 LWLIB_ID id;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1615 void *call_data;
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 struct frame *f;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1618 Lisp_Object help;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1619
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1620 widget_value *wv = (widget_value *) call_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1621
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1622 help = wv ? wv->help : Qnil;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1623
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1624 /* Determine the frame for the help event. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1625 f = menubar_id_to_frame (id);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1626
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1627 show_help_event (f, widget, help);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1628 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1629 #endif
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1630
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1631 /* Find the menu selection and store it in the keyboard buffer.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1632 F is the frame the menu is on.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1633 MENU_BAR_ITEMS_USED is the length of VECTOR.
59912
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
1634 VECTOR is an array of menu events for the whole menu. */
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
1635
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
1636 static void
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1637 find_and_call_menu_selection (f, menu_bar_items_used, vector, client_data)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1638 FRAME_PTR f;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1639 int menu_bar_items_used;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1640 Lisp_Object vector;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1641 void *client_data;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1642 {
11655
a9f93ce6e1b4 (xmenu_show, menubar_selection_callback): Move declaration
Karl Heuer <kwzh@gnu.org>
parents: 11614
diff changeset
1643 Lisp_Object prefix, entry;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1644 Lisp_Object *subprefix_stack;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1645 int submenu_depth = 0;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1646 int i;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1647
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31465
diff changeset
1648 entry = Qnil;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1649 subprefix_stack = (Lisp_Object *) alloca (menu_bar_items_used * sizeof (Lisp_Object));
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1650 prefix = Qnil;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1651 i = 0;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1652
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1653 while (i < menu_bar_items_used)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1654 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1655 if (EQ (XVECTOR (vector)->contents[i], Qnil))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1656 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1657 subprefix_stack[submenu_depth++] = prefix;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1658 prefix = entry;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1659 i++;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1660 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1661 else if (EQ (XVECTOR (vector)->contents[i], Qlambda))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1662 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1663 prefix = subprefix_stack[--submenu_depth];
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1664 i++;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1665 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1666 else if (EQ (XVECTOR (vector)->contents[i], Qt))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1667 {
10799
1745fca9370a (menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents: 10757
diff changeset
1668 prefix = XVECTOR (vector)->contents[i + MENU_ITEMS_PANE_PREFIX];
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1669 i += MENU_ITEMS_PANE_LENGTH;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1670 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1671 else
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1672 {
10799
1745fca9370a (menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents: 10757
diff changeset
1673 entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE];
11266
3e93d8b99b05 (menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents: 11237
diff changeset
1674 /* 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
1675 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
1676 if ((int) (EMACS_INT) client_data == i)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1677 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1678 int j;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1679 struct input_event buf;
10799
1745fca9370a (menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents: 10757
diff changeset
1680 Lisp_Object frame;
51575
45724e359a61 (find_and_call_menu_selection): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51404
diff changeset
1681 EVENT_INIT (buf);
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1682
10799
1745fca9370a (menubar_selection_callback): frame_or_window field of a menu-bar event now
Karl Heuer <kwzh@gnu.org>
parents: 10757
diff changeset
1683 XSETFRAME (frame, f);
30181
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1684 buf.kind = MENU_BAR_EVENT;
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1685 buf.frame_or_window = frame;
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1686 buf.arg = frame;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1687 kbd_buffer_store_event (&buf);
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1688
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1689 for (j = 0; j < submenu_depth; j++)
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1690 if (!NILP (subprefix_stack[j]))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1691 {
30181
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1692 buf.kind = MENU_BAR_EVENT;
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1693 buf.frame_or_window = frame;
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1694 buf.arg = subprefix_stack[j];
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1695 kbd_buffer_store_event (&buf);
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1696 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1697
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1698 if (!NILP (prefix))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1699 {
30181
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1700 buf.kind = MENU_BAR_EVENT;
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1701 buf.frame_or_window = frame;
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1702 buf.arg = prefix;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1703 kbd_buffer_store_event (&buf);
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1704 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1705
30181
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1706 buf.kind = MENU_BAR_EVENT;
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1707 buf.frame_or_window = frame;
770a280db6ee (menu_highlight_callback): Store help string in the
Gerd Moellmann <gerd@gnu.org>
parents: 30144
diff changeset
1708 buf.arg = entry;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1709 kbd_buffer_store_event (&buf);
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1710
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1711 return;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1712 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1713 i += MENU_ITEMS_ITEM_LENGTH;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1714 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1715 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1716 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1717
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1718
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1719 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1720 /* 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
1721 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
1722 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
1723 */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1724 static int xg_crazy_callback_abort;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1725
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1726 /* 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
1727 when the user makes a selection.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1728 Figure out what the user chose
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1729 and put the appropriate events into the keyboard buffer. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1730 static void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1731 menubar_selection_callback (widget, client_data)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1732 GtkWidget *widget;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1733 gpointer client_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1734 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1735 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
1736
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1737 if (xg_crazy_callback_abort)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1738 return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1739
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1740 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
1741 return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1742
67527
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
1743 /* 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
1744 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
1745 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
1746 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
1747 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
1748 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
1749 && ! 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
1750 return;
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
1751
59912
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
1752 /* 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
1753 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
1754 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
1755 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
1756 event. */
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
1757
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
1758 BLOCK_INPUT;
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
1759 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
1760 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
1761 UNBLOCK_INPUT;
ef2f9fc4fd42 * xmenu.c (menubar_selection_callback): Force out GTK buffered
Jan Djärv <jan.h.d@swipnet.se>
parents: 59415
diff changeset
1762
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1763 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
1764 cb_data->cl_data->menu_bar_items_used,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1765 cb_data->cl_data->menu_bar_vector,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1766 cb_data->call_data);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1767 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1768
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1769 #else /* not USE_GTK */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1770
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1771 /* 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
1772 when the user makes a selection.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1773 Figure out what the user chose
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1774 and put the appropriate events into the keyboard buffer. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1775 static void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1776 menubar_selection_callback (widget, id, client_data)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1777 Widget widget;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1778 LWLIB_ID id;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1779 XtPointer client_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1780 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1781 FRAME_PTR f;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1782
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1783 f = menubar_id_to_frame (id);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1784 if (!f)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1785 return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1786 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
1787 f->menu_bar_vector, client_data);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1788 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1789 #endif /* not USE_GTK */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
1790
14553
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1791 /* Allocate a widget_value, blocking input. */
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1792
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1793 widget_value *
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1794 xmalloc_widget_value ()
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1795 {
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1796 widget_value *value;
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1797
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1798 BLOCK_INPUT;
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1799 value = malloc_widget_value ();
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1800 UNBLOCK_INPUT;
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1801
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1802 return value;
00521a7aaa75 (xmalloc_widget_value): Define only if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 14548
diff changeset
1803 }
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
1804
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1805 /* This recursively calls free_widget_value on the tree of widgets.
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1806 It must free all data that was malloc'ed for these widget_values.
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1807 In Emacs, many slots are pointers into the data of Lisp_Strings, and
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1808 must be left alone. */
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
1809
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1810 void
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1811 free_menubar_widget_value_tree (wv)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1812 widget_value *wv;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1813 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1814 if (! wv) return;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1815
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1816 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1817
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1818 if (wv->contents && (wv->contents != (widget_value*)1))
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1819 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1820 free_menubar_widget_value_tree (wv->contents);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1821 wv->contents = (widget_value *) 0xDEADBEEF;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1822 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1823 if (wv->next)
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1824 {
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1825 free_menubar_widget_value_tree (wv->next);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1826 wv->next = (widget_value *) 0xDEADBEEF;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1827 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1828 BLOCK_INPUT;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1829 free_widget_value (wv);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1830 UNBLOCK_INPUT;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1831 }
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1832
48270
b6f3eaeb71e5 (parse_single_submenu): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48113
diff changeset
1833 /* Set up data in menu_items for a menu bar item
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1834 whose event type is ITEM_KEY (with string ITEM_NAME)
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1835 and whose contents come from the list of keymaps MAPS. */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
1836
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1837 static int
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1838 parse_single_submenu (item_key, item_name, maps)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1839 Lisp_Object item_key, item_name, maps;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1840 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1841 Lisp_Object length;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1842 int len;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1843 Lisp_Object *mapvec;
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1844 int i;
12432
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
1845 int top_level_items = 0;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1846
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1847 length = Flength (maps);
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1848 len = XINT (length);
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1849
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1850 /* Convert the list MAPS into a vector MAPVEC. */
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1851 mapvec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1852 for (i = 0; i < len; i++)
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1853 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1854 mapvec[i] = Fcar (maps);
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1855 maps = Fcdr (maps);
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1856 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1857
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1858 /* Loop over the given keymaps, making a pane for each map.
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1859 But don't make a pane that is empty--ignore that map instead. */
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1860 for (i = 0; i < len; i++)
12432
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
1861 {
48270
b6f3eaeb71e5 (parse_single_submenu): Simplify.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48113
diff changeset
1862 if (!KEYMAPP (mapvec[i]))
12432
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
1863 {
15311
a9ed91ec0700 (single_submenu): Handle non-keymap lists like symbols.
Richard M. Stallman <rms@gnu.org>
parents: 15107
diff changeset
1864 /* Here we have a command at top level in the menu bar
a9ed91ec0700 (single_submenu): Handle non-keymap lists like symbols.
Richard M. Stallman <rms@gnu.org>
parents: 15107
diff changeset
1865 as opposed to a submenu. */
12432
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
1866 top_level_items = 1;
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
1867 push_menu_pane (Qnil, Qnil);
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1868 push_menu_item (item_name, Qt, item_key, mapvec[i],
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1869 Qnil, Qnil, Qnil, Qnil);
12432
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
1870 }
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
1871 else
48946
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1872 {
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1873 Lisp_Object prompt;
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1874 prompt = Fkeymap_prompt (mapvec[i]);
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1875 single_keymap_panes (mapvec[i],
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1876 !NILP (prompt) ? prompt : item_name,
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1877 item_key, 0, 10);
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1878 }
12432
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
1879 }
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1880
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1881 return top_level_items;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1882 }
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1883
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1884 /* Create a tree of widget_value objects
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1885 representing the panes and items
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1886 in menu_items starting at index START, up to index END. */
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1887
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1888 static widget_value *
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1889 digest_single_submenu (start, end, top_level_items)
48329
0d792a35828b (unuse_menu_items, digest_single_submenu):
Dave Love <fx@gnu.org>
parents: 48270
diff changeset
1890 int start, end, top_level_items;
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1891 {
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1892 widget_value *wv, *prev_wv, *save_wv, *first_wv;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1893 int i;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1894 int submenu_depth = 0;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1895 widget_value **submenu_stack;
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1896 int panes_seen = 0;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1897
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1898 submenu_stack
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1899 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
1900 wv = xmalloc_widget_value ();
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1901 wv->name = "menu";
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1902 wv->value = 0;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1903 wv->enabled = 1;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1904 wv->button_type = BUTTON_TYPE_NONE;
42586
3d2b46b8e1bf (single_submenu): Initialize wv->help to Qnil.
Jason Rumney <jasonr@gnu.org>
parents: 42583
diff changeset
1905 wv->help = Qnil;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1906 first_wv = wv;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1907 save_wv = 0;
12432
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
1908 prev_wv = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1909
48946
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1910 /* Loop over all panes and items made by the preceding call
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1911 to parse_single_submenu and construct a tree of widget_value objects.
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1912 Ignore the panes and items used by previous calls to
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
1913 digest_single_submenu, even though those are also in menu_items. */
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1914 i = start;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
1915 while (i < end)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1916 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1917 if (EQ (XVECTOR (menu_items)->contents[i], Qnil))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1918 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1919 submenu_stack[submenu_depth++] = save_wv;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1920 save_wv = prev_wv;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1921 prev_wv = 0;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1922 i++;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1923 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1924 else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1925 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1926 prev_wv = save_wv;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1927 save_wv = submenu_stack[--submenu_depth];
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1928 i++;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1929 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1930 else if (EQ (XVECTOR (menu_items)->contents[i], Qt)
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1931 && submenu_depth != 0)
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1932 i += MENU_ITEMS_PANE_LENGTH;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1933 /* Ignore a nil in the item list.
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1934 It's meaningful only for dialog boxes. */
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1935 else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1936 i += 1;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1937 else if (EQ (XVECTOR (menu_items)->contents[i], Qt))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1938 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1939 /* Create a new pane. */
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1940 Lisp_Object pane_name, prefix;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1941 char *pane_string;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1942
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1943 panes_seen++;
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1944
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1945 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME];
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1946 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1947
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
1948 #ifndef HAVE_MULTILINGUAL_MENU
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
1949 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
1950 {
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
1951 pane_name = ENCODE_MENU_STRING (pane_name);
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
1952 AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name;
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
1953 }
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
1954 #endif
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1955 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
1956 ? "" : (char *) SDATA (pane_name));
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1957 /* If there is just one top-level pane, put all its items directly
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1958 under the top-level menu. */
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1959 if (menu_items_n_panes == 1)
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1960 pane_string = "";
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1961
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1962 /* If the pane has a meaningful name,
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1963 make the pane a top-level menu item
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1964 with its items as a submenu beneath it. */
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1965 if (strcmp (pane_string, ""))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1966 {
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
1967 wv = xmalloc_widget_value ();
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1968 if (save_wv)
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1969 save_wv->next = wv;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1970 else
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1971 first_wv->contents = wv;
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
1972 wv->lname = pane_name;
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
1973 /* Set value to 1 so update_submenu_strings can handle '@' */
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
1974 wv->value = (char *)1;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1975 wv->enabled = 1;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1976 wv->button_type = BUTTON_TYPE_NONE;
42586
3d2b46b8e1bf (single_submenu): Initialize wv->help to Qnil.
Jason Rumney <jasonr@gnu.org>
parents: 42583
diff changeset
1977 wv->help = Qnil;
69017
3293c81b59b1 (digest_single_submenu): When pane_string is empty, do initialize save_wv.
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
1978 save_wv = wv;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1979 }
69017
3293c81b59b1 (digest_single_submenu): When pane_string is empty, do initialize save_wv.
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
1980 else
3293c81b59b1 (digest_single_submenu): When pane_string is empty, do initialize save_wv.
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
1981 save_wv = first_wv;
3293c81b59b1 (digest_single_submenu): When pane_string is empty, do initialize save_wv.
Richard M. Stallman <rms@gnu.org>
parents: 68651
diff changeset
1982
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1983 prev_wv = 0;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1984 i += MENU_ITEMS_PANE_LENGTH;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1985 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1986 else
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1987 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
1988 /* Create a new item within current pane. */
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
1989 Lisp_Object item_name, enable, descrip, def, type, selected;
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
1990 Lisp_Object help;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
1991
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1992 /* All items should be contained in panes. */
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1993 if (panes_seen == 0)
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1994 abort ();
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
1995
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
1996 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
1997 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
1998 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
1999 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2000 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2001 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2002 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2003
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
2004 #ifndef HAVE_MULTILINGUAL_MENU
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2005 if (STRING_MULTIBYTE (item_name))
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2006 {
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
2007 item_name = ENCODE_MENU_STRING (item_name);
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2008 AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2009 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2010
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2011 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2012 {
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
2013 descrip = ENCODE_MENU_STRING (descrip);
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2014 AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2015 }
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2016 #endif /* not HAVE_MULTILINGUAL_MENU */
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2017
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
2018 wv = xmalloc_widget_value ();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2019 if (prev_wv)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2020 prev_wv->next = wv;
12432
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
2021 else
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2022 save_wv->contents = wv;
12432
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
2023
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
2024 wv->lname = item_name;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2025 if (!NILP (descrip))
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
2026 wv->lkey = descrip;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2027 wv->value = 0;
11266
3e93d8b99b05 (menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents: 11237
diff changeset
2028 /* 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
2029 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
2030 wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0);
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2031 wv->enabled = !NILP (enable);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2032
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2033 if (NILP (type))
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2034 wv->button_type = BUTTON_TYPE_NONE;
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2035 else if (EQ (type, QCradio))
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2036 wv->button_type = BUTTON_TYPE_RADIO;
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2037 else if (EQ (type, QCtoggle))
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2038 wv->button_type = BUTTON_TYPE_TOGGLE;
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2039 else
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2040 abort ();
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2041
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2042 wv->selected = !NILP (selected);
41769
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
2043 if (! STRINGP (help))
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
2044 help = Qnil;
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
2045
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
2046 wv->help = help;
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
2047
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2048 prev_wv = wv;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2049
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2050 i += MENU_ITEMS_ITEM_LENGTH;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2051 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2052 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2053
12432
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
2054 /* If we have just one "menu item"
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
2055 that was originally a button, return it by itself. */
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
2056 if (top_level_items && first_wv->contents && first_wv->contents->next == 0)
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
2057 {
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
2058 wv = first_wv->contents;
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
2059 free_widget_value (first_wv);
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
2060 return wv;
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
2061 }
a46766b7288a (single_submenu): Handle commands appearing directly in the menu bar.
Richard M. Stallman <rms@gnu.org>
parents: 12361
diff changeset
2062
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2063 return first_wv;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2064 }
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
2065
56848
7201186afcb7 Fix typo in comment string.
Jan Djärv <jan.h.d@swipnet.se>
parents: 56847
diff changeset
2066 /* Walk through the widget_value tree starting at FIRST_WV and update
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
2067 the char * pointers from the corresponding lisp values.
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
2068 We do this after building the whole tree, since GC may happen while the
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
2069 tree is constructed, and small strings are relocated. So we must wait
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
2070 until no GC can happen before storing pointers into lisp values. */
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
2071 static void
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
2072 update_submenu_strings (first_wv)
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
2073 widget_value *first_wv;
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
2074 {
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
2075 widget_value *wv;
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
2076
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
2077 for (wv = first_wv; wv; wv = wv->next)
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
2078 {
56959
dc35c2e20d41 (update_submenu_strings): YAILOM.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56848
diff changeset
2079 if (STRINGP (wv->lname))
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
2080 {
67527
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
2081 wv->name = (char *) SDATA (wv->lname);
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
2082
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
2083 /* Ignore the @ that means "separate pane".
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
2084 This is a kludge, but this isn't worth more time. */
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
2085 if (wv->value == (char *)1)
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
2086 {
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
2087 if (wv->name[0] == '@')
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
2088 wv->name++;
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
2089 wv->value = 0;
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
2090 }
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
2091 }
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
2092
56959
dc35c2e20d41 (update_submenu_strings): YAILOM.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56848
diff changeset
2093 if (STRINGP (wv->lkey))
67527
88807d05a058 * xmenu.c (menubar_selection_callback): Do nothing if the callback
Jan Djärv <jan.h.d@swipnet.se>
parents: 64770
diff changeset
2094 wv->key = (char *) SDATA (wv->lkey);
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
2095
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
2096 if (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
2097 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
2098 }
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
2099 }
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
2100
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2101
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2102 /* 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
2103 changed. Value is non-zero if widgets were updated. */
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2104
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2105 static int
6481
55236c5bca7c (update_frame_menubar): Function renamed from update_one_frame_psheets.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6439
diff changeset
2106 update_frame_menubar (f)
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2107 FRAME_PTR f;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2108 {
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2109 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2110 return xg_update_frame_menubar (f);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2111 #else
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2112 struct x_output *x;
6200
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
2113 int columns, rows;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2114
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2115 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
2116 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2117
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2118 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
2119
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2120 if (!x->menubar_widget || XtIsManaged (x->menubar_widget))
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2121 return 0;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2122
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2123 BLOCK_INPUT;
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2124 /* 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
2125 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
2126 columns = FRAME_COLS (f);
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
2127 rows = FRAME_LINES (f);
6200
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
2128
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2129 /* 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
2130 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
2131 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
2132
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2133 /* 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
2134 order in which they are displayed in the paned window. First,
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2135 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
2136 XtUnmanageChild (x->edit_widget);
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2137
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2138 /* 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
2139 should be there. */
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2140 XtManageChild (x->menubar_widget);
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2141 XtMapWidget (x->menubar_widget);
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2142 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
2143
9236
583bb9211b2b (popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents: 9233
diff changeset
2144 /* 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
2145 XtManageChild (x->edit_widget);
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2146 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
2147
01c57ae8ca57 (update_one_frame_psheets): Call EmacsFrameSetCharSize to
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6198
diff changeset
2148 /* 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
2149 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
2150 UNBLOCK_INPUT;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2151 #endif
36933
01f8906fa0fd Include widget.h.
Gerd Moellmann <gerd@gnu.org>
parents: 36779
diff changeset
2152 return 1;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2153 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2154
12018
f5d820ad7a13 (set_frame_menubar): Always call update_frame_menubar.
Karl Heuer <kwzh@gnu.org>
parents: 11954
diff changeset
2155 /* 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
2156 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
2157 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
2158
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2159 void
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2160 set_frame_menubar (f, first_time, deep_p)
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2161 FRAME_PTR f;
6605
f5b781f33789 (set_frame_menubar): New arg, first_time.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6526
diff changeset
2162 int first_time;
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2163 int deep_p;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2164 {
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2165 xt_or_gtk_widget menubar_widget;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2166 #ifdef USE_X_TOOLKIT
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2167 LWLIB_ID id;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2168 #endif
25730
db88a4b84d91 (single_menu_item, Fx_popup_menu, Fx_popup_menu,
Gerd Moellmann <gerd@gnu.org>
parents: 25680
diff changeset
2169 Lisp_Object items;
9725
98d374d51f4d (set_frame_menubar): Don't copy string during GC risk.
Karl Heuer <kwzh@gnu.org>
parents: 9649
diff changeset
2170 widget_value *wv, *first_wv, *prev_wv = 0;
56959
dc35c2e20d41 (update_submenu_strings): YAILOM.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56848
diff changeset
2171 int i, last_i = 0;
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2172 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
2173 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
2174
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2175 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
2176 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2177
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2178 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
2179
16656
9cbbf721b91c (Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16411
diff changeset
2180 XSETFRAME (Vmenu_updating_frame, f);
9cbbf721b91c (Vmenu_updating_frame): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 16411
diff changeset
2181
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2182 #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
2183 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
2184 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
2185 id = f->output_data.x->id;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2186 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2187
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2188 if (! menubar_widget)
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2189 deep_p = 1;
15792
feeb1f7c1cec (pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15785
diff changeset
2190 else if (pending_menu_activation && !deep_p)
15807
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
2191 deep_p = 1;
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
2192 /* 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
2193 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
2194 {
feeb1f7c1cec (pending_menu_activation): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15785
diff changeset
2195 deep_p = 1;
15807
508ec69917b1 (pending_menu_activation): Don't initialize. Not static.
Richard M. Stallman <rms@gnu.org>
parents: 15795
diff changeset
2196 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
2197 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
2198 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2199
52981
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
2200 #ifdef USE_GTK
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
2201 /* 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
2202 also gets updated. */
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
2203 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
2204 #endif
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
2205
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2206 if (deep_p)
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2207 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2208 /* Make a widget-value tree representing the entire menu trees. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2209
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2210 struct buffer *prev = current_buffer;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2211 Lisp_Object buffer;
46293
1fb8f75062c6 Use macro SPECPDL_INDEX.
Juanma Barranquero <lekktu@gmail.com>
parents: 45803
diff changeset
2212 int specpdl_count = SPECPDL_INDEX ();
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2213 int previous_menu_items_used = f->menu_bar_items_used;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2214 Lisp_Object *previous_items
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2215 = (Lisp_Object *) alloca (previous_menu_items_used
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2216 * 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
2217
17554
0a75fcee3cb8 (set_frame_menubar): When widget is new, forget records of old contents.
Richard M. Stallman <rms@gnu.org>
parents: 17364
diff changeset
2218 /* 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
2219 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
2220 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
2221 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
2222
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2223 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2224 specbind (Qinhibit_quit, Qt);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2225 /* Don't let the debugger step into this code
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2226 because it is not reentrant. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2227 specbind (Qdebug_on_next_call, Qnil);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2228
63147
9bde03db5726 * composite.c (compose_chars_in_text):
Kim F. Storm <storm@cua.dk>
parents: 63070
diff changeset
2229 record_unwind_save_match_data ();
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2230 if (NILP (Voverriding_local_map_menu_flag))
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2231 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2232 specbind (Qoverriding_terminal_local_map, Qnil);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2233 specbind (Qoverriding_local_map, Qnil);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2234 }
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2235
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2236 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
2237
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2238 /* Run the Lucid hook. */
36191
0cee3a77c592 (set_frame_menubar): Run acivate-menu-bar-hook with
Gerd Moellmann <gerd@gnu.org>
parents: 34038
diff changeset
2239 safe_run_hooks (Qactivate_menubar_hook);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2240
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2241 /* If it has changed current-menubar from previous value,
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2242 really recompute the menubar from the value. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2243 if (! NILP (Vlucid_menu_bar_dirty_flag))
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2244 call0 (Qrecompute_lucid_menubar);
14298
6448a36ceaad (set_frame_menubar):
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2245 safe_run_hooks (Qmenu_bar_update_hook);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2246 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
2247
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2248 items = FRAME_MENU_BAR_ITEMS (f);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2249
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2250 /* 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
2251 if (previous_menu_items_used)
53ed5f089c9e (set_frame_menubar): Take into account that
Gerd Moellmann <gerd@gnu.org>
parents: 37940
diff changeset
2252 bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items,
53ed5f089c9e (set_frame_menubar): Take into account that
Gerd Moellmann <gerd@gnu.org>
parents: 37940
diff changeset
2253 previous_menu_items_used * sizeof (Lisp_Object));
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2254
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2255 /* 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
2256 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
2257 save_menu_items ();
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
2258
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2259 menu_items = f->menu_bar_vector;
38594
53ed5f089c9e (set_frame_menubar): Take into account that
Gerd Moellmann <gerd@gnu.org>
parents: 37940
diff changeset
2260 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
2261 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
2262 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
2263 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
2264 submenu_top_level_items
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2265 = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2266 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
2267 for (i = 0; i < XVECTOR (items)->size; i += 4)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2268 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2269 Lisp_Object key, string, maps;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2270
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2271 last_i = i;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2272
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2273 key = XVECTOR (items)->contents[i];
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2274 string = XVECTOR (items)->contents[i + 1];
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2275 maps = XVECTOR (items)->contents[i + 2];
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2276 if (NILP (string))
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2277 break;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2278
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2279 submenu_start[i] = menu_items_used;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2280
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2281 menu_items_n_panes = 0;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2282 submenu_top_level_items[i]
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2283 = 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
2284 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
2285
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2286 submenu_end[i] = menu_items_used;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2287 }
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2288
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2289 finish_menu_items ();
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2290
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2291 /* 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
2292 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
2293
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2294 wv = xmalloc_widget_value ();
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2295 wv->name = "menubar";
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2296 wv->value = 0;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2297 wv->enabled = 1;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2298 wv->button_type = BUTTON_TYPE_NONE;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2299 wv->help = Qnil;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2300 first_wv = wv;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2301
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2302 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
2303 {
48946
2c4a754e02b6 (parse_single_submenu): Use individual keymap's prompt
Richard M. Stallman <rms@gnu.org>
parents: 48912
diff changeset
2304 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
2305 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
2306 submenu_top_level_items[i]);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2307 if (prev_wv)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2308 prev_wv->next = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2309 else
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2310 first_wv->contents = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2311 /* 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
2312 wv->enabled = 1;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2313 wv->button_type = BUTTON_TYPE_NONE;
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2314 prev_wv = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2315 }
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2316
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2317 set_buffer_internal_1 (prev);
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2318
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2319 /* 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
2320 of the menu bar, skip redisplaying it. Just exit. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2321
70086
c12e24e779ab Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 70085
diff changeset
2322 /* 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
2323 for (i = 0; i < previous_menu_items_used; i++)
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2324 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
2325 || (!EQ (previous_items[i], XVECTOR (menu_items)->contents[i])))
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2326 break;
13654
645e14e39a2b (set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents: 13489
diff changeset
2327 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
2328 {
70086
c12e24e779ab Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 70085
diff changeset
2329 /* The menu items have not changed. Don't bother updating
c12e24e779ab Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 70085
diff changeset
2330 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
2331 free_menubar_widget_value_tree (first_wv);
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
2332 discard_menu_items ();
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
2333 unbind_to (specpdl_count, Qnil);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2334 return;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2335 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2336
70086
c12e24e779ab Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 70085
diff changeset
2337 /* 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
2338 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
2339 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
2340
70086
c12e24e779ab Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 70085
diff changeset
2341 /* This calls restore_menu_items to restore menu_items, etc.,
c12e24e779ab Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 70085
diff changeset
2342 as they were outside. */
70085
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
2343 unbind_to (specpdl_count, Qnil);
93e99c27012e (restore_menu_items, save_menu_items): New fns.
Richard M. Stallman <rms@gnu.org>
parents: 69017
diff changeset
2344
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2345 /* 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
2346 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
2347 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
2348 for (i = 0; i < XVECTOR (items)->size; i += 4)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2349 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2350 Lisp_Object string;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2351 string = XVECTOR (items)->contents[i + 1];
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2352 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
2353 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
2354 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
2355 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
2356 wv = wv->next;
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2357 }
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2358
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2359 }
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2360 else
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2361 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2362 /* Make a widget-value tree containing
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2363 just the top level menu bar strings. */
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2364
46753
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2365 wv = xmalloc_widget_value ();
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2366 wv->name = "menubar";
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2367 wv->value = 0;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2368 wv->enabled = 1;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2369 wv->button_type = BUTTON_TYPE_NONE;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2370 wv->help = Qnil;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2371 first_wv = wv;
5e95e401d481 (set_frame_menubar): First parse all submenus,
Richard M. Stallman <rms@gnu.org>
parents: 46370
diff changeset
2372
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2373 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
2374 for (i = 0; i < XVECTOR (items)->size; i += 4)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2375 {
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2376 Lisp_Object string;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2377
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2378 string = XVECTOR (items)->contents[i + 1];
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2379 if (NILP (string))
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2380 break;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2381
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
2382 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
2383 wv->name = (char *) SDATA (string);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2384 wv->value = 0;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2385 wv->enabled = 1;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2386 wv->button_type = BUTTON_TYPE_NONE;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
2387 wv->help = Qnil;
15785
9902d8a8a548 (set_frame_menubar): Use -1 for call_data
Richard M. Stallman <rms@gnu.org>
parents: 15710
diff changeset
2388 /* 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
2389 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
2390 /* 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
2391 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
2392 wv->call_data = (void *) (EMACS_INT) (-1);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2393
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2394 if (prev_wv)
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2395 prev_wv->next = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2396 else
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2397 first_wv->contents = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2398 prev_wv = wv;
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2399 }
13654
645e14e39a2b (set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents: 13489
diff changeset
2400
645e14e39a2b (set_frame_menubar): When called with deep_p == 0,
Richard M. Stallman <rms@gnu.org>
parents: 13489
diff changeset
2401 /* 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
2402 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
2403 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
2404 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
2405 }
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2406
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2407 /* 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
2408
fca5a32f7806 (popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents: 11266
diff changeset
2409 BLOCK_INPUT;
fca5a32f7806 (popup_get_selection): Queue up events that aren't
Richard M. Stallman <rms@gnu.org>
parents: 11266
diff changeset
2410
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2411 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2412 xg_crazy_callback_abort = 1;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2413 if (menubar_widget)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2414 {
52981
54482f5ea7be Remove tear off capability for GTK popup menus.
Jan Djärv <jan.h.d@swipnet.se>
parents: 52401
diff changeset
2415 /* 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
2416 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
2417 xg_modify_menubar_widgets (menubar_widget,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2418 f,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2419 first_wv,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2420 deep_p,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2421 G_CALLBACK (menubar_selection_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2422 G_CALLBACK (popup_deactivate_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2423 G_CALLBACK (menu_highlight_callback));
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2424 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2425 else
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2426 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2427 GtkWidget *wvbox = f->output_data.x->vbox_widget;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2428
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2429 menubar_widget
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2430 = xg_create_widget ("menubar", "menubar", f, first_wv,
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2431 G_CALLBACK (menubar_selection_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2432 G_CALLBACK (popup_deactivate_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2433 G_CALLBACK (menu_highlight_callback));
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2434
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2435 f->output_data.x->menubar_widget = menubar_widget;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2436 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2437
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2438
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2439 #else /* not USE_GTK */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2440 if (menubar_widget)
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2441 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2442 /* 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
2443 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
2444
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2445 /* 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
2446 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
2447 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
2448
9236
583bb9211b2b (popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents: 9233
diff changeset
2449 /* 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
2450 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
2451 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2452 else
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2453 {
59102
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
2454 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
2455 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
2456
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2457 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
2458 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
2459 0,
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2460 popup_activate_callback,
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2461 menubar_selection_callback,
27341
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
2462 popup_deactivate_callback,
ab22130d8fe3 (enum menu_item_idx): New enumeration replacing defines
Gerd Moellmann <gerd@gnu.org>
parents: 26729
diff changeset
2463 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
2464 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
2465
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
2466 /* 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
2467 XtOverrideTranslations (menubar_widget, override);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2468 }
11898
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
2469
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
2470 {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2471 int 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
2472 = (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
2473 ? (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
2474 + 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
2475 : 0);
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
2476
15943
16fb6dcfa4e8 (set_frame_menubar): Don't add ibw to menubar_size.
Richard M. Stallman <rms@gnu.org>
parents: 15912
diff changeset
2477 #if 0 /* Experimentally, we now get the right results
16fb6dcfa4e8 (set_frame_menubar): Don't add ibw to menubar_size.
Richard M. Stallman <rms@gnu.org>
parents: 15912
diff changeset
2478 for -geometry -0-0 without this. 24 Aug 96, rms. */
13489
ddf90bfd3744 Don't include Xaw/Paned.h unless USE_LUCID is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13071
diff changeset
2479 #ifdef USE_LUCID
11898
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
2480 if (FRAME_EXTERNAL_MENU_BAR (f))
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
2481 {
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
2482 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
2483 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
2484 XtNinternalBorderWidth, &ibw, NULL);
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
2485 menubar_size += ibw;
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
2486 }
13489
ddf90bfd3744 Don't include Xaw/Paned.h unless USE_LUCID is defined.
Richard M. Stallman <rms@gnu.org>
parents: 13071
diff changeset
2487 #endif /* USE_LUCID */
15943
16fb6dcfa4e8 (set_frame_menubar): Don't add ibw to menubar_size.
Richard M. Stallman <rms@gnu.org>
parents: 15912
diff changeset
2488 #endif /* 0 */
11898
a23359be806b (set_frame_menubar): Set menubar_height field.
Karl Heuer <kwzh@gnu.org>
parents: 11655
diff changeset
2489
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
2490 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
2491 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2492 #endif /* not USE_GTK */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2493
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2494 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
2495 update_frame_menubar (f);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2496
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2497 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2498 xg_crazy_callback_abort = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2499 #endif
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2500
12634
eec80ea06395 (set_frame_menubar): If the Lisp-level menu bar menus
Richard M. Stallman <rms@gnu.org>
parents: 12625
diff changeset
2501 UNBLOCK_INPUT;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2502 }
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
2503
14036
621a575db6f7 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13821
diff changeset
2504 /* 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
2505 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
2506 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
2507 is visible. */
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2508
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2509 void
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2510 initialize_frame_menubar (f)
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2511 FRAME_PTR f;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2512 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2513 /* 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
2514 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
2515 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
2516 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
2517 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2518
37022
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
2519
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2520 /* 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
2521 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
2522 For GTK this function is in gtkutil.c. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2523
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2524 #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
2525 void
5a68abc8f1f9 (free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5896
diff changeset
2526 free_frame_menubar (f)
5a68abc8f1f9 (free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5896
diff changeset
2527 FRAME_PTR f;
5a68abc8f1f9 (free_frame_menubar) [USE_X_TOOLKIT]. New function to destroy the X Widget
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5896
diff changeset
2528 {
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
2529 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
2530
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2531 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
2532 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2533
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
2534 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
2535
c73494a6bcd3 (free_frame_menubar): Clear menubar_height field.
Richard M. Stallman <rms@gnu.org>
parents: 17709
diff changeset
2536 f->output_data.x->menubar_height = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2537
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
2538 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
2539 {
37022
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
2540 #ifdef USE_MOTIF
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
2541 /* 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
2542 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
2543 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
2544 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
2545 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
2546 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
2547 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
2548 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
2549 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
2550 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2551
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
2552 BLOCK_INPUT;
37022
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
2553
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
2554 #ifdef USE_MOTIF
37211
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
2555 if (f->output_data.x->widget)
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
2556 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
2557 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2558
12667
a3466dad7d6d Renamings: frame->display => frame->output, struct x_display -> sruct x_output.
Richard M. Stallman <rms@gnu.org>
parents: 12661
diff changeset
2559 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
2560 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
2561
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
2562 #ifdef USE_MOTIF
37211
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
2563 if (f->output_data.x->widget)
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
2564 {
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
2565 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
2566 if (x1 == 0 && y1 == 0)
afa458ac7a62 (free_frame_menubar) [USE_MOTIF]: Preserve the
Gerd Moellmann <gerd@gnu.org>
parents: 37022
diff changeset
2567 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
2568 }
37022
d7d30cecd891 (free_frame_menubar) [USE_MOTIF]: If the shell widget's
Gerd Moellmann <gerd@gnu.org>
parents: 36958
diff changeset
2569 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2570
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
2571 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
2572 }
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
2573 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2574 #endif /* not USE_GTK */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2575
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2576 #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
2577
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2578 /* 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
2579 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
2580 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
2581 Both assume input is blocked by the caller. */
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2582
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2583 /* 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
2584 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
2585 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
2586 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
2587 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
2588 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
2589 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
2590 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
2591 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
2592 (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
2593
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2594 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2595
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2596 /* The item selected in the popup menu. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2597 static Lisp_Object *volatile menu_item_selection;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2598
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2599 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2600
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2601 /* 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
2602 create_and_show_popup_menu below. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2603 struct next_popup_x_y
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2604 {
49651
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
2605 FRAME_PTR f;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2606 int x;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2607 int y;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2608 };
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2609
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2610 /* 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
2611 menu where the pointer is.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2612 MENU is the menu to pop up.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2613 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
2614 PUSH_IN is not documented in the GTK manual.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2615 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
2616 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
2617 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
2618
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2619 Here only X and Y are used. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2620 static void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2621 menu_position_func (menu, x, y, push_in, user_data)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2622 GtkMenu *menu;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2623 gint *x;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2624 gint *y;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2625 gboolean *push_in;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2626 gpointer user_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2627 {
49651
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
2628 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
2629 GtkRequisition req;
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
2630 int disp_width = FRAME_X_DISPLAY_INFO (data->f)->width;
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
2631 int disp_height = FRAME_X_DISPLAY_INFO (data->f)->height;
58171
e08eaff3b8ab (pop_down_menu): Return nil.
Kim F. Storm <storm@cua.dk>
parents: 58170
diff changeset
2632
49651
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
2633 *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
2634 *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
2635
05ebf4266798 xterm.c (x_make_frame_visible): Call gtk_window_deiconify.
Jan Djärv <jan.h.d@swipnet.se>
parents: 49600
diff changeset
2636 /* 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
2637 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
2638 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
2639 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
2640 *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
2641 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
2642 *y -= data->y + req.height - disp_height;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2643 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2644
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2645 static void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2646 popup_selection_callback (widget, client_data)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2647 GtkWidget *widget;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2648 gpointer client_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2649 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2650 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
2651
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2652 if (xg_crazy_callback_abort) return;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2653 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
2654 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2655
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
2656 static Lisp_Object
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2657 pop_down_menu (arg)
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2658 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
2659 {
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2660 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
2661
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
2662 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
2663 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
2664 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
2665 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
2666 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
2667 }
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
2668
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2669 /* 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
2670 menu pops down.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2671 menu_item_selection will be set to the selection. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2672 static void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2673 create_and_show_popup_menu (f, first_wv, x, y, for_click)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2674 FRAME_PTR f;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2675 widget_value *first_wv;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2676 int x;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2677 int y;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2678 int for_click;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2679 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2680 int i;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2681 GtkWidget *menu;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2682 GtkMenuPositionFunc pos_func = 0; /* Pop up at pointer. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2683 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
2684 int specpdl_count = SPECPDL_INDEX ();
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2685
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2686 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
2687 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2688
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2689 xg_crazy_callback_abort = 1;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2690 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
2691 G_CALLBACK (popup_selection_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2692 G_CALLBACK (popup_deactivate_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2693 G_CALLBACK (menu_highlight_callback));
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2694 xg_crazy_callback_abort = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2695
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2696 if (! for_click)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2697 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2698 /* 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
2699 pos_func = menu_position_func;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2700
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2701 /* 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
2702 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
2703 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
2704
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2705 popup_x_y.x = x;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2706 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
2707 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
2708
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
2709 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
2710 }
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
2711 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
2712 {
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
2713 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
2714 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
2715 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
2716 }
61619
489414dfb069 Remove eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 60890
diff changeset
2717
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2718 /* Display the menu. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2719 gtk_widget_show_all (menu);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2720 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2721
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
2722 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
2723
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
2724 if (GTK_WIDGET_MAPPED (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
2725 {
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
2726 /* 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
2727 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
2728 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
2729 /* 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
2730 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
2731 }
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
2732
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
2733 unbind_to (specpdl_count, Qnil);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2734
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2735 /* 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
2736 to Emacs event loop. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2737 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2738 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2739
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2740 #else /* not USE_GTK */
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2741
9336
d5ffd9c9edb0 (widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents: 9236
diff changeset
2742 /* 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
2743 library.
da016ba65a6c (xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents: 11907
diff changeset
2744
da016ba65a6c (xmenu_show, xdialog_show): Increment widget_id_tick
Karl Heuer <kwzh@gnu.org>
parents: 11907
diff changeset
2745 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
2746 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
2747
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
2748 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
2749 next_menubar_widget_id. */
9336
d5ffd9c9edb0 (widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents: 9236
diff changeset
2750 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
2751
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2752 static void
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2753 popup_selection_callback (widget, id, client_data)
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2754 Widget widget;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2755 LWLIB_ID id;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2756 XtPointer client_data;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2757 {
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2758 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
2759 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
2760
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
2761 /* 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
2762 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
2763
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
2764 static Lisp_Object
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
2765 pop_down_menu (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
2766 Lisp_Object 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
2767 {
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
2768 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
2769 | 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
2770
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
2771 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
2772 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
2773 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
2774 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
2775
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
2776 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
2777 }
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
2778
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2779 /* 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
2780 menu pops down.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2781 menu_item_selection will be set to the selection. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2782 static void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2783 create_and_show_popup_menu (f, first_wv, x, y, for_click)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2784 FRAME_PTR f;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2785 widget_value *first_wv;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2786 int x;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2787 int y;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2788 int for_click;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2789 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2790 int i;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2791 Arg av[2];
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2792 int ac = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2793 XButtonPressedEvent dummy;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2794 LWLIB_ID menu_id;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2795 Widget menu;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2796
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2797 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
2798 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2799
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2800 menu_id = widget_id_tick++;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2801 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
2802 f->output_data.x->widget, 1, 0,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2803 popup_selection_callback,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2804 popup_deactivate_callback,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2805 menu_highlight_callback);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2806
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2807 dummy.type = ButtonPress;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2808 dummy.serial = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2809 dummy.send_event = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2810 dummy.display = FRAME_X_DISPLAY (f);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2811 dummy.time = CurrentTime;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2812 dummy.root = FRAME_X_DISPLAY_INFO (f)->root_window;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2813 dummy.window = dummy.root;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2814 dummy.subwindow = dummy.root;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2815 dummy.x = x;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2816 dummy.y = y;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2817
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2818 /* 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
2819 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
2820 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
2821
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2822 dummy.x_root = x;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2823 dummy.y_root = y;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2824
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2825 dummy.state = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2826 dummy.button = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2827 for (i = 0; i < 5; i++)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2828 if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i))
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2829 dummy.button = i;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2830
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2831 /* Don't allow any geometry request from the user. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2832 XtSetArg (av[ac], XtNgeometry, 0); ac++;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2833 XtSetValues (menu, av, ac);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2834
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2835 /* Display the menu. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2836 lw_popup_menu (menu, (XEvent *) &dummy);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2837 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
2838 x_activate_timeout_atimer ();
61619
489414dfb069 Remove eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 60890
diff changeset
2839
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
2840 {
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
2841 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
2842 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
2843 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
2844 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
2845 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
2846
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
2847 /* 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
2848 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
2849
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
2850 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
2851 }
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2852 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2853
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2854 #endif /* not USE_GTK */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
2855
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2856 static Lisp_Object
11491
272baf4a077a (xmenu_show, xdialog_show): Delete menubarp arg.
Richard M. Stallman <rms@gnu.org>
parents: 11449
diff changeset
2857 xmenu_show (f, x, y, for_click, keymaps, title, error)
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2858 FRAME_PTR f;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2859 int x;
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2860 int y;
10757
2829c9840b0e (xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents: 10716
diff changeset
2861 int for_click;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2862 int keymaps;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2863 Lisp_Object title;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2864 char **error;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
2865 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2866 int i;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2867 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
2868 widget_value **submenu_stack
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2869 = (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
2870 Lisp_Object *subprefix_stack
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2871 = (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
2872 int submenu_depth = 0;
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
2873
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2874 int first_pane;
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2875
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2876 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
2877 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
2878
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2879 *error = NULL;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2880
7335
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
2881 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
2882 {
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
2883 *error = "Empty menu";
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
2884 return Qnil;
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
2885 }
5896
b20145eafe0c (xmenu_show) [USE_X_TOOLKIT]: return Qnil when val is null.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 5881
diff changeset
2886
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2887 /* 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
2888 representing the panes and their items. */
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
2889 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
2890 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
2891 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
2892 wv->enabled = 1;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2893 wv->button_type = BUTTON_TYPE_NONE;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
2894 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
2895 first_wv = wv;
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2896 first_pane = 1;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2897
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2898 /* 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
2899 i = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2900 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
2901 {
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2902 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
2903 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2904 submenu_stack[submenu_depth++] = save_wv;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2905 save_wv = prev_wv;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2906 prev_wv = 0;
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2907 first_pane = 1;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2908 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2909 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2910 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
2911 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2912 prev_wv = save_wv;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2913 save_wv = submenu_stack[--submenu_depth];
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2914 first_pane = 0;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2915 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2916 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2917 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
2918 && submenu_depth != 0)
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2919 i += MENU_ITEMS_PANE_LENGTH;
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2920 /* Ignore a nil in the item list.
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2921 It's meaningful only for dialog boxes. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
2922 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
2923 i += 1;
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2924 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
2925 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2926 /* 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
2927 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
2928 char *pane_string;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2929
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2930 pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2931 prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2932
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
2933 #ifndef HAVE_MULTILINGUAL_MENU
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2934 if (STRINGP (pane_name) && STRING_MULTIBYTE (pane_name))
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2935 {
60583
44c9c79a2c7a (ENCODE_MENU_STRING): Explicitly use string_make_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59914
diff changeset
2936 pane_name = ENCODE_MENU_STRING (pane_name);
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2937 AREF (menu_items, i + MENU_ITEMS_PANE_NAME) = pane_name;
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2938 }
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
2939 #endif
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2940 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
2941 ? "" : (char *) SDATA (pane_name));
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
2942 /* 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
2943 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
2944 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
2945 pane_string = "";
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2946
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2947 /* 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
2948 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
2949 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
2950 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
2951 {
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
2952 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
2953 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
2954 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
2955 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2956 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
2957 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
2958 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
2959 wv->name++;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2960 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
2961 wv->enabled = 1;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2962 wv->button_type = BUTTON_TYPE_NONE;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
2963 wv->help = Qnil;
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2964 save_wv = wv;
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2965 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
2966 }
7521
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2967 else if (first_pane)
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2968 {
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2969 save_wv = wv;
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2970 prev_wv = 0;
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2971 }
2971264ff9aa (xmenu_show): Completely ignore nameless panes
Richard M. Stallman <rms@gnu.org>
parents: 7459
diff changeset
2972 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
2973 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
2974 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2975 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2976 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
2977 /* 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
2978 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: 37929
diff changeset
2979 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2980 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2981 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2982 def = AREF (menu_items, i + MENU_ITEMS_ITEM_DEFINITION);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2983 type = AREF (menu_items, i + MENU_ITEMS_ITEM_TYPE);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2984 selected = AREF (menu_items, i + MENU_ITEMS_ITEM_SELECTED);
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2985 help = AREF (menu_items, i + MENU_ITEMS_ITEM_HELP);
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2986
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
2987 #ifndef HAVE_MULTILINGUAL_MENU
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2988 if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2989 {
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
2990 item_name = ENCODE_MENU_STRING (item_name);
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2991 AREF (menu_items, i + MENU_ITEMS_ITEM_NAME) = item_name;
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2992 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
2993
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
2994 if (STRINGP (descrip) && STRING_MULTIBYTE (descrip))
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2995 {
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
2996 descrip = ENCODE_MENU_STRING (descrip);
37940
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2997 AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY) = descrip;
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2998 }
e76f885709fc (single_submenu, xmenu_show) [!HAVE_MULTILINGUAL_MENU]:
Gerd Moellmann <gerd@gnu.org>
parents: 37929
diff changeset
2999 #endif /* not HAVE_MULTILINGUAL_MENU */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3000
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
3001 wv = xmalloc_widget_value ();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3002 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
3003 prev_wv->next = wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3004 else
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3005 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
3006 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
3007 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
3008 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
3009 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
3010 /* 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
3011 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
3012 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
3013 wv->call_data
358d48409854 Don't include ../oldXMenu/XMenu.h if USE_X_TOOLKIT.
Richard M. Stallman <rms@gnu.org>
parents: 9725
diff changeset
3014 = (!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
3015 wv->enabled = !NILP (enable);
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3016
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3017 if (NILP (type))
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3018 wv->button_type = BUTTON_TYPE_NONE;
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3019 else if (EQ (type, QCtoggle))
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3020 wv->button_type = BUTTON_TYPE_TOGGLE;
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3021 else if (EQ (type, QCradio))
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3022 wv->button_type = BUTTON_TYPE_RADIO;
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3023 else
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3024 abort ();
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3025
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3026 wv->selected = !NILP (selected);
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
3027
41769
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
3028 if (! STRINGP (help))
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
3029 help = Qnil;
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
3030
26c1876db9e3 (menu_highlight_callback): Use `help' field as Lisp_Object.
Richard M. Stallman <rms@gnu.org>
parents: 40993
diff changeset
3031 wv->help = help;
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
3032
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3033 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
3034
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3035 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
3036 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3037 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3038
9236
583bb9211b2b (popup_get_selection): Remove BLOCK_INPUT, UNBLOCK_INPUT since the
Paul Reilly <pmr@pajato.com>
parents: 9233
diff changeset
3039 /* 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
3040 if (!NILP (title))
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3041 {
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
3042 widget_value *wv_title = xmalloc_widget_value ();
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
3043 widget_value *wv_sep1 = xmalloc_widget_value ();
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
3044 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
3045
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3046 wv_sep2->name = "--";
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3047 wv_sep2->next = first_wv->contents;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
3048 wv_sep2->help = Qnil;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3049
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3050 wv_sep1->name = "--";
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3051 wv_sep1->next = wv_sep2;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
3052 wv_sep1->help = Qnil;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3053
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
3054 #ifndef HAVE_MULTILINGUAL_MENU
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
3055 if (STRING_MULTIBYTE (title))
51404
e518bae63784 (ENCODE_MENU_STRING): New.
Dave Love <fx@gnu.org>
parents: 51212
diff changeset
3056 title = ENCODE_MENU_STRING (title);
23302
dcff2a4b6cb4 (single_submenu) [! HAVE_MULTILINGUAL_MENU]: Make
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
3057 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3058
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
3059 wv_title->name = (char *) SDATA (title);
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
3060 wv_title->enabled = TRUE;
24993
Gerd Moellmann <gerd@gnu.org>
parents: 23302
diff changeset
3061 wv_title->button_type = BUTTON_TYPE_NONE;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3062 wv_title->next = wv_sep1;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
3063 wv_title->help = Qnil;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3064 first_wv->contents = wv_title;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3065 }
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3066
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3067 /* No selection has been chosen yet. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3068 menu_item_selection = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3069
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3070 /* Actually create and show the menu until popped down. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3071 create_and_show_popup_menu (f, first_wv, x, y, for_click);
8414
8a8d2cdd4218 (xmenu_show): Ignore any geometry resource from the user.
Richard M. Stallman <rms@gnu.org>
parents: 8269
diff changeset
3072
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3073 /* 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
3074 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
3075
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3076 /* 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
3077 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
3078 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
3079 {
11655
a9f93ce6e1b4 (xmenu_show, menubar_selection_callback): Move declaration
Karl Heuer <kwzh@gnu.org>
parents: 11614
diff changeset
3080 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
3081
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31465
diff changeset
3082 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
3083 i = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3084 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
3085 {
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3086 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
3087 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3088 subprefix_stack[submenu_depth++] = prefix;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3089 prefix = entry;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3090 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3091 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3092 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
3093 {
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3094 prefix = subprefix_stack[--submenu_depth];
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3095 i++;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3096 }
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3097 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
3098 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3099 prefix
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3100 = 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
3101 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
3102 }
13071
2e514396cbc8 (popup_get_selection): Pop menu down if button is pressed
Richard M. Stallman <rms@gnu.org>
parents: 12747
diff changeset
3103 /* 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
3104 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
3105 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
3106 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
3107 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3108 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3109 entry
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3110 = 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
3111 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
3112 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3113 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
3114 {
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3115 int j;
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3116
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3117 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
3118 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
3119 entry = Fcons (prefix, entry);
6291
38ec8e76594f (Fx_popup_menu): If POSITION is nil,
Richard M. Stallman <rms@gnu.org>
parents: 6200
diff changeset
3120 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
3121 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
3122 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
3123 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3124 return entry;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3125 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3126 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
3127 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3128 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3129 }
61984
2ce055c7db65 [not HAVE_X_TOOLKIT] (xmenu_show):
Richard M. Stallman <rms@gnu.org>
parents: 61620
diff changeset
3130 else if (!for_click)
2ce055c7db65 [not HAVE_X_TOOLKIT] (xmenu_show):
Richard M. Stallman <rms@gnu.org>
parents: 61620
diff changeset
3131 /* Make "Cancel" equivalent to C-g. */
2ce055c7db65 [not HAVE_X_TOOLKIT] (xmenu_show):
Richard M. Stallman <rms@gnu.org>
parents: 61620
diff changeset
3132 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
3133
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3134 return Qnil;
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
3135 }
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3136
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3137 #ifdef USE_GTK
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3138 static void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3139 dialog_selection_callback (widget, client_data)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3140 GtkWidget *widget;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3141 gpointer client_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3142 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3143 /* 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
3144 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
3145 if ((int) (EMACS_INT) client_data != -1)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3146 menu_item_selection = (Lisp_Object *) client_data;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3147
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3148 popup_activated_flag = 0;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3149 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3150
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3151 /* 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
3152 dialog pops down.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3153 menu_item_selection will be set to the selection. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3154 static void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3155 create_and_show_dialog (f, first_wv)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3156 FRAME_PTR f;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3157 widget_value *first_wv;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3158 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3159 GtkWidget *menu;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3160
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
3161 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
3162 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
3163
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3164 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
3165 G_CALLBACK (dialog_selection_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3166 G_CALLBACK (popup_deactivate_callback),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3167 0);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3168
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3169 if (menu)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3170 {
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
3171 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
3172 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
3173
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3174 /* Display the menu. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3175 gtk_widget_show_all (menu);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3176
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3177 /* 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
3178 popup_widget_loop (1, menu);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3179
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
3180 unbind_to (specpdl_count, Qnil);
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3181 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3182 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3183
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3184 #else /* not USE_GTK */
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3185 static void
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3186 dialog_selection_callback (widget, id, client_data)
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3187 Widget widget;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3188 LWLIB_ID id;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3189 XtPointer client_data;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3190 {
11266
3e93d8b99b05 (menubar_selection_callback, dialog_selection_callback)
Richard M. Stallman <rms@gnu.org>
parents: 11237
diff changeset
3191 /* 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
3192 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
3193 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
3194 menu_item_selection = (Lisp_Object *) client_data;
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3195
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3196 BLOCK_INPUT;
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3197 lw_destroy_all_widgets (id);
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3198 UNBLOCK_INPUT;
11614
fdd0d5bdd8c6 (popup_get_selection): Use x_non_menubar_window_to_frame.
Karl Heuer <kwzh@gnu.org>
parents: 11528
diff changeset
3199 popup_activated_flag = 0;
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3200 }
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
3201
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3202
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3203 /* 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
3204 dialog pops down.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3205 menu_item_selection will be set to the selection. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3206 static void
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3207 create_and_show_dialog (f, first_wv)
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3208 FRAME_PTR f;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3209 widget_value *first_wv;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3210 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3211 LWLIB_ID dialog_id;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3212
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
3213 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
3214 abort();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
3215
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3216 dialog_id = widget_id_tick++;
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3217 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
3218 f->output_data.x->widget, 1, 0,
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3219 dialog_selection_callback, 0, 0);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3220 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
3221
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3222 /* Display the dialog box. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3223 lw_pop_up_all_widgets (dialog_id);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3224 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
3225 x_activate_timeout_atimer ();
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3226
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3227 /* Process events that apply to the dialog box.
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3228 Also handle timers. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3229 {
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3230 int count = SPECPDL_INDEX ();
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3231 int fact = 4 * sizeof (LWLIB_ID);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3232
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3233 /* 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
3234 record_unwind_protect (pop_down_menu,
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3235 Fcons (make_number (dialog_id >> (fact)),
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3236 make_number (dialog_id & ~(-1 << (fact)))));
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3237
57965
9b14127a651a * eval.c (Feval): Remove check for INPUT_BLOCKED_P.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57928
diff changeset
3238 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
3239 dialog_id, 1);
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3240
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3241 unbind_to (count, Qnil);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3242 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3243 }
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3244
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3245 #endif /* not USE_GTK */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3246
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3247 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
3248 "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
3249 "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
3250
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3251 static Lisp_Object
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3252 xdialog_show (f, keymaps, title, header, 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
3253 FRAME_PTR f;
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3254 int keymaps;
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3255 Lisp_Object title, header;
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3256 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
3257 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3258 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
3259 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
3260
25730
db88a4b84d91 (single_menu_item, Fx_popup_menu, Fx_popup_menu,
Gerd Moellmann <gerd@gnu.org>
parents: 25680
diff changeset
3261 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
3262
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3263 /* Number of elements seen so far, before boundary. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3264 int left_count = 0;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3265 /* 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
3266 int boundary_seen = 0;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3267
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
3268 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
3269 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
3270
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3271 *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
3272
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
3273 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
3274 {
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3275 *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
3276 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
3277 }
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
3278
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3279 /* 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
3280 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
3281 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3282 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
3283 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
3284 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
3285 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
3286 pane_string = (NILP (pane_name)
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3287 ? "" : (char *) SDATA (pane_name));
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
3288 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
3289 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
3290 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
3291 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
3292 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
3293 prev_wv->name = "message";
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
3294 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
3295 first_wv = prev_wv;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3296
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3297 /* 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
3298 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
3299 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
3300 {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3301
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3302 /* 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
3303 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
3304 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
3305 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
3306 descrip
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3307 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3308
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
3309 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
3310 {
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
3311 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
3312 *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
3313 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
3314 }
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3315 if (EQ (item_name, Qquote))
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3316 {
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3317 /* This is the boundary between left-side elts
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3318 and right-side elts. Stop incrementing right_count. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3319 boundary_seen = 1;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3320 i++;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3321 continue;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3322 }
15912
afb0bb1cdbe6 (xdialog_show): Don't allow 9 buttons.
Richard M. Stallman <rms@gnu.org>
parents: 15839
diff changeset
3323 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
3324 {
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
3325 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
3326 *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
3327 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
3328 }
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
3329
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
3330 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
3331 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
3332 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
3333 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
3334 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
3335 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
3336 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
3337 wv->enabled = !NILP (enable);
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
3338 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
3339 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
3340
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3341 if (! boundary_seen)
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3342 left_count++;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3343
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3344 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
3345 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
3346 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3347
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3348 /* If the boundary was not specified,
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3349 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
3350 if (! boundary_seen)
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3351 left_count = nb_buttons - nb_buttons / 2;
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3352
14546
bc0388a7c282 (xmalloc_widget_value): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14298
diff changeset
3353 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
3354 wv->name = dialog_name;
42588
43a330df6213 (set_frame_menubar, xmenu_show):
Jason Rumney <jasonr@gnu.org>
parents: 42586
diff changeset
3355 wv->help = Qnil;
62661
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3356
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3357 /* 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
3358 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
3359 a popup for errors. */
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3360 if (NILP(header))
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3361 dialog_name[0] = 'Q';
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3362 else
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3363 dialog_name[0] = 'I';
0db5674a79de (Fx_popup_dialog): Add a third boolean argument to
Nick Roberts <nickrob@snap.net.nz>
parents: 62216
diff changeset
3364
6426
1f1388aa2d44 (Fx_popup_dialog): Don't fail to set X, Y from POSITION.
Richard M. Stallman <rms@gnu.org>
parents: 6424
diff changeset
3365 /* 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
3366 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
3367 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
3368 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
3369 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
3370 dialog_name[3] = 'R';
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3371 /* Number of buttons to put on the right. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3372 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
3373 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
3374 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
3375 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
3376 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3377
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3378 /* 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
3379 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
3380
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3381 /* Actually create and show the dialog. */
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3382 create_and_show_dialog (f, first_wv);
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3383
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3384 /* 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
3385 free_menubar_widget_value_tree (first_wv);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3386
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3387 /* Find the selected item, and its pane, to return
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3388 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
3389 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
3390 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3391 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
3392
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3393 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
3394 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
3395 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
3396 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3397 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
3398
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3399 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
3400 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3401 prefix
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3402 = 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
3403 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
3404 }
31465
b58d8e366faa (xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents: 31365
diff changeset
3405 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
3406 {
b58d8e366faa (xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents: 31365
diff changeset
3407 /* 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
3408 right-side elts. */
b58d8e366faa (xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents: 31365
diff changeset
3409 ++i;
b58d8e366faa (xdialog_show): When looking up the selection in
Gerd Moellmann <gerd@gnu.org>
parents: 31365
diff changeset
3410 }
6307
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3411 else
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3412 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3413 entry
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3414 = 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
3415 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
3416 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3417 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
3418 {
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3419 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
3420 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
3421 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
3422 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3423 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
3424 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3425 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
3426 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3427 }
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3428 }
59102
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
3429 else
0096c58ce34a * xmenu.c (popup_get_selection): Pop down on C-g.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58824
diff changeset
3430 /* 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
3431 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
3432
1f9fa4022502 (xdialog_show): New function to handle the display of dialog boxes.
Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
parents: 6291
diff changeset
3433 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
3434 }
30299
f2cd2bf063c9 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30215
diff changeset
3435
49322
2cbb0b823e83 GTK version
Jan Djärv <jan.h.d@swipnet.se>
parents: 49302
diff changeset
3436 #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
3437
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3438 /* 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
3439 Used to generate menu help events. */
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3440
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3441 static struct frame *menu_help_frame;
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3442
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3443
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3444 /* 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
3445
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3446 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
3447 the menu (currently not used).
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3448
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3449 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
3450 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
3451 keyboard events. */
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3452
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3453 static void
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3454 menu_help_callback (help_string, pane, item)
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3455 char *help_string;
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3456 int pane, item;
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3457 {
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3458 extern Lisp_Object Qmenu_item;
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3459 Lisp_Object *first_item;
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3460 Lisp_Object pane_name;
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3461 Lisp_Object menu_object;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3462
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3463 first_item = XVECTOR (menu_items)->contents;
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3464 if (EQ (first_item[0], Qt))
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3465 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
3466 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
3467 /* This shouldn't happen, see xmenu_show. */
40477
a56267e601e4 Include coding.h and charset.h.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40239
diff changeset
3468 pane_name = empty_string;
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3469 else
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3470 pane_name = first_item[MENU_ITEMS_ITEM_NAME];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3471
30363
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3472 /* (menu-item MENU-NAME PANE-NUMBER) */
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3473 menu_object = Fcons (Qmenu_item,
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3474 Fcons (pane_name,
8f11e306dc02 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30299
diff changeset
3475 Fcons (make_number (pane), Qnil)));
30299
f2cd2bf063c9 (menu_help_callback): Call show_help_echo with
Gerd Moellmann <gerd@gnu.org>
parents: 30215
diff changeset
3476 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
3477 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
3478 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3479
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
3480 static Lisp_Object
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
3481 pop_down_menu (arg)
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
3482 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
3483 {
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
3484 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
3485 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
3486
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
3487 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
3488 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
3489
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
3490 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
3491 #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
3492 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
3493 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
3494 #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
3495 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
3496
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
3497 #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
3498 /* 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
3499 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
3500 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
3501
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
3502 /* 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
3503 (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
3504 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
3505 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
3506 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
3507
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
3508 #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
3509
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
3510 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
3511
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
3512 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
3513 }
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
3514
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3515
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3516 static Lisp_Object
11491
272baf4a077a (xmenu_show, xdialog_show): Delete menubarp arg.
Richard M. Stallman <rms@gnu.org>
parents: 11449
diff changeset
3517 xmenu_show (f, x, y, for_click, keymaps, title, error)
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3518 FRAME_PTR f;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3519 int x, y;
10757
2829c9840b0e (xmenu_show, both versions): New arg for_click.
Richard M. Stallman <rms@gnu.org>
parents: 10716
diff changeset
3520 int for_click;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3521 int keymaps;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3522 Lisp_Object title;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3523 char **error;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3524 {
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3525 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
3526 XMenu *menu;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3527 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
3528 Lisp_Object entry, pane_prefix;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3529 char *datap;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3530 int ulx, uly, width, height;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3531 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
3532 int i, j, lines, maxlines;
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3533 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
3534 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
3535 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
3536 int specpdl_count = SPECPDL_INDEX ();
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
3537
83370
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
3538 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
3539 abort ();
5272862a4865 Fix crashes in xdialog_show (and other places) with xterm-mouse-mode.
Karoly Lorentey <lorentey@elte.hu>
parents: 83353
diff changeset
3540
3747
6506b2fd475a (xmenu_show): Store 0 in *ERROR at the beginning.
Richard M. Stallman <rms@gnu.org>
parents: 3501
diff changeset
3541 *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
3542 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
3543 return Qnil;
1082
d24afc1bef38 (xmenu_show): If no panes, just return.
Richard M. Stallman <rms@gnu.org>
parents: 975
diff changeset
3544
7335
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
3545 if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
3546 {
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
3547 *error = "Empty menu";
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
3548 return Qnil;
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
3549 }
73d1276933e1 (xmenu_show): Disallow empty menus.
Karl Heuer <kwzh@gnu.org>
parents: 7334
diff changeset
3550
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3551 /* 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
3552 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
3553 &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
3554 &dummy_uint, &dummy_uint);
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
3555
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3556 /* 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
3557 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
3558 if (menu == NULL)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3559 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3560 *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
3561 return Qnil;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3562 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3563
67743
3c879987313f (xmenu_show): Call inhibit_garbage_collection.
Richard M. Stallman <rms@gnu.org>
parents: 67703
diff changeset
3564 /* 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
3565 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
3566 contents of strings. */
3c879987313f (xmenu_show): Call inhibit_garbage_collection.
Richard M. Stallman <rms@gnu.org>
parents: 67703
diff changeset
3567 inhibit_garbage_collection ();
3c879987313f (xmenu_show): Call inhibit_garbage_collection.
Richard M. Stallman <rms@gnu.org>
parents: 67703
diff changeset
3568
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9546
diff changeset
3569 #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
3570 /* 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
3571 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
3572 y += FRAME_OUTER_TO_INNER_DIFF_Y (f);
9572
b36d5e88cccc *** empty log message ***
Morten Welinder <terra@diku.dk>
parents: 9546
diff changeset
3573 #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
3574
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3575 /* 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
3576 x += f->left_pos;
332134065648 Make (some) trivial substitutions for renamed and
Kim F. Storm <storm@cua.dk>
parents: 50938
diff changeset
3577 y += f->top_pos;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3578
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3579 /* 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
3580 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
3581 while (i < menu_items_used)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3582 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3583 if (EQ (XVECTOR (menu_items)->contents[i], Qt))
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3584 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3585 /* 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
3586 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
3587 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
3588
58824
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
3589 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
3590 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
3591 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
3592 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
3593 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
3594 ? "" : (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
3595 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
3596 pane_string++;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3597
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
3598 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
3599 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
3600 {
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
3601 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
3602 *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
3603 return Qnil;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3604 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3605 i += MENU_ITEMS_PANE_LENGTH;
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3606
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3607 /* 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
3608 maxwidth = 0;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3609 j = i;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3610 while (j < menu_items_used)
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3611 {
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3612 Lisp_Object item;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3613 item = XVECTOR (menu_items)->contents[j];
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3614 if (EQ (item, Qt))
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3615 break;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3616 if (NILP (item))
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3617 {
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3618 j++;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3619 continue;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3620 }
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
3621 width = SBYTES (item);
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3622 if (width > maxwidth)
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3623 maxwidth = width;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3624
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3625 j += MENU_ITEMS_ITEM_LENGTH;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3626 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3627 }
6746
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3628 /* Ignore a nil in the item list.
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3629 It's meaningful only for dialog boxes. */
cda1ce7952ca (Fx_popup_dialog): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6656
diff changeset
3630 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
3631 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
3632 else
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3633 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3634 /* 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
3635 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
3636 unsigned char *item_data;
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3637 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
3638
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3639 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
3640 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
3641 descrip
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3642 = 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
3643 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
3644 help_string = STRINGP (help) ? SDATA (help) : NULL;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3645
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3646 if (!NILP (descrip))
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3647 {
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
3648 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
3649 #ifdef C_ALLOCA
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3650 Lisp_Object spacer;
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3651 spacer = Fmake_string (make_number (gap), make_number (' '));
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3652 item_name = concat2 (item_name, spacer);
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3653 item_name = concat2 (item_name, descrip);
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
3654 item_data = SDATA (item_name);
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3655 #else
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3656 /* 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
3657 to reduce gc needs. */
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3658 item_data
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3659 = (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
3660 + SBYTES (descrip) + 1);
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
3661 bcopy (SDATA (item_name), item_data,
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
3662 SBYTES (item_name));
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
3663 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
3664 item_data[j] = ' ';
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
3665 bcopy (SDATA (descrip), item_data + j,
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
3666 SBYTES (descrip));
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
3667 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
3668 #endif
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3669 }
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3670 else
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 46293
diff changeset
3671 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
3672
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
3673 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
3674 menu, lpane, 0, item_data,
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3675 !NILP (enable), help_string)
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3676 == XM_FAILURE)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3677 {
9608
1a85137cb257 Use FRAME_X_DISPLAY, not XDISPLAY or x_current_display.
Richard M. Stallman <rms@gnu.org>
parents: 9572
diff changeset
3678 XMenuDestroy (FRAME_X_DISPLAY (f), menu);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3679 *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
3680 return Qnil;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3681 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3682 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
3683 lines++;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3684 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3685 }
6881
796416bd7f7e (last_menu_bar_item_end): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 6764
diff changeset
3686
58824
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
3687 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
3688
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3689 /* 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
3690 XMenuRecompute (FRAME_X_DISPLAY (f), menu);
37255
ff709975abaf (xmenu_show): Use FRAME_X_SCREEN_NUMBER.
Gerd Moellmann <gerd@gnu.org>
parents: 37211
diff changeset
3691 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
3692 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
3693 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
3694 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
3695 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
3696 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
3697 XMenuLocate (FRAME_X_DISPLAY (f), menu, 0, 0, x, y,
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3698 &ulx, &uly, &width, &height);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3699 if (ulx+width > dispwidth)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3700 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3701 x -= (ulx + width) - dispwidth;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3702 ulx = dispwidth - width;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3703 }
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3704 if (uly+height > dispheight)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3705 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3706 y -= (uly + height) - dispheight;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3707 uly = dispheight - height;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3708 }
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3709 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
3710 if (uly < 0) y -= uly;
6526
95661fd7a320 (xmenu_show): Enable asynchronous events.
Karl Heuer <kwzh@gnu.org>
parents: 6481
diff changeset
3711
58824
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
3712 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
3713 {
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
3714 /* 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
3715 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
3716 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
3717 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
3718 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
3719 }
8da33d42472e * xmenu.c (Fx_popup_menu): Correct documentation about position.
Jan Djärv <jan.h.d@swipnet.se>
parents: 58283
diff changeset
3720
6526
95661fd7a320 (xmenu_show): Enable asynchronous events.
Karl Heuer <kwzh@gnu.org>
parents: 6481
diff changeset
3721 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
3722 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
3723 pane = selidx = 0;
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3724
58168
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
3725 #ifndef MSDOS
ab22e6ae6fac * xmenu.c (x_menu_wait_for_event): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 57965
diff changeset
3726 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
3727 #endif
61619
489414dfb069 Remove eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 60890
diff changeset
3728
58215
8f529503ae83 * xmenu.c (pop_down_menu): Remove global variable current_menu,
Jan Djärv <jan.h.d@swipnet.se>
parents: 58202
diff changeset
3729 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
3730 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
3731 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
3732
27458
2bfd43d89c8e (xmenu_show) [!USE_X_TOOLKIT]: Pass help to
Gerd Moellmann <gerd@gnu.org>
parents: 27425
diff changeset
3733 /* 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
3734 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
3735 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
3736 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
3737 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
3738 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
3739
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3740 switch (status)
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3741 {
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3742 case XM_SUCCESS:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3743 #ifdef XDEBUG
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3744 fprintf (stderr, "pane= %d line = %d\n", panes, selidx);
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3745 #endif
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3746
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3747 /* 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
3748 i = 0;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3749 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
3750 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3751 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
3752 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3753 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
3754 pane_prefix
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3755 = 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
3756 pane--;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3757 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
3758 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3759 else
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3760 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3761 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
3762 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3763 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
3764 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3765 entry
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3766 = 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
3767 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
3768 {
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3769 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
3770 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
3771 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
3772 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3773 break;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3774 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3775 selidx--;
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3776 }
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3777 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
3778 }
2747
f258c79c9162 (Fx_popup_menu): Add a vector of prefix keys for the panes.
Richard M. Stallman <rms@gnu.org>
parents: 2514
diff changeset
3779 }
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3780 break;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3781
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3782 case XM_FAILURE:
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3783 *error = "Can't activate menu";
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3784 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
3785 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
3786 break;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3787 case XM_NO_SELECT:
61984
2ce055c7db65 [not HAVE_X_TOOLKIT] (xmenu_show):
Richard M. Stallman <rms@gnu.org>
parents: 61620
diff changeset
3788 /* 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
3789 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
3790 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
3791 Fsignal (Qquit, Qnil);
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3792 entry = Qnil;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3793 break;
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3794 }
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
3795
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
3796 unbind_to (specpdl_count, Qnil);
7208
2d3c771ff861 (xdialog_show): Clear x_mouse_grabbed.
Richard M. Stallman <rms@gnu.org>
parents: 7175
diff changeset
3797
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3798 return entry;
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3799 }
9233
746cc6b0d28f (widget_id_tick): Renamed from popup_id_tick.
Paul Reilly <pmr@pajato.com>
parents: 9102
diff changeset
3800
5673
7035bc81858b Find lwlib.h and xlwmenuP.h in ../lwlib.
Richard M. Stallman <rms@gnu.org>
parents: 5602
diff changeset
3801 #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
3802
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
3803 #endif /* HAVE_MENUS */
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3804
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21268
diff changeset
3805 void
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3806 syms_of_xmenu ()
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3807 {
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3808 staticpro (&menu_items);
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3809 menu_items = Qnil;
48113
6a09e4b41337 (unuse_menu_items): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46753
diff changeset
3810 menu_items_inuse = Qnil;
6058
662b9cd767fe (Fx_popup_menu): Allow t as position, meaning use mouse pos.
Richard M. Stallman <rms@gnu.org>
parents: 6018
diff changeset
3811
12625
e2831d2f5b09 (syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents: 12432
diff changeset
3812 Qdebug_on_next_call = intern ("debug-on-next-call");
e2831d2f5b09 (syms_of_xmenu): Set up Qdebug_on_next_call.
Richard M. Stallman <rms@gnu.org>
parents: 12432
diff changeset
3813 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
3814
9336
d5ffd9c9edb0 (widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents: 9236
diff changeset
3815 #ifdef USE_X_TOOLKIT
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49322
diff changeset
3816 widget_id_tick = (1<<16);
12661
3c0fbefb3833 Include buffer.h.
Richard M. Stallman <rms@gnu.org>
parents: 12634
diff changeset
3817 next_menubar_widget_id = 1;
9336
d5ffd9c9edb0 (widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents: 9236
diff changeset
3818 #endif
d5ffd9c9edb0 (widget_id_tick): Move definition into conditional.
Richard M. Stallman <rms@gnu.org>
parents: 9236
diff changeset
3819
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3820 defsubr (&Sx_popup_menu);
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
3821
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
3822 #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
3823 defsubr (&Sx_menu_bar_open_internal);
2d56e13fd23d Merged from emacs@sv.gnu.org
Karoly Lorentey <lorentey@elte.hu>
parents: 83537 73320
diff changeset
3824 Ffset (intern ("accelerate-menu"),
2d56e13fd23d Merged from emacs@sv.gnu.org
Karoly Lorentey <lorentey@elte.hu>
parents: 83537 73320
diff changeset
3825 intern (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
3826 #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
3827
14741
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
3828 #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
3829 defsubr (&Sx_popup_dialog);
14741
9f9c4d4581e4 Put most of file into HAVE_MENUS conditional.
Richard M. Stallman <rms@gnu.org>
parents: 14553
diff changeset
3830 #endif
118
49342840ba00 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3831 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51575
diff changeset
3832
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51575
diff changeset
3833 /* arch-tag: 92ea573c-398e-496e-ac73-2436f7d63242
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51575
diff changeset
3834 (do not change this comment) */