summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Antipov <dmantipov@yandex.ru>2014-06-02 22:01:21 +0400
committerDmitry Antipov <dmantipov@yandex.ru>2014-06-02 22:01:21 +0400
commit5668fb88bf3731d39c4e958c8e79a549f789ce1e (patch)
treeb0d3fd3555fca3b34c47b803a633da2f36d31165
parentda11196a248b530c3b3a8329497d71332f8c71a3 (diff)
downloademacs-5668fb88bf3731d39c4e958c8e79a549f789ce1e.tar.gz
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.
-rw-r--r--lwlib/ChangeLog9
-rw-r--r--lwlib/lwlib.c50
-rw-r--r--lwlib/lwlib.h7
-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
15 files changed, 96 insertions, 349 deletions
diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog
index 6444498e1a5..294bb10ef0a 100644
--- a/lwlib/ChangeLog
+++ b/lwlib/ChangeLog
@@ -1,3 +1,12 @@
+2014-06-02 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Use common memory management functions for widgets.
+ * lwlib.h (widget_value): Do not maintain a free list any more.
+ (malloc_widget_value, free_widget_value): Remove prototypes.
+ * 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.
+
2014-05-30 Dmitry Antipov <dmantipov@yandex.ru>
Use common string allocation and freeing functions where applicable.
diff --git a/lwlib/lwlib.c b/lwlib/lwlib.c
index eccf58046de..7f2f753c1d4 100644
--- a/lwlib/lwlib.c
+++ b/lwlib/lwlib.c
@@ -99,51 +99,6 @@ static void lw_pop_all_widgets (LWLIB_ID, Boolean);
static Boolean get_one_value (widget_instance *, widget_value *);
static void show_one_widget_busy (Widget, Boolean);
-static widget_value *widget_value_free_list = 0;
-static int malloc_cpt = 0;
-
-widget_value *
-malloc_widget_value (void)
-{
- widget_value *wv;
- if (widget_value_free_list)
- {
- wv = widget_value_free_list;
- widget_value_free_list = wv->free_list;
- wv->free_list = 0;
- }
- else
- {
- wv = (widget_value *) xmalloc (sizeof (widget_value));
- malloc_cpt++;
- }
- memset ((void*) wv, 0, sizeof (widget_value));
- return wv;
-}
-
-/* this is analogous to free(). It frees only what was allocated
- by malloc_widget_value(), and no substructures.
- */
-void
-free_widget_value (widget_value *wv)
-{
- if (wv->free_list)
- abort ();
-
- if (malloc_cpt > 25)
- {
- /* When the number of already allocated cells is too big,
- We free it. */
- xfree (wv);
- malloc_cpt--;
- }
- else
- {
- wv->free_list = widget_value_free_list;
- widget_value_free_list = wv;
- }
-}
-
static void
free_widget_value_tree (widget_value *wv)
{
@@ -172,7 +127,7 @@ free_widget_value_tree (widget_value *wv)
free_widget_value_tree (wv->next);
wv->next = (widget_value *) 0xDEADBEEF;
}
- free_widget_value (wv);
+ xfree (wv);
}
static widget_value *
@@ -185,7 +140,8 @@ copy_widget_value_tree (widget_value *val, change_type change)
if (val == (widget_value *) 1)
return val;
- copy = malloc_widget_value ();
+ copy = xmalloc (sizeof (widget_value));
+ copy->lname = copy->lkey = Qnil;
copy->name = xstrdup (val->name);
copy->value = val->value ? xstrdup (val->value) : NULL;
copy->key = val->key ? xstrdup (val->key) : NULL;
diff --git a/lwlib/lwlib.h b/lwlib/lwlib.h
index 0e646a26b99..563ade8b34d 100644
--- a/lwlib/lwlib.h
+++ b/lwlib/lwlib.h
@@ -119,11 +119,6 @@ typedef struct _widget_value
/* tell us if we should free the toolkit data slot when freeing the
widget_value itself. */
Boolean free_toolkit_data;
-
- /* we resource the widget_value structures; this points to the next
- one on the free list if this one has been deallocated.
- */
- struct _widget_value *free_list;
} widget_value;
@@ -153,8 +148,6 @@ widget_value* lw_get_all_values (LWLIB_ID id);
Boolean lw_get_some_values (LWLIB_ID id, widget_value* val);
void lw_pop_up_all_widgets (LWLIB_ID id);
void lw_pop_down_all_widgets (LWLIB_ID id);
-widget_value *malloc_widget_value (void);
-void free_widget_value (widget_value *);
void lw_popup_menu (Widget, XEvent *);
/* Toolkit independent way of focusing on a Widget at the Xt level. */
diff --git a/src/ChangeLog b/src/ChangeLog
index 1f321a9df4b..f0c0c973be8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,23 @@
2014-06-02 Dmitry Antipov <dmantipov@yandex.ru>
+ Adjust to match recent lwlib changes.
+ * menu.h (xmalloc_widget_value): Replaced by ...
+ (make_widget_value): ... new prototype.
+ * menu.c (xmalloc_widget_value): Replaced by ...
+ (make_widget_value): ... new function.
+ (free_menubar_widget_value_tree, digest_single_submenu): Adjust users.
+ * gtkutil.c (malloc_widget_value, free_widget_value):
+ (widget_value_free_list, malloc_cpt): Remove old lwlib-compatible code.
+ * keyboard.h (enum button_type, struct _widget_value):
+ * gtkutil.h, nsgui.h, w32gui.h (malloc_widget_value, free_widget_value):
+ Likewise.
+ * nsmenu.m (ns_update_menubar, ns_menu_show):
+ * w32menu.c (set_frame_menubar, w32_menu_show, w32_dialog_show):
+ * xmenu.c (set_frame_menubar, xmenu_show, x_dialog_show): Adjust users.
+ * xterm.h (XtParent) [USE_GTK]: Remove unused macro.
+
+2014-06-02 Dmitry Antipov <dmantipov@yandex.ru>
+
* image.c (x_query_frame_background_color)
[HAVE_PNG || HAVE_NS || HAVE_IMAGEMAGICK || HAVE_RSVG]:
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)
/***********************************************************************
Utility functions
***********************************************************************/
-/* The next two variables and functions are taken from lwlib. */
-static widget_value *widget_value_free_list;
-static int malloc_cpt;
-
-/* Allocate a widget_value structure, either by taking one from the
- widget_value_free_list or by malloc:ing a new one.
-
- Return a pointer to the allocated structure. */
-
-widget_value *
-malloc_widget_value (void)
-{
- widget_value *wv;
- if (widget_value_free_list)
- {
- wv = widget_value_free_list;
- widget_value_free_list = wv->free_list;
- wv->free_list = 0;
- }
- else
- {
- wv = xmalloc (sizeof *wv);
- malloc_cpt++;
- }
- memset (wv, 0, sizeof (widget_value));
- return wv;
-}
-
-/* This is analogous to free. It frees only what was allocated
- by malloc_widget_value, and no substructures. */
-
-void
-free_widget_value (widget_value *wv)
-{
- if (wv->free_list)
- emacs_abort ();
-
- if (malloc_cpt > 25)
- {
- /* When the number of already allocated cells is too big,
- We free it. */
- xfree (wv);
- malloc_cpt--;
- }
- else
- {
- wv->free_list = widget_value_free_list;
- widget_value_free_list = wv;
- }
-}
-
/* Create and return the cursor to be used for popup menus and
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/>. */
#ifdef USE_GTK
#include <gtk/gtk.h>
+#include "../lwlib/lwlib.h"
#include "frame.h"
#include "xterm.h"
@@ -74,9 +75,6 @@ typedef struct xg_menu_item_cb_data_
} xg_menu_item_cb_data;
-extern struct _widget_value *malloc_widget_value (void) ATTRIBUTE_MALLOC;
-extern void free_widget_value (struct _widget_value *);
-
extern bool xg_uses_old_file_dialog (void) ATTRIBUTE_CONST;
extern 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);
#define ENCODE_MENU_STRING(str) (str)
#endif
-#if defined (HAVE_NS) || defined (HAVE_NTGUI) || defined (USE_GTK)
-
-/* Definitions copied from lwlib.h */
-
-enum button_type
-{
- BUTTON_TYPE_NONE,
- BUTTON_TYPE_TOGGLE,
- BUTTON_TYPE_RADIO
-};
-
-/* This structure is based on the one in ../lwlib/lwlib.h, with unused portions
- removed. No term uses these. */
-typedef struct _widget_value
-{
- /* name of widget */
- Lisp_Object lname;
- const char* name;
- /* value (meaning depend on widget type) */
- const char* value;
- /* keyboard equivalent. no implications for XtTranslations */
- Lisp_Object lkey;
- const char* key;
- /* Help string or nil if none.
- GC finds this string through the frame's menu_bar_vector
- or through menu_items. */
- Lisp_Object help;
- /* true if enabled */
- unsigned char enabled;
- /* true if selected */
- unsigned char selected;
- /* The type of a button. */
- enum button_type button_type;
-#if defined (HAVE_NTGUI)
- /* true if menu title */
- unsigned char title;
-#endif
- /* Contents of the sub-widgets, also selected slot for checkbox */
- struct _widget_value* contents;
- /* data passed to callback */
- void *call_data;
- /* next one in the list */
- struct _widget_value* next;
-#ifdef USE_GTK
- struct _widget_value *free_list;
-#endif
-} widget_value;
-
-#endif /* HAVE_NS || HAVE_NTGUI */
-
-
/* Macros for dealing with lispy events. */
/* 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,
#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (HAVE_NTGUI)
-/* Allocate a widget_value, blocking input. */
+/* Allocate and basically initialize widget_value, blocking input. */
widget_value *
-xmalloc_widget_value (void)
+make_widget_value (const char *name, char *value,
+ bool enabled, Lisp_Object help)
{
- widget_value *value;
+ widget_value *wv;
block_input ();
- value = malloc_widget_value ();
+ wv = xzalloc (sizeof (widget_value));
unblock_input ();
- return value;
+ wv->name = (char *) name;
+ wv->value = value;
+ wv->enabled = enabled;
+ wv->help = help;
+ return wv;
}
-/* This recursively calls free_widget_value on the tree of widgets.
+/* This recursively calls xfree on the tree of widgets.
It must free all data that was malloc'ed for these widget_values.
In Emacs, many slots are pointers into the data of Lisp_Strings, and
must be left alone. */
@@ -613,7 +618,7 @@ free_menubar_widget_value_tree (widget_value *wv)
wv->next = (widget_value *) 0xDEADBEEF;
}
block_input ();
- free_widget_value (wv);
+ xfree (wv);
unblock_input ();
}
@@ -632,12 +637,8 @@ digest_single_submenu (int start, int end, bool top_level_items)
struct frame *f = XFRAME (Vmenu_updating_frame);
submenu_stack = alloca (menu_items_used * sizeof *submenu_stack);
- wv = xmalloc_widget_value ();
- wv->name = "menu";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menu", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
save_wv = 0;
prev_wv = 0;
@@ -721,17 +722,14 @@ digest_single_submenu (int start, int end, bool top_level_items)
with its items as a submenu beneath it. */
if (strcmp (pane_string, ""))
{
- wv = xmalloc_widget_value ();
+ /* Set value to 1 so update_submenu_strings can handle '@'. */
+ wv = make_widget_value (NULL, (char *) 1, true, Qnil);
if (save_wv)
save_wv->next = wv;
else
first_wv->contents = wv;
wv->lname = pane_name;
- /* Set value to 1 so update_submenu_strings can handle '@' */
- wv->value = (char *)1;
- wv->enabled = 1;
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
save_wv = wv;
}
else
@@ -805,7 +803,8 @@ digest_single_submenu (int start, int end, bool top_level_items)
#endif
}
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (NULL, NULL, !NILP (enable),
+ STRINGP (help) ? help : Qnil);
if (prev_wv)
prev_wv->next = wv;
else
@@ -814,11 +813,9 @@ digest_single_submenu (int start, int end, bool top_level_items)
wv->lname = item_name;
if (!NILP (descrip))
wv->lkey = descrip;
- wv->value = 0;
/* The intptr_t cast avoids a warning. There's no problem
as long as pointers have enough bits to hold small integers. */
wv->call_data = (!NILP (def) ? (void *) (intptr_t) i : 0);
- wv->enabled = !NILP (enable);
if (NILP (type))
wv->button_type = BUTTON_TYPE_NONE;
@@ -830,10 +827,6 @@ digest_single_submenu (int start, int end, bool top_level_items)
emacs_abort ();
wv->selected = !NILP (selected);
- if (! STRINGP (help))
- help = Qnil;
-
- wv->help = help;
prev_wv = wv;
@@ -846,7 +839,7 @@ digest_single_submenu (int start, int end, bool top_level_items)
if (top_level_items && first_wv->contents && first_wv->contents->next == 0)
{
wv = first_wv->contents;
- free_widget_value (first_wv);
+ xfree (first_wv);
return wv;
}
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/>. */
#define MENU_H
#include "systime.h" /* for Time */
+#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \
+ || defined (HAVE_NS)
+#include "../lwlib/lwlib.h" /* for widget_value */
+#endif
#ifdef HAVE_NTGUI
extern Lisp_Object Qunsupported__w32_dialog;
@@ -41,7 +45,7 @@ extern void free_menubar_widget_value_tree (widget_value *);
extern void update_submenu_strings (widget_value *);
extern void find_and_call_menu_selection (struct frame *, int,
Lisp_Object, void *);
-extern widget_value *xmalloc_widget_value (void);
+extern widget_value *make_widget_value (const char *, char *, bool, Lisp_Object);
extern widget_value *digest_single_submenu (int, int, bool);
#endif
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/>. */
#undef _GL_VERIFY_H
#include <verify.h>
-/* menu-related */
-#define free_widget_value(wv) xfree (wv)
-#define malloc_widget_value() ((widget_value *) memset (xmalloc \
- (sizeof (widget_value)), 0, sizeof (widget_value)))
-
/* Emulate XCharStruct. */
typedef struct _XCharStruct
{
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)
/* parse stage 2: insert into lucid 'widget_value' structures
[comments in other terms say not to evaluate lisp code here] */
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
for (i = 0; i < 4*n; i += 4)
@@ -378,12 +374,8 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu)
int n;
Lisp_Object string;
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
/* 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)
memcpy (previous_strings[i/4], SDATA (string),
min (10, SBYTES (string) + 1));
- wv = xmalloc_widget_value ();
- wv->name = SSDATA (string);
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
wv->call_data = (void *) (intptr_t) (-1);
#ifdef NS_IMPL_COCOA
@@ -838,12 +826,8 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
p.x = x; p.y = y;
/* now parse stage 2 as in ns_update_menubar */
- wv = xmalloc_widget_value ();
- wv->name = "contextmenu";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("contextmenu", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
#if 0
@@ -914,18 +898,14 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
with its items as a submenu beneath it. */
if (!keymaps && strcmp (pane_string, ""))
{
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (pane_string, NULL, true, Qnil);
if (save_wv)
save_wv->next = wv;
else
first_wv->contents = wv;
- wv->name = pane_string;
if (keymaps && !NILP (prefix))
wv->name++;
- wv->value = 0;
- wv->enabled = 1;
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
save_wv = wv;
prev_wv = 0;
}
@@ -963,20 +943,18 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
}
#endif /* not HAVE_MULTILINGUAL_MENU */
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enabled),
+ STRINGP (help) ? help : Qnil);
if (prev_wv)
prev_wv->next = wv;
else
save_wv->contents = wv;
- wv->name = SSDATA (item_name);
if (!NILP (descrip))
wv->key = SSDATA (descrip);
- wv->value = 0;
/* If this item has a null value,
make the call_data null so that it won't display a box
when the mouse is on it. */
wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
- wv->enabled = !NILP (enable);
if (NILP (type))
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,
wv->selected = !NILP (selected);
- if (! STRINGP (help))
- help = Qnil;
-
- wv->help = help;
-
prev_wv = wv;
i += MENU_ITEMS_ITEM_LENGTH;
@@ -1004,24 +977,19 @@ ns_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
if (!NILP (title))
{
- widget_value *wv_title = xmalloc_widget_value ();
- widget_value *wv_sep = xmalloc_widget_value ();
+ widget_value *wv_title;
+ widget_value *wv_sep = make_widget_value ("--", NULL, false, Qnil);
/* Maybe replace this separator with a bitmap or owner-draw item
so that it looks better. Having two separators looks odd. */
- wv_sep->name = "--";
wv_sep->next = first_wv->contents;
- wv_sep->help = Qnil;
#ifndef HAVE_MULTILINGUAL_MENU
if (STRING_MULTIBYTE (title))
title = ENCODE_MENU_STRING (title);
#endif
-
- wv_title->name = SSDATA (title);
- wv_title->enabled = NO;
+ wv_title = make_widget_value (SSDATA (title), NULL, false, Qnil);
wv_title->button_type = BUTTON_TYPE_NONE;
- wv_title->help = Qnil;
wv_title->next = wv_sep;
first_wv->contents = wv_title;
}
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/>. */
#include "systime.h" /* for Time */
-/* Local memory management for menus. */
+/* FIXME: old local memory management for menus. */
#define local_heap (GetProcessHeap ())
#define local_alloc(n) (HeapAlloc (local_heap, HEAP_ZERO_MEMORY, (n)))
#define local_free(p) (HeapFree (local_heap, 0, ((LPVOID) (p))))
-#define malloc_widget_value() ((widget_value *) local_alloc (sizeof (widget_value)))
-#define free_widget_value(wv) (local_free ((wv)))
-
/* Emulate X GC's by keeping color and font info in a structure. */
typedef struct _XGCValues
{
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)
/* Convert menu_items into widget_value trees
to display the menu. This cannot evaluate Lisp code. */
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
for (i = 0; i < last_i; i += 4)
@@ -444,12 +440,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
/* Make a widget-value tree containing
just the top level menu bar strings. */
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
items = FRAME_MENU_BAR_ITEMS (f);
@@ -461,12 +453,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
if (NILP (string))
break;
- wv = xmalloc_widget_value ();
- wv->name = SSDATA (string);
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
/* This prevents lwlib from assuming this
menu item is really supposed to be empty. */
/* 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,
/* Create a tree of widget_value objects
representing the panes and their items. */
- wv = xmalloc_widget_value ();
- wv->name = "menu";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menu", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
first_pane = 1;
@@ -665,18 +649,14 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
with its items as a submenu beneath it. */
if (!keymaps && strcmp (pane_string, ""))
{
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (pane_string, NULL, true, Qnil);
if (save_wv)
save_wv->next = wv;
else
first_wv->contents = wv;
- wv->name = pane_string;
if (keymaps && !NILP (prefix))
wv->name++;
- wv->value = 0;
- wv->enabled = 1;
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
save_wv = wv;
prev_wv = 0;
}
@@ -717,19 +697,17 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
}
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enabled),
+ STRINGP (help) ? help : Qnil);
if (prev_wv)
prev_wv->next = wv;
else
save_wv->contents = wv;
- wv->name = SSDATA (item_name);
if (!NILP (descrip))
wv->key = SSDATA (descrip);
- wv->value = 0;
/* Use the contents index as call_data, since we are
restricted to 16-bits. */
wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0;
- wv->enabled = !NILP (enable);
if (NILP (type))
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,
wv->selected = !NILP (selected);
- if (!STRINGP (help))
- help = Qnil;
-
- wv->help = help;
-
prev_wv = wv;
i += MENU_ITEMS_ITEM_LENGTH;
@@ -756,25 +729,21 @@ w32_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
/* Deal with the title, if it is non-nil. */
if (!NILP (title))
{
- widget_value *wv_title = xmalloc_widget_value ();
- widget_value *wv_sep = xmalloc_widget_value ();
+ widget_value *wv_title;
+ widget_value *wv_sep = make_widget_value ("--", NULL, false, Qnil);
/* Maybe replace this separator with a bitmap or owner-draw item
so that it looks better. Having two separators looks odd. */
- wv_sep->name = "--";
wv_sep->next = first_wv->contents;
- wv_sep->help = Qnil;
if (unicode_append_menu)
title = ENCODE_UTF_8 (title);
else if (STRING_MULTIBYTE (title))
title = ENCODE_SYSTEM (title);
- wv_title->name = SSDATA (title);
- wv_title->enabled = TRUE;
+ wv_title = make_widget_value (SSDATA (title), NULL, true, Qnil);
wv_title->title = TRUE;
wv_title->button_type = BUTTON_TYPE_NONE;
- wv_title->help = Qnil;
wv_title->next = wv_sep;
first_wv->contents = wv_title;
}
@@ -934,11 +903,7 @@ w32_dialog_show (struct frame *f, Lisp_Object title,
pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME);
pane_string = (NILP (pane_name)
? "" : SSDATA (pane_name));
- prev_wv = xmalloc_widget_value ();
- prev_wv->value = pane_string;
- prev_wv->enabled = 1;
- prev_wv->name = "message";
- prev_wv->help = Qnil;
+ prev_wv = make_widget_value ("message", pane_string, true, Qnil);
first_wv = prev_wv;
/* Loop over all panes and items, filling in the tree. */
@@ -975,15 +940,13 @@ w32_dialog_show (struct frame *f, Lisp_Object title,
return Qnil;
}
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (button_names[nb_buttons],
+ SSDATA (item_name),
+ !NILP (enable), Qnil);
prev_wv->next = wv;
- wv->name = (char *) button_names[nb_buttons];
if (!NILP (descrip))
wv->key = SSDATA (descrip);
- wv->value = SSDATA (item_name);
wv->call_data = aref_addr (menu_items, i);
- wv->enabled = !NILP (enable);
- wv->help = Qnil;
prev_wv = wv;
if (! boundary_seen)
@@ -998,9 +961,7 @@ w32_dialog_show (struct frame *f, Lisp_Object title,
if (! boundary_seen)
left_count = nb_buttons - nb_buttons / 2;
- wv = xmalloc_widget_value ();
- wv->name = dialog_name;
- wv->help = Qnil;
+ wv = make_widget_value (dialog_name, NULL, false, Qnil);
/* Frame title: 'Q' = Question, 'I' = Information.
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)
/* Convert menu_items into widget_value trees
to display the menu. This cannot evaluate Lisp code. */
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
for (i = 0; submenu_start[i] >= 0; i++)
@@ -952,12 +948,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
/* Make a widget-value tree containing
just the top level menu bar strings. */
- wv = xmalloc_widget_value ();
- wv->name = "menubar";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menubar", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
first_wv = wv;
items = FRAME_MENU_BAR_ITEMS (f);
@@ -969,12 +961,8 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
if (NILP (string))
break;
- wv = xmalloc_widget_value ();
- wv->name = SSDATA (string);
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
/* This prevents lwlib from assuming this
menu item is really supposed to be empty. */
/* 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,
/* Create a tree of widget_value objects
representing the panes and their items. */
- wv = xmalloc_widget_value ();
- wv->name = "menu";
- wv->value = 0;
- wv->enabled = 1;
+ wv = make_widget_value ("menu", NULL, true, Qnil);
wv->button_type = BUTTON_TYPE_NONE;
- wv->help =Qnil;
first_wv = wv;
first_pane = 1;
@@ -1537,18 +1521,14 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
with its items as a submenu beneath it. */
if (!keymaps && strcmp (pane_string, ""))
{
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (pane_string, NULL, true, Qnil);
if (save_wv)
save_wv->next = wv;
else
first_wv->contents = wv;
- wv->name = (char *) pane_string;
if (keymaps && !NILP (prefix))
wv->name++;
- wv->value = 0;
- wv->enabled = 1;
wv->button_type = BUTTON_TYPE_NONE;
- wv->help = Qnil;
save_wv = wv;
prev_wv = 0;
}
@@ -1586,20 +1566,18 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
}
#endif /* not HAVE_MULTILINGUAL_MENU */
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enable),
+ STRINGP (help) ? help : Qnil);
if (prev_wv)
prev_wv->next = wv;
else
save_wv->contents = wv;
- wv->name = SSDATA (item_name);
if (!NILP (descrip))
wv->key = SSDATA (descrip);
- wv->value = 0;
/* If this item has a null value,
make the call_data null so that it won't display a box
when the mouse is on it. */
wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
- wv->enabled = !NILP (enable);
if (NILP (type))
wv->button_type = BUTTON_TYPE_NONE;
@@ -1612,11 +1590,6 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
wv->selected = !NILP (selected);
- if (! STRINGP (help))
- help = Qnil;
-
- wv->help = help;
-
prev_wv = wv;
i += MENU_ITEMS_ITEM_LENGTH;
@@ -1626,27 +1599,20 @@ xmenu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
/* Deal with the title, if it is non-nil. */
if (!NILP (title))
{
- widget_value *wv_title = xmalloc_widget_value ();
- widget_value *wv_sep1 = xmalloc_widget_value ();
- widget_value *wv_sep2 = xmalloc_widget_value ();
+ widget_value *wv_title;
+ widget_value *wv_sep1 = make_widget_value ("--", NULL, false, Qnil);
+ widget_value *wv_sep2 = make_widget_value ("--", NULL, false, Qnil);
- wv_sep2->name = "--";
wv_sep2->next = first_wv->contents;
- wv_sep2->help = Qnil;
-
- wv_sep1->name = "--";
wv_sep1->next = wv_sep2;
- wv_sep1->help = Qnil;
#ifndef HAVE_MULTILINGUAL_MENU
if (STRING_MULTIBYTE (title))
title = ENCODE_MENU_STRING (title);
#endif
- wv_title->name = SSDATA (title);
- wv_title->enabled = true;
+ wv_title = make_widget_value (SSDATA (title), NULL, true, Qnil);
wv_title->button_type = BUTTON_TYPE_NONE;
- wv_title->help = Qnil;
wv_title->next = wv_sep1;
first_wv->contents = wv_title;
}
@@ -1867,11 +1833,7 @@ x_dialog_show (struct frame *f, Lisp_Object title,
pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME);
pane_string = (NILP (pane_name)
? "" : SSDATA (pane_name));
- prev_wv = xmalloc_widget_value ();
- prev_wv->value = (char *) pane_string;
- prev_wv->enabled = 1;
- prev_wv->name = "message";
- prev_wv->help = Qnil;
+ prev_wv = make_widget_value ("message", (char *) pane_string, true, Qnil);
first_wv = prev_wv;
/* Loop over all panes and items, filling in the tree. */
@@ -1907,15 +1869,13 @@ x_dialog_show (struct frame *f, Lisp_Object title,
return Qnil;
}
- wv = xmalloc_widget_value ();
+ wv = make_widget_value (button_names[nb_buttons],
+ SSDATA (item_name),
+ !NILP (enable), Qnil);
prev_wv->next = wv;
- wv->name = (char *) button_names[nb_buttons];
if (!NILP (descrip))
wv->key = SSDATA (descrip);
- wv->value = SSDATA (item_name);
wv->call_data = aref_addr (menu_items, i);
- wv->enabled = !NILP (enable);
- wv->help = Qnil;
prev_wv = wv;
if (! boundary_seen)
@@ -1930,9 +1890,7 @@ x_dialog_show (struct frame *f, Lisp_Object title,
if (! boundary_seen)
left_count = nb_buttons - nb_buttons / 2;
- wv = xmalloc_widget_value ();
- wv->name = dialog_name;
- wv->help = Qnil;
+ wv = make_widget_value (dialog_name, NULL, false, Qnil);
/* Frame title: 'Q' = Question, 'I' = Information.
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;
/* Some definitions to reduce conditionals. */
typedef GtkWidget *xt_or_gtk_widget;
-#define XtParent(x) (gtk_widget_get_parent (x))
#undef XSync
#define XSync(d, b) do { gdk_window_process_all_updates (); \
XSync (d, b); } while (false)