aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-06-02 22:01:21 +0400
committerDmitry Antipov2014-06-02 22:01:21 +0400
commit5668fb88bf3731d39c4e958c8e79a549f789ce1e (patch)
treeb0d3fd3555fca3b34c47b803a633da2f36d31165 /src
parentda11196a248b530c3b3a8329497d71332f8c71a3 (diff)
downloademacs-5668fb88bf3731d39c4e958c8e79a549f789ce1e.tar.gz
emacs-5668fb88bf3731d39c4e958c8e79a549f789ce1e.zip
Use common memory management functions for lwlib and refactor users.
* lwlib/lwlib.h (widget_value): Do not maintain a free list any more. (malloc_widget_value, free_widget_value): Remove prototypes. * lwlib/lwlib.c (malloc_widget_value, free_widget_value): (widget_value_free_list, malloc_cpt): Remove. (free_widget_value_tree, copy_widget_value_tree): Adjust users. * src/menu.h (xmalloc_widget_value): Replaced by ... (make_widget_value): ... new prototype. * src/menu.c (xmalloc_widget_value): Replaced by ... (make_widget_value): ... new function. (free_menubar_widget_value_tree, digest_single_submenu): Adjust users. * src/gtkutil.c (malloc_widget_value, free_widget_value): (widget_value_free_list, malloc_cpt): Remove old lwlib-compatible code. * src/keyboard.h (enum button_type, struct _widget_value): * src/gtkutil.h, src/nsgui.h, src/w32gui.h (malloc_widget_value): (free_widget_value): Likewise. * src/nsmenu.m (ns_update_menubar, ns_menu_show): * src/w32menu.c (set_frame_menubar, w32_menu_show, w32_dialog_show): * src/xmenu.c (set_frame_menubar, xmenu_show, x_dialog_show): Adjust users. * src/xterm.h (XtParent) [USE_GTK]: Remove unused macro.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog18
-rw-r--r--src/gtkutil.c51
-rw-r--r--src/gtkutil.h4
-rw-r--r--src/keyboard.h51
-rw-r--r--src/menu.c43
-rw-r--r--src/menu.h6
-rw-r--r--src/nsgui.h5
-rw-r--r--src/nsmenu.m52
-rw-r--r--src/w32gui.h5
-rw-r--r--src/w32menu.c69
-rw-r--r--src/xmenu.c74
-rw-r--r--src/xterm.h1
12 files changed, 84 insertions, 295 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1f321a9df4b..f0c0c973be8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,23 @@
12014-06-02 Dmitry Antipov <dmantipov@yandex.ru> 12014-06-02 Dmitry Antipov <dmantipov@yandex.ru>
2 2
3 Adjust to match recent lwlib changes.
4 * menu.h (xmalloc_widget_value): Replaced by ...
5 (make_widget_value): ... new prototype.
6 * menu.c (xmalloc_widget_value): Replaced by ...
7 (make_widget_value): ... new function.
8 (free_menubar_widget_value_tree, digest_single_submenu): Adjust users.
9 * gtkutil.c (malloc_widget_value, free_widget_value):
10 (widget_value_free_list, malloc_cpt): Remove old lwlib-compatible code.
11 * keyboard.h (enum button_type, struct _widget_value):
12 * gtkutil.h, nsgui.h, w32gui.h (malloc_widget_value, free_widget_value):
13 Likewise.
14 * nsmenu.m (ns_update_menubar, ns_menu_show):
15 * w32menu.c (set_frame_menubar, w32_menu_show, w32_dialog_show):
16 * xmenu.c (set_frame_menubar, xmenu_show, x_dialog_show): Adjust users.
17 * xterm.h (XtParent) [USE_GTK]: Remove unused macro.
18
192014-06-02 Dmitry Antipov <dmantipov@yandex.ru>
20
3 * image.c (x_query_frame_background_color) 21 * image.c (x_query_frame_background_color)
4 [HAVE_PNG || HAVE_NS || HAVE_IMAGEMAGICK || HAVE_RSVG]: 22 [HAVE_PNG || HAVE_NS || HAVE_IMAGEMAGICK || HAVE_RSVG]:
5 Fix --enable-gcc-warnings compilation without image libraries. 23 Fix --enable-gcc-warnings compilation without image libraries.
diff --git a/src/gtkutil.c b/src/gtkutil.c
index cebff68614f..8614fe57cb2 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -221,57 +221,6 @@ xg_display_close (Display *dpy)
221/*********************************************************************** 221/***********************************************************************
222 Utility functions 222 Utility functions
223 ***********************************************************************/ 223 ***********************************************************************/
224/* The next two variables and functions are taken from lwlib. */
225static widget_value *widget_value_free_list;
226static int malloc_cpt;
227
228/* Allocate a widget_value structure, either by taking one from the
229 widget_value_free_list or by malloc:ing a new one.
230
231 Return a pointer to the allocated structure. */
232
233widget_value *
234malloc_widget_value (void)
235{
236 widget_value *wv;
237 if (widget_value_free_list)
238 {
239 wv = widget_value_free_list;
240 widget_value_free_list = wv->free_list;
241 wv->free_list = 0;
242 }
243 else
244 {
245 wv = xmalloc (sizeof *wv);
246 malloc_cpt++;
247 }
248 memset (wv, 0, sizeof (widget_value));
249 return wv;
250}
251
252/* This is analogous to free. It frees only what was allocated
253 by malloc_widget_value, and no substructures. */
254
255void
256free_widget_value (widget_value *wv)
257{
258 if (wv->free_list)
259 emacs_abort ();
260
261 if (malloc_cpt > 25)
262 {
263 /* When the number of already allocated cells is too big,
264 We free it. */
265 xfree (wv);
266 malloc_cpt--;
267 }
268 else
269 {
270 wv->free_list = widget_value_free_list;
271 widget_value_free_list = wv;
272 }
273}
274
275 224
276/* Create and return the cursor to be used for popup menus and 225/* Create and return the cursor to be used for popup menus and
277 scroll bars on display DPY. */ 226 scroll bars on display DPY. */
diff --git a/src/gtkutil.h b/src/gtkutil.h
index b576fc6d9fe..345b3283e6d 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
24#ifdef USE_GTK 24#ifdef USE_GTK
25 25
26#include <gtk/gtk.h> 26#include <gtk/gtk.h>
27#include "../lwlib/lwlib.h"
27#include "frame.h" 28#include "frame.h"
28#include "xterm.h" 29#include "xterm.h"
29 30
@@ -74,9 +75,6 @@ typedef struct xg_menu_item_cb_data_
74 75
75} xg_menu_item_cb_data; 76} xg_menu_item_cb_data;
76 77
77extern struct _widget_value *malloc_widget_value (void) ATTRIBUTE_MALLOC;
78extern void free_widget_value (struct _widget_value *);
79
80extern bool xg_uses_old_file_dialog (void) ATTRIBUTE_CONST; 78extern bool xg_uses_old_file_dialog (void) ATTRIBUTE_CONST;
81 79
82extern char *xg_get_file_name (struct frame *f, 80extern char *xg_get_file_name (struct frame *f,
diff --git a/src/keyboard.h b/src/keyboard.h
index 8bb54dd86e0..8a72d03416f 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -354,57 +354,6 @@ extern void unuse_menu_items (void);
354#define ENCODE_MENU_STRING(str) (str) 354#define ENCODE_MENU_STRING(str) (str)
355#endif 355#endif
356 356
357#if defined (HAVE_NS) || defined (HAVE_NTGUI) || defined (USE_GTK)
358
359/* Definitions copied from lwlib.h */
360
361enum button_type
362{
363 BUTTON_TYPE_NONE,
364 BUTTON_TYPE_TOGGLE,
365 BUTTON_TYPE_RADIO
366};
367
368/* This structure is based on the one in ../lwlib/lwlib.h, with unused portions
369 removed. No term uses these. */
370typedef struct _widget_value
371{
372 /* name of widget */
373 Lisp_Object lname;
374 const char* name;
375 /* value (meaning depend on widget type) */
376 const char* value;
377 /* keyboard equivalent. no implications for XtTranslations */
378 Lisp_Object lkey;
379 const char* key;
380 /* Help string or nil if none.
381 GC finds this string through the frame's menu_bar_vector
382 or through menu_items. */
383 Lisp_Object help;
384 /* true if enabled */
385 unsigned char enabled;
386 /* true if selected */
387 unsigned char selected;
388 /* The type of a button. */
389 enum button_type button_type;
390#if defined (HAVE_NTGUI)
391 /* true if menu title */
392 unsigned char title;
393#endif
394 /* Contents of the sub-widgets, also selected slot for checkbox */
395 struct _widget_value* contents;
396 /* data passed to callback */
397 void *call_data;
398 /* next one in the list */
399 struct _widget_value* next;
400#ifdef USE_GTK
401 struct _widget_value *free_list;
402#endif
403} widget_value;
404
405#endif /* HAVE_NS || HAVE_NTGUI */
406
407
408/* Macros for dealing with lispy events. */ 357/* Macros for dealing with lispy events. */
409 358
410/* True if EVENT has data fields describing it (i.e. a mouse click). */ 359/* True if EVENT has data fields describing it (i.e. a mouse click). */
diff --git a/src/menu.c b/src/menu.c
index 468f2814eb4..0cd886f55d1 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -576,21 +576,26 @@ parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name,
576 576
577#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (HAVE_NTGUI) 577#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (HAVE_NTGUI)
578 578
579/* Allocate a widget_value, blocking input. */ 579/* Allocate and basically initialize widget_value, blocking input. */
580 580
581widget_value * 581widget_value *
582xmalloc_widget_value (void) 582make_widget_value (const char *name, char *value,
583 bool enabled, Lisp_Object help)
583{ 584{
584 widget_value *value; 585 widget_value *wv;
585 586
586 block_input (); 587 block_input ();
587 value = malloc_widget_value (); 588 wv = xzalloc (sizeof (widget_value));
588 unblock_input (); 589 unblock_input ();
589 590
590 return value; 591 wv->name = (char *) name;
592 wv->value = value;
593 wv->enabled = enabled;
594 wv->help = help;
595 return wv;
591} 596}
592 597
593/* This recursively calls free_widget_value on the tree of widgets. 598/* This recursively calls xfree on the tree of widgets.
594 It must free all data that was malloc'ed for these widget_values. 599 It must free all data that was malloc'ed for these widget_values.
595 In Emacs, many slots are pointers into the data of Lisp_Strings, and 600 In Emacs, many slots are pointers into the data of Lisp_Strings, and
596 must be left alone. */ 601 must be left alone. */
@@ -613,7 +618,7 @@ free_menubar_widget_value_tree (widget_value *wv)
613 wv->next = (widget_value *) 0xDEADBEEF; 618 wv->next = (widget_value *) 0xDEADBEEF;
614 } 619 }
615 block_input (); 620 block_input ();
616 free_widget_value (wv); 621 xfree (wv);
617 unblock_input (); 622 unblock_input ();
618} 623}
619 624
@@ -632,12 +637,8 @@ digest_single_submenu (int start, int end, bool top_level_items)
632 struct frame *f = XFRAME (Vmenu_updating_frame); 637 struct frame *f = XFRAME (Vmenu_updating_frame);
633 638
634 submenu_stack = alloca (menu_items_used * sizeof *submenu_stack); 639 submenu_stack = alloca (menu_items_used * sizeof *submenu_stack);
635 wv = xmalloc_widget_value (); 640 wv = make_widget_value ("menu", NULL, true, Qnil);
636 wv->name = "menu";
637 wv->value = 0;
638 wv->enabled = 1;
639 wv->button_type = BUTTON_TYPE_NONE; 641 wv->button_type = BUTTON_TYPE_NONE;
640 wv->help = Qnil;
641 first_wv = wv; 642 first_wv = wv;
642 save_wv = 0; 643 save_wv = 0;
643 prev_wv = 0; 644 prev_wv = 0;
@@ -721,17 +722,14 @@ digest_single_submenu (int start, int end, bool top_level_items)
721 with its items as a submenu beneath it. */ 722 with its items as a submenu beneath it. */
722 if (strcmp (pane_string, "")) 723 if (strcmp (pane_string, ""))
723 { 724 {
724 wv = xmalloc_widget_value (); 725 /* Set value to 1 so update_submenu_strings can handle '@'. */
726 wv = make_widget_value (NULL, (char *) 1, true, Qnil);
725 if (save_wv) 727 if (save_wv)
726 save_wv->next = wv; 728 save_wv->next = wv;
727 else 729 else
728 first_wv->contents = wv; 730 first_wv->contents = wv;
729 wv->lname = pane_name; 731 wv->lname = pane_name;
730 /* Set value to 1 so update_submenu_strings can handle '@' */
731 wv->value = (char *)1;
732 wv->enabled = 1;
733 wv->button_type = BUTTON_TYPE_NONE; 732 wv->button_type = BUTTON_TYPE_NONE;
734 wv->help = Qnil;
735 save_wv = wv; 733 save_wv = wv;
736 } 734 }
737 else 735 else
@@ -805,7 +803,8 @@ digest_single_submenu (int start, int end, bool top_level_items)
805#endif 803#endif
806 } 804 }
807 805
808 wv = xmalloc_widget_value (); 806 wv = make_widget_value (NULL, NULL, !NILP (enable),
807 STRINGP (help) ? help : Qnil);
809 if (prev_wv) 808 if (prev_wv)
810 prev_wv->next = wv; 809 prev_wv->next = wv;
811 else 810 else
@@ -814,11 +813,9 @@ digest_single_submenu (int start, int end, bool top_level_items)
814 wv->lname = item_name; 813 wv->lname = item_name;
815 if (!NILP (descrip)) 814 if (!NILP (descrip))
816 wv->lkey = descrip; 815 wv->lkey = descrip;
817 wv->value = 0;
818 /* The intptr_t cast avoids a warning. There's no problem 816 /* The intptr_t cast avoids a warning. There's no problem
819 as long as pointers have enough bits to hold small integers. */ 817 as long as pointers have enough bits to hold small integers. */
820 wv->call_data = (!NILP (def) ? (void *) (intptr_t) i : 0); 818 wv->call_data = (!NILP (def) ? (void *) (intptr_t) i : 0);
821 wv->enabled = !NILP (enable);
822 819
823 if (NILP (type)) 820 if (NILP (type))
824 wv->button_type = BUTTON_TYPE_NONE; 821 wv->button_type = BUTTON_TYPE_NONE;
@@ -830,10 +827,6 @@ digest_single_submenu (int start, int end, bool top_level_items)
830 emacs_abort (); 827 emacs_abort ();
831 828
832 wv->selected = !NILP (selected); 829 wv->selected = !NILP (selected);
833 if (! STRINGP (help))
834 help = Qnil;
835
836 wv->help = help;
837 830
838 prev_wv = wv; 831 prev_wv = wv;
839 832
@@ -846,7 +839,7 @@ digest_single_submenu (int start, int end, bool top_level_items)
846 if (top_level_items && first_wv->contents && first_wv->contents->next == 0) 839 if (top_level_items && first_wv->contents && first_wv->contents->next == 0)
847 { 840 {
848 wv = first_wv->contents; 841 wv = first_wv->contents;
849 free_widget_value (first_wv); 842 xfree (first_wv);
850 return wv; 843 return wv;
851 } 844 }
852 845
diff --git a/src/menu.h b/src/menu.h
index 429dcfa6221..89a8729fd43 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -20,6 +20,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20#define MENU_H 20#define MENU_H
21 21
22#include "systime.h" /* for Time */ 22#include "systime.h" /* for Time */
23#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \
24 || defined (HAVE_NS)
25#include "../lwlib/lwlib.h" /* for widget_value */
26#endif
23 27
24#ifdef HAVE_NTGUI 28#ifdef HAVE_NTGUI
25extern Lisp_Object Qunsupported__w32_dialog; 29extern Lisp_Object Qunsupported__w32_dialog;
@@ -41,7 +45,7 @@ extern void free_menubar_widget_value_tree (widget_value *);
41extern void update_submenu_strings (widget_value *); 45extern void update_submenu_strings (widget_value *);
42extern void find_and_call_menu_selection (struct frame *, int, 46extern void find_and_call_menu_selection (struct frame *, int,
43 Lisp_Object, void *); 47 Lisp_Object, void *);
44extern widget_value *xmalloc_widget_value (void); 48extern widget_value *make_widget_value (const char *, char *, bool, Lisp_Object);
45extern widget_value *digest_single_submenu (int, int, bool); 49extern widget_value *digest_single_submenu (int, int, bool);
46#endif 50#endif
47 51
diff --git a/src/nsgui.h b/src/nsgui.h
index 5935531fa48..0e1e9bb73e9 100644
--- a/src/nsgui.h
+++ b/src/nsgui.h
@@ -48,11 +48,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
48#undef _GL_VERIFY_H 48#undef _GL_VERIFY_H
49#include <verify.h> 49#include <verify.h>
50 50
51/* menu-related */
52#define free_widget_value(wv) xfree (wv)
53#define malloc_widget_value() ((widget_value *) memset (xmalloc \
54 (sizeof (widget_value)), 0, sizeof (widget_value)))
55
56/* Emulate XCharStruct. */ 51/* Emulate XCharStruct. */
57typedef struct _XCharStruct 52typedef struct _XCharStruct
58{ 53{
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 24842241f37..e5f0b7668bc 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -266,12 +266,8 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
266 266
267 /* parse stage 2: insert into lucid 'widget_value' structures 267 /* parse stage 2: insert into lucid 'widget_value' structures
268 [comments in other terms say not to evaluate lisp code here] */ 268 [comments in other terms say not to evaluate lisp code here] */
269 wv = xmalloc_widget_value (); 269 wv = make_widget_value ("menubar", NULL, true, Qnil);
270 wv->name = "menubar";
271 wv->value = 0;
272 wv->enabled = 1;
273 wv->button_type = BUTTON_TYPE_NONE; 270 wv->button_type = BUTTON_TYPE_NONE;
274 wv->help = Qnil;
275 first_wv = wv; 271 first_wv = wv;
276 272
277 for (i = 0; i < 4*n; i += 4) 273 for (i = 0; i < 4*n; i += 4)
@@ -378,12 +374,8 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
378 int n; 374 int n;
379 Lisp_Object string; 375 Lisp_Object string;
380 376
381 wv = xmalloc_widget_value (); 377 wv = make_widget_value ("menubar", NULL, true, Qnil);
382 wv->name = "menubar";
383 wv->value = 0;
384 wv->enabled = 1;
385 wv->button_type = BUTTON_TYPE_NONE; 378 wv->button_type = BUTTON_TYPE_NONE;
386 wv->help = Qnil;
387 first_wv = wv; 379 first_wv = wv;
388 380
389 /* Make widget-value tree w/ just the top level menu bar strings */ 381 /* Make widget-value tree w/ just the top level menu bar strings */
@@ -439,12 +431,8 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
439 memcpy (previous_strings[i/4], SDATA (string), 431 memcpy (previous_strings[i/4], SDATA (string),
440 min (10, SBYTES (string) + 1)); 432 min (10, SBYTES (string) + 1));
441 433
442 wv = xmalloc_widget_value (); 434 wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
443 wv->name = SSDATA (string);
444 wv->value = 0;
445 wv->enabled = 1;
446 wv->button_type = BUTTON_TYPE_NONE; 435 wv->button_type = BUTTON_TYPE_NONE;
447 wv->help = Qnil;
448 wv->call_data = (void *) (intptr_t) (-1); 436 wv->call_data = (void *) (intptr_t) (-1);
449 437
450#ifdef NS_IMPL_COCOA 438#ifdef NS_IMPL_COCOA
@@ -838,12 +826,8 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
838 p.x = x; p.y = y; 826 p.x = x; p.y = y;
839 827
840 /* now parse stage 2 as in ns_update_menubar */ 828 /* now parse stage 2 as in ns_update_menubar */
841 wv = xmalloc_widget_value (); 829 wv = make_widget_value ("contextmenu", NULL, true, Qnil);
842 wv->name = "contextmenu";
843 wv->value = 0;
844 wv->enabled = 1;
845 wv->button_type = BUTTON_TYPE_NONE; 830 wv->button_type = BUTTON_TYPE_NONE;
846 wv->help = Qnil;
847 first_wv = wv; 831 first_wv = wv;
848 832
849#if 0 833#if 0
@@ -914,18 +898,14 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
914 with its items as a submenu beneath it. */ 898 with its items as a submenu beneath it. */
915 if (!keymaps && strcmp (pane_string, "")) 899 if (!keymaps && strcmp (pane_string, ""))
916 { 900 {
917 wv = xmalloc_widget_value (); 901 wv = make_widget_value (pane_string, NULL, true, Qnil);
918 if (save_wv) 902 if (save_wv)
919 save_wv->next = wv; 903 save_wv->next = wv;
920 else 904 else
921 first_wv->contents = wv; 905 first_wv->contents = wv;
922 wv->name = pane_string;
923 if (keymaps && !NILP (prefix)) 906 if (keymaps && !NILP (prefix))
924 wv->name++; 907 wv->name++;
925 wv->value = 0;
926 wv->enabled = 1;
927 wv->button_type = BUTTON_TYPE_NONE; 908 wv->button_type = BUTTON_TYPE_NONE;
928 wv->help = Qnil;
929 save_wv = wv; 909 save_wv = wv;
930 prev_wv = 0; 910 prev_wv = 0;
931 } 911 }
@@ -963,20 +943,18 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
963 } 943 }
964#endif /* not HAVE_MULTILINGUAL_MENU */ 944#endif /* not HAVE_MULTILINGUAL_MENU */
965 945
966 wv = xmalloc_widget_value (); 946 wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enabled),
947 STRINGP (help) ? help : Qnil);
967 if (prev_wv) 948 if (prev_wv)
968 prev_wv->next = wv; 949 prev_wv->next = wv;
969 else 950 else
970 save_wv->contents = wv; 951 save_wv->contents = wv;
971 wv->name = SSDATA (item_name);
972 if (!NILP (descrip)) 952 if (!NILP (descrip))
973 wv->key = SSDATA (descrip); 953 wv->key = SSDATA (descrip);
974 wv->value = 0;
975 /* If this item has a null value, 954 /* If this item has a null value,
976 make the call_data null so that it won't display a box 955 make the call_data null so that it won't display a box
977 when the mouse is on it. */ 956 when the mouse is on it. */
978 wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0; 957 wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
979 wv->enabled = !NILP (enable);
980 958
981 if (NILP (type)) 959 if (NILP (type))
982 wv->button_type = BUTTON_TYPE_NONE; 960 wv->button_type = BUTTON_TYPE_NONE;
@@ -989,11 +967,6 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
989 967
990 wv->selected = !NILP (selected); 968 wv->selected = !NILP (selected);
991 969
992 if (! STRINGP (help))
993 help = Qnil;
994
995 wv->help = help;
996
997 prev_wv = wv; 970 prev_wv = wv;
998 971
999 i += MENU_ITEMS_ITEM_LENGTH; 972 i += MENU_ITEMS_ITEM_LENGTH;
@@ -1004,24 +977,19 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
1004 977
1005 if (!NILP (title)) 978 if (!NILP (title))
1006 { 979 {
1007 widget_value *wv_title = xmalloc_widget_value (); 980 widget_value *wv_title;
1008 widget_value *wv_sep = xmalloc_widget_value (); 981 widget_value *wv_sep = make_widget_value ("--", NULL, false, Qnil);
1009 982
1010 /* Maybe replace this separator with a bitmap or owner-draw item 983 /* Maybe replace this separator with a bitmap or owner-draw item
1011 so that it looks better. Having two separators looks odd. */ 984 so that it looks better. Having two separators looks odd. */
1012 wv_sep->name = "--";
1013 wv_sep->next = first_wv->contents; 985 wv_sep->next = first_wv->contents;
1014 wv_sep->help = Qnil;
1015 986
1016#ifndef HAVE_MULTILINGUAL_MENU 987#ifndef HAVE_MULTILINGUAL_MENU
1017 if (STRING_MULTIBYTE (title)) 988 if (STRING_MULTIBYTE (title))
1018 title = ENCODE_MENU_STRING (title); 989 title = ENCODE_MENU_STRING (title);
1019#endif 990#endif
1020 991 wv_title = make_widget_value (SSDATA (title), NULL, false, Qnil);
1021 wv_title->name = SSDATA (title);
1022 wv_title->enabled = NO;
1023 wv_title->button_type = BUTTON_TYPE_NONE; 992 wv_title->button_type = BUTTON_TYPE_NONE;
1024 wv_title->help = Qnil;
1025 wv_title->next = wv_sep; 993 wv_title->next = wv_sep;
1026 first_wv->contents = wv_title; 994 first_wv->contents = wv_title;
1027 } 995 }
diff --git a/src/w32gui.h b/src/w32gui.h
index b8c8557357a..d04ce625d1d 100644
--- a/src/w32gui.h
+++ b/src/w32gui.h
@@ -22,14 +22,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22 22
23#include "systime.h" /* for Time */ 23#include "systime.h" /* for Time */
24 24
25/* Local memory management for menus. */ 25/* FIXME: old local memory management for menus. */
26#define local_heap (GetProcessHeap ()) 26#define local_heap (GetProcessHeap ())
27#define local_alloc(n) (HeapAlloc (local_heap, HEAP_ZERO_MEMORY, (n))) 27#define local_alloc(n) (HeapAlloc (local_heap, HEAP_ZERO_MEMORY, (n)))
28#define local_free(p) (HeapFree (local_heap, 0, ((LPVOID) (p)))) 28#define local_free(p) (HeapFree (local_heap, 0, ((LPVOID) (p))))
29 29
30#define malloc_widget_value() ((widget_value *) local_alloc (sizeof (widget_value)))
31#define free_widget_value(wv) (local_free ((wv)))
32
33/* Emulate X GC's by keeping color and font info in a structure. */ 30/* Emulate X GC's by keeping color and font info in a structure. */
34typedef struct _XGCValues 31typedef struct _XGCValues
35{ 32{
diff --git a/src/w32menu.c b/src/w32menu.c
index 2c69fc78053..36b06bafad2 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -376,12 +376,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
376 /* Convert menu_items into widget_value trees 376 /* Convert menu_items into widget_value trees
377 to display the menu. This cannot evaluate Lisp code. */ 377 to display the menu. This cannot evaluate Lisp code. */
378 378
379 wv = xmalloc_widget_value (); 379 wv = make_widget_value ("menubar", NULL, true, Qnil);
380 wv->name = "menubar";
381 wv->value = 0;
382 wv->enabled = 1;
383 wv->button_type = BUTTON_TYPE_NONE; 380 wv->button_type = BUTTON_TYPE_NONE;
384 wv->help = Qnil;
385 first_wv = wv; 381 first_wv = wv;
386 382
387 for (i = 0; i < last_i; i += 4) 383 for (i = 0; i < last_i; i += 4)
@@ -444,12 +440,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
444 /* Make a widget-value tree containing 440 /* Make a widget-value tree containing
445 just the top level menu bar strings. */ 441 just the top level menu bar strings. */
446 442
447 wv = xmalloc_widget_value (); 443 wv = make_widget_value ("menubar", NULL, true, Qnil);
448 wv->name = "menubar";
449 wv->value = 0;
450 wv->enabled = 1;
451 wv->button_type = BUTTON_TYPE_NONE; 444 wv->button_type = BUTTON_TYPE_NONE;
452 wv->help = Qnil;
453 first_wv = wv; 445 first_wv = wv;
454 446
455 items = FRAME_MENU_BAR_ITEMS (f); 447 items = FRAME_MENU_BAR_ITEMS (f);
@@ -461,12 +453,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
461 if (NILP (string)) 453 if (NILP (string))
462 break; 454 break;
463 455
464 wv = xmalloc_widget_value (); 456 wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
465 wv->name = SSDATA (string);
466 wv->value = 0;
467 wv->enabled = 1;
468 wv->button_type = BUTTON_TYPE_NONE; 457 wv->button_type = BUTTON_TYPE_NONE;
469 wv->help = Qnil;
470 /* This prevents lwlib from assuming this 458 /* This prevents lwlib from assuming this
471 menu item is really supposed to be empty. */ 459 menu item is really supposed to be empty. */
472 /* The EMACS_INT cast avoids a warning. 460 /* The EMACS_INT cast avoids a warning.
@@ -600,12 +588,8 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
600 588
601 /* Create a tree of widget_value objects 589 /* Create a tree of widget_value objects
602 representing the panes and their items. */ 590 representing the panes and their items. */
603 wv = xmalloc_widget_value (); 591 wv = make_widget_value ("menu", NULL, true, Qnil);
604 wv->name = "menu";
605 wv->value = 0;
606 wv->enabled = 1;
607 wv->button_type = BUTTON_TYPE_NONE; 592 wv->button_type = BUTTON_TYPE_NONE;
608 wv->help = Qnil;
609 first_wv = wv; 593 first_wv = wv;
610 first_pane = 1; 594 first_pane = 1;
611 595
@@ -665,18 +649,14 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
665 with its items as a submenu beneath it. */ 649 with its items as a submenu beneath it. */
666 if (!keymaps && strcmp (pane_string, "")) 650 if (!keymaps && strcmp (pane_string, ""))
667 { 651 {
668 wv = xmalloc_widget_value (); 652 wv = make_widget_value (pane_string, NULL, true, Qnil);
669 if (save_wv) 653 if (save_wv)
670 save_wv->next = wv; 654 save_wv->next = wv;
671 else 655 else
672 first_wv->contents = wv; 656 first_wv->contents = wv;
673 wv->name = pane_string;
674 if (keymaps && !NILP (prefix)) 657 if (keymaps && !NILP (prefix))
675 wv->name++; 658 wv->name++;
676 wv->value = 0;
677 wv->enabled = 1;
678 wv->button_type = BUTTON_TYPE_NONE; 659 wv->button_type = BUTTON_TYPE_NONE;
679 wv->help = Qnil;
680 save_wv = wv; 660 save_wv = wv;
681 prev_wv = 0; 661 prev_wv = 0;
682 } 662 }
@@ -717,19 +697,17 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
717 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip); 697 ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
718 } 698 }
719 699
720 wv = xmalloc_widget_value (); 700 wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enabled),
701 STRINGP (help) ? help : Qnil);
721 if (prev_wv) 702 if (prev_wv)
722 prev_wv->next = wv; 703 prev_wv->next = wv;
723 else 704 else
724 save_wv->contents = wv; 705 save_wv->contents = wv;
725 wv->name = SSDATA (item_name);
726 if (!NILP (descrip)) 706 if (!NILP (descrip))
727 wv->key = SSDATA (descrip); 707 wv->key = SSDATA (descrip);
728 wv->value = 0;
729 /* Use the contents index as call_data, since we are 708 /* Use the contents index as call_data, since we are
730 restricted to 16-bits. */ 709 restricted to 16-bits. */
731 wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0; 710 wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0;
732 wv->enabled = !NILP (enable);
733 711
734 if (NILP (type)) 712 if (NILP (type))
735 wv->button_type = BUTTON_TYPE_NONE; 713 wv->button_type = BUTTON_TYPE_NONE;
@@ -742,11 +720,6 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
742 720
743 wv->selected = !NILP (selected); 721 wv->selected = !NILP (selected);
744 722
745 if (!STRINGP (help))
746 help = Qnil;
747
748 wv->help = help;
749
750 prev_wv = wv; 723 prev_wv = wv;
751 724
752 i += MENU_ITEMS_ITEM_LENGTH; 725 i += MENU_ITEMS_ITEM_LENGTH;
@@ -756,25 +729,21 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
756 /* Deal with the title, if it is non-nil. */ 729 /* Deal with the title, if it is non-nil. */
757 if (!NILP (title)) 730 if (!NILP (title))
758 { 731 {
759 widget_value *wv_title = xmalloc_widget_value (); 732 widget_value *wv_title;
760 widget_value *wv_sep = xmalloc_widget_value (); 733 widget_value *wv_sep = make_widget_value ("--", NULL, false, Qnil);
761 734
762 /* Maybe replace this separator with a bitmap or owner-draw item 735 /* Maybe replace this separator with a bitmap or owner-draw item
763 so that it looks better. Having two separators looks odd. */ 736 so that it looks better. Having two separators looks odd. */
764 wv_sep->name = "--";
765 wv_sep->next = first_wv->contents; 737 wv_sep->next = first_wv->contents;
766 wv_sep->help = Qnil;
767 738
768 if (unicode_append_menu) 739 if (unicode_append_menu)
769 title = ENCODE_UTF_8 (title); 740 title = ENCODE_UTF_8 (title);
770 else if (STRING_MULTIBYTE (title)) 741 else if (STRING_MULTIBYTE (title))
771 title = ENCODE_SYSTEM (title); 742 title = ENCODE_SYSTEM (title);
772 743
773 wv_title->name = SSDATA (title); 744 wv_title = make_widget_value (SSDATA (title), NULL, true, Qnil);
774 wv_title->enabled = TRUE;
775 wv_title->title = TRUE; 745 wv_title->title = TRUE;
776 wv_title->button_type = BUTTON_TYPE_NONE; 746 wv_title->button_type = BUTTON_TYPE_NONE;
777 wv_title->help = Qnil;
778 wv_title->next = wv_sep; 747 wv_title->next = wv_sep;
779 first_wv->contents = wv_title; 748 first_wv->contents = wv_title;
780 } 749 }
@@ -934,11 +903,7 @@ w32_dialog_show (struct frame *f, Lisp_Object title,
934 pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME); 903 pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME);
935 pane_string = (NILP (pane_name) 904 pane_string = (NILP (pane_name)
936 ? "" : SSDATA (pane_name)); 905 ? "" : SSDATA (pane_name));
937 prev_wv = xmalloc_widget_value (); 906 prev_wv = make_widget_value ("message", pane_string, true, Qnil);
938 prev_wv->value = pane_string;
939 prev_wv->enabled = 1;
940 prev_wv->name = "message";
941 prev_wv->help = Qnil;
942 first_wv = prev_wv; 907 first_wv = prev_wv;
943 908
944 /* Loop over all panes and items, filling in the tree. */ 909 /* Loop over all panes and items, filling in the tree. */
@@ -975,15 +940,13 @@ w32_dialog_show (struct frame *f, Lisp_Object title,
975 return Qnil; 940 return Qnil;
976 } 941 }
977 942
978 wv = xmalloc_widget_value (); 943 wv = make_widget_value (button_names[nb_buttons],
944 SSDATA (item_name),
945 !NILP (enable), Qnil);
979 prev_wv->next = wv; 946 prev_wv->next = wv;
980 wv->name = (char *) button_names[nb_buttons];
981 if (!NILP (descrip)) 947 if (!NILP (descrip))
982 wv->key = SSDATA (descrip); 948 wv->key = SSDATA (descrip);
983 wv->value = SSDATA (item_name);
984 wv->call_data = aref_addr (menu_items, i); 949 wv->call_data = aref_addr (menu_items, i);
985 wv->enabled = !NILP (enable);
986 wv->help = Qnil;
987 prev_wv = wv; 950 prev_wv = wv;
988 951
989 if (! boundary_seen) 952 if (! boundary_seen)
@@ -998,9 +961,7 @@ w32_dialog_show (struct frame *f, Lisp_Object title,
998 if (! boundary_seen) 961 if (! boundary_seen)
999 left_count = nb_buttons - nb_buttons / 2; 962 left_count = nb_buttons - nb_buttons / 2;
1000 963
1001 wv = xmalloc_widget_value (); 964 wv = make_widget_value (dialog_name, NULL, false, Qnil);
1002 wv->name = dialog_name;
1003 wv->help = Qnil;
1004 965
1005 /* Frame title: 'Q' = Question, 'I' = Information. 966 /* Frame title: 'Q' = Question, 'I' = Information.
1006 Can also have 'E' = Error if, one day, we want 967 Can also have 'E' = Error if, one day, we want
diff --git a/src/xmenu.c b/src/xmenu.c
index 683e9c6cd90..c167eaa8159 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -882,12 +882,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
882 /* Convert menu_items into widget_value trees 882 /* Convert menu_items into widget_value trees
883 to display the menu. This cannot evaluate Lisp code. */ 883 to display the menu. This cannot evaluate Lisp code. */
884 884
885 wv = xmalloc_widget_value (); 885 wv = make_widget_value ("menubar", NULL, true, Qnil);
886 wv->name = "menubar";
887 wv->value = 0;
888 wv->enabled = 1;
889 wv->button_type = BUTTON_TYPE_NONE; 886 wv->button_type = BUTTON_TYPE_NONE;
890 wv->help = Qnil;
891 first_wv = wv; 887 first_wv = wv;
892 888
893 for (i = 0; submenu_start[i] >= 0; i++) 889 for (i = 0; submenu_start[i] >= 0; i++)
@@ -952,12 +948,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
952 /* Make a widget-value tree containing 948 /* Make a widget-value tree containing
953 just the top level menu bar strings. */ 949 just the top level menu bar strings. */
954 950
955 wv = xmalloc_widget_value (); 951 wv = make_widget_value ("menubar", NULL, true, Qnil);
956 wv->name = "menubar";
957 wv->value = 0;
958 wv->enabled = 1;
959 wv->button_type = BUTTON_TYPE_NONE; 952 wv->button_type = BUTTON_TYPE_NONE;
960 wv->help = Qnil;
961 first_wv = wv; 953 first_wv = wv;
962 954
963 items = FRAME_MENU_BAR_ITEMS (f); 955 items = FRAME_MENU_BAR_ITEMS (f);
@@ -969,12 +961,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
969 if (NILP (string)) 961 if (NILP (string))
970 break; 962 break;
971 963
972 wv = xmalloc_widget_value (); 964 wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
973 wv->name = SSDATA (string);
974 wv->value = 0;
975 wv->enabled = 1;
976 wv->button_type = BUTTON_TYPE_NONE; 965 wv->button_type = BUTTON_TYPE_NONE;
977 wv->help = Qnil;
978 /* This prevents lwlib from assuming this 966 /* This prevents lwlib from assuming this
979 menu item is really supposed to be empty. */ 967 menu item is really supposed to be empty. */
980 /* The intptr_t cast avoids a warning. 968 /* The intptr_t cast avoids a warning.
@@ -1474,12 +1462,8 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
1474 1462
1475 /* Create a tree of widget_value objects 1463 /* Create a tree of widget_value objects
1476 representing the panes and their items. */ 1464 representing the panes and their items. */
1477 wv = xmalloc_widget_value (); 1465 wv = make_widget_value ("menu", NULL, true, Qnil);
1478 wv->name = "menu";
1479 wv->value = 0;
1480 wv->enabled = 1;
1481 wv->button_type = BUTTON_TYPE_NONE; 1466 wv->button_type = BUTTON_TYPE_NONE;
1482 wv->help =Qnil;
1483 first_wv = wv; 1467 first_wv = wv;
1484 first_pane = 1; 1468 first_pane = 1;
1485 1469
@@ -1537,18 +1521,14 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
1537 with its items as a submenu beneath it. */ 1521 with its items as a submenu beneath it. */
1538 if (!keymaps && strcmp (pane_string, "")) 1522 if (!keymaps && strcmp (pane_string, ""))
1539 { 1523 {
1540 wv = xmalloc_widget_value (); 1524 wv = make_widget_value (pane_string, NULL, true, Qnil);
1541 if (save_wv) 1525 if (save_wv)
1542 save_wv->next = wv; 1526 save_wv->next = wv;
1543 else 1527 else
1544 first_wv->contents = wv; 1528 first_wv->contents = wv;
1545 wv->name = (char *) pane_string;
1546 if (keymaps && !NILP (prefix)) 1529 if (keymaps && !NILP (prefix))
1547 wv->name++; 1530 wv->name++;
1548 wv->value = 0;
1549 wv->enabled = 1;
1550 wv->button_type = BUTTON_TYPE_NONE; 1531 wv->button_type = BUTTON_TYPE_NONE;
1551 wv->help = Qnil;
1552 save_wv = wv; 1532 save_wv = wv;
1553 prev_wv = 0; 1533 prev_wv = 0;
1554 } 1534 }
@@ -1586,20 +1566,18 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
1586 } 1566 }
1587#endif /* not HAVE_MULTILINGUAL_MENU */ 1567#endif /* not HAVE_MULTILINGUAL_MENU */
1588 1568
1589 wv = xmalloc_widget_value (); 1569 wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enable),
1570 STRINGP (help) ? help : Qnil);
1590 if (prev_wv) 1571 if (prev_wv)
1591 prev_wv->next = wv; 1572 prev_wv->next = wv;
1592 else 1573 else
1593 save_wv->contents = wv; 1574 save_wv->contents = wv;
1594 wv->name = SSDATA (item_name);
1595 if (!NILP (descrip)) 1575 if (!NILP (descrip))
1596 wv->key = SSDATA (descrip); 1576 wv->key = SSDATA (descrip);
1597 wv->value = 0;
1598 /* If this item has a null value, 1577 /* If this item has a null value,
1599 make the call_data null so that it won't display a box 1578 make the call_data null so that it won't display a box
1600 when the mouse is on it. */ 1579 when the mouse is on it. */
1601 wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0; 1580 wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
1602 wv->enabled = !NILP (enable);
1603 1581
1604 if (NILP (type)) 1582 if (NILP (type))
1605 wv->button_type = BUTTON_TYPE_NONE; 1583 wv->button_type = BUTTON_TYPE_NONE;
@@ -1612,11 +1590,6 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
1612 1590
1613 wv->selected = !NILP (selected); 1591 wv->selected = !NILP (selected);
1614 1592
1615 if (! STRINGP (help))
1616 help = Qnil;
1617
1618 wv->help = help;
1619
1620 prev_wv = wv; 1593 prev_wv = wv;
1621 1594
1622 i += MENU_ITEMS_ITEM_LENGTH; 1595 i += MENU_ITEMS_ITEM_LENGTH;
@@ -1626,27 +1599,20 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
1626 /* Deal with the title, if it is non-nil. */ 1599 /* Deal with the title, if it is non-nil. */
1627 if (!NILP (title)) 1600 if (!NILP (title))
1628 { 1601 {
1629 widget_value *wv_title = xmalloc_widget_value (); 1602 widget_value *wv_title;
1630 widget_value *wv_sep1 = xmalloc_widget_value (); 1603 widget_value *wv_sep1 = make_widget_value ("--", NULL, false, Qnil);
1631 widget_value *wv_sep2 = xmalloc_widget_value (); 1604 widget_value *wv_sep2 = make_widget_value ("--", NULL, false, Qnil);
1632 1605
1633 wv_sep2->name = "--";
1634 wv_sep2->next = first_wv->contents; 1606 wv_sep2->next = first_wv->contents;
1635 wv_sep2->help = Qnil;
1636
1637 wv_sep1->name = "--";
1638 wv_sep1->next = wv_sep2; 1607 wv_sep1->next = wv_sep2;
1639 wv_sep1->help = Qnil;
1640 1608
1641#ifndef HAVE_MULTILINGUAL_MENU 1609#ifndef HAVE_MULTILINGUAL_MENU
1642 if (STRING_MULTIBYTE (title)) 1610 if (STRING_MULTIBYTE (title))
1643 title = ENCODE_MENU_STRING (title); 1611 title = ENCODE_MENU_STRING (title);
1644#endif 1612#endif
1645 1613
1646 wv_title->name = SSDATA (title); 1614 wv_title = make_widget_value (SSDATA (title), NULL, true, Qnil);
1647 wv_title->enabled = true;
1648 wv_title->button_type = BUTTON_TYPE_NONE; 1615 wv_title->button_type = BUTTON_TYPE_NONE;
1649 wv_title->help = Qnil;
1650 wv_title->next = wv_sep1; 1616 wv_title->next = wv_sep1;
1651 first_wv->contents = wv_title; 1617 first_wv->contents = wv_title;
1652 } 1618 }
@@ -1867,11 +1833,7 @@ x_dialog_show (struct frame *f, Lisp_Object title,
1867 pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME); 1833 pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME);
1868 pane_string = (NILP (pane_name) 1834 pane_string = (NILP (pane_name)
1869 ? "" : SSDATA (pane_name)); 1835 ? "" : SSDATA (pane_name));
1870 prev_wv = xmalloc_widget_value (); 1836 prev_wv = make_widget_value ("message", (char *) pane_string, true, Qnil);
1871 prev_wv->value = (char *) pane_string;
1872 prev_wv->enabled = 1;
1873 prev_wv->name = "message";
1874 prev_wv->help = Qnil;
1875 first_wv = prev_wv; 1837 first_wv = prev_wv;
1876 1838
1877 /* Loop over all panes and items, filling in the tree. */ 1839 /* Loop over all panes and items, filling in the tree. */
@@ -1907,15 +1869,13 @@ x_dialog_show (struct frame *f, Lisp_Object title,
1907 return Qnil; 1869 return Qnil;
1908 } 1870 }
1909 1871
1910 wv = xmalloc_widget_value (); 1872 wv = make_widget_value (button_names[nb_buttons],
1873 SSDATA (item_name),
1874 !NILP (enable), Qnil);
1911 prev_wv->next = wv; 1875 prev_wv->next = wv;
1912 wv->name = (char *) button_names[nb_buttons];
1913 if (!NILP (descrip)) 1876 if (!NILP (descrip))
1914 wv->key = SSDATA (descrip); 1877 wv->key = SSDATA (descrip);
1915 wv->value = SSDATA (item_name);
1916 wv->call_data = aref_addr (menu_items, i); 1878 wv->call_data = aref_addr (menu_items, i);
1917 wv->enabled = !NILP (enable);
1918 wv->help = Qnil;
1919 prev_wv = wv; 1879 prev_wv = wv;
1920 1880
1921 if (! boundary_seen) 1881 if (! boundary_seen)
@@ -1930,9 +1890,7 @@ x_dialog_show (struct frame *f, Lisp_Object title,
1930 if (! boundary_seen) 1890 if (! boundary_seen)
1931 left_count = nb_buttons - nb_buttons / 2; 1891 left_count = nb_buttons - nb_buttons / 2;
1932 1892
1933 wv = xmalloc_widget_value (); 1893 wv = make_widget_value (dialog_name, NULL, false, Qnil);
1934 wv->name = dialog_name;
1935 wv->help = Qnil;
1936 1894
1937 /* Frame title: 'Q' = Question, 'I' = Information. 1895 /* Frame title: 'Q' = Question, 'I' = Information.
1938 Can also have 'E' = Error if, one day, we want 1896 Can also have 'E' = Error if, one day, we want
diff --git a/src/xterm.h b/src/xterm.h
index 8f71cefb02b..bd27c1b201b 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -47,7 +47,6 @@ typedef Widget xt_or_gtk_widget;
47 47
48/* Some definitions to reduce conditionals. */ 48/* Some definitions to reduce conditionals. */
49typedef GtkWidget *xt_or_gtk_widget; 49typedef GtkWidget *xt_or_gtk_widget;
50#define XtParent(x) (gtk_widget_get_parent (x))
51#undef XSync 50#undef XSync
52#define XSync(d, b) do { gdk_window_process_all_updates (); \ 51#define XSync(d, b) do { gdk_window_process_all_updates (); \
53 XSync (d, b); } while (false) 52 XSync (d, b); } while (false)