summaryrefslogtreecommitdiff
path: root/lwlib
diff options
context:
space:
mode:
Diffstat (limited to 'lwlib')
-rw-r--r--lwlib/ChangeLog84
-rw-r--r--lwlib/Makefile.in51
-rw-r--r--lwlib/autodeps.mk5
-rw-r--r--lwlib/deps.mk43
-rw-r--r--lwlib/lwlib-Xm.c18
-rw-r--r--lwlib/lwlib-int.h2
-rw-r--r--lwlib/lwlib-widget.h103
-rw-r--r--lwlib/lwlib.c86
-rw-r--r--lwlib/lwlib.h64
-rw-r--r--lwlib/xlwmenu.c38
10 files changed, 293 insertions, 201 deletions
diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog
index 9179cd56ccd..6687735003a 100644
--- a/lwlib/ChangeLog
+++ b/lwlib/ChangeLog
@@ -1,6 +1,88 @@
2014-10-20 Glenn Morris <rgm@gnu.org>
- * Version 24.4 released.
+ * Merge in all changes up to 24.4 release.
+
+2014-09-01 Paul Eggert <eggert@cs.ucla.edu>
+
+ --enable-silent-rules now suppresses more chatter.
+ * Makefile.in (AM_DEFAULT_VERBOSITY, AM_V_CC, am__v_CC_)
+ (am__v_CC_0, am__v_CC_1): New macros, taken from Automake.
+ (.c.o): Use them.
+
+2014-07-15 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * lwlib.h (toplevel): Use unsigned int for LWLIB_ID.
+
+2014-06-28 Glenn Morris <rgm@gnu.org>
+
+ * Makefile.in: Use gcc auto-dependency information.
+ Move old dependency information to new file deps.mk.
+ (MKDIR_P, DEPFLAGS, MKDEPDIR, lwlib_deps_frag):
+ New, set by configure.
+ (DEPDIR): New variable.
+ (ALL_CFLAGS): Add DEPFLAGS.
+ (.c.o): Add MKDEPDIR.
+ (clean, mostlyclean): Delete DEPDIR.
+ * deps.mk, autodeps.mk: New files.
+
+2014-06-17 Paul Eggert <eggert@cs.ucla.edu>
+
+ Omit redundant extern decls.
+ From Dmitry Antipov.
+ * lwlib-Xm.c (lw_motif_widget_p, xm_update_one_value)
+ (xm_create_dialog, xm_destroy_instance, xm_popup_menu)
+ (xm_set_keyboard_focus, xm_set_main_areas): Remove decls.
+
+2014-06-15 Glenn Morris <rgm@gnu.org>
+
+ * Makefile.in ($(globals_h)): Use `make -C' rather than `cd && make'.
+
+ * Makefile.in (mostlyclean, clean, distclean, maintainer-clean):
+ Declare as PHONY.
+ (bootstrap-clean): New.
+
+2014-06-13 Glenn Morris <rgm@gnu.org>
+
+ * Makefile.in ($(globals_h)):
+ GNU make automatically passes command-line arguments to sub-makes.
+
+2014-06-04 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * lwlib-widget.h (widget_value) [USE_X_TOOLKIT]: Use X toolkit
+ fields conditionally.
+
+2014-06-03 Paul Eggert <eggert@cs.ucla.edu>
+
+ Do not require libXt-devel when building with gtk.
+ * lwlib-widget.h: New file, with contents taken from lwlib.h.
+ (widget_value) [HAVE_NTGUI]: New member 'title'.
+ * lwlib.h: Include lwlib-widget.h.
+ (change_type, enum button_type, widget_value):
+ Move to lwlib-widget.h.
+
+2014-06-03 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * xlwmenu.c (openXftFont): Do not load regular X font here.
+ (XlwMenuInitialize): Remove ancient #if 0 code.
+ (XlwMenuDestroy): Likewise. Free regular X font here.
+
+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.
+ * lwlib.h (safe_strdup): Remove prototype.
+ * lwlib.c (safe_strdup, safe_free_str): Remove.
+ (copy_widget_value_tree, allocate_widget_info, free_widget_info):
+ (merge_widget_value): Prefer xstrdup, xfree and dupstring.
+ * lwlib-Xm.c (make_destroyed_instance, xm_update_one_value): Ditto.
2013-12-14 Paul Eggert <eggert@cs.ucla.edu>
diff --git a/lwlib/Makefile.in b/lwlib/Makefile.in
index 8bdd2bbbf3d..b01e69c4392 100644
--- a/lwlib/Makefile.in
+++ b/lwlib/Makefile.in
@@ -41,6 +41,7 @@ RANLIB=@RANLIB@
AR = @AR@
ARFLAGS = @ARFLAGS@
+MKDIR_P = @MKDIR_P@
LUCID_OBJS = lwlib-Xlw.o xlwmenu.o lwlib-Xaw.o
MOTIF_OBJS = lwlib-Xm.o
@@ -50,13 +51,27 @@ TOOLKIT_OBJS = $(@X_TOOLKIT_TYPE@_OBJS)
OBJS = lwlib.o $(TOOLKIT_OBJS) lwlib-utils.o
+# 'make' verbosity.
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+
+DEPDIR = deps
+## -MMD -MF $(DEPDIR)/$*.d if AUTO_DEPEND; else empty.
+DEPFLAGS = @DEPFLAGS@
+## ${MKDIR_P} ${DEPDIR} (if AUTO_DEPEND); else ':'.
+MKDEPDIR = @MKDEPDIR@
+
## ../src is where the generated file (config.h, globals.h) are.
## $(srcdir)/../src is where the non-generated files (lisp.h) are.
## (In an out-of-tree build, these two are not the same.)
## $(srcdir) is where the lwlib sources are.
## There are no generated lwlib files, hence no need for -I.
ALL_CFLAGS= $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \
- $(C_SWITCH_MACHINE) \
+ $(C_SWITCH_MACHINE) $(DEPFLAGS) \
$(WARN_CFLAGS) $(WERROR_CFLAGS) $(PROFILING_CFLAGS) $(CFLAGS) \
-Demacs -I../src \
-I$(srcdir) -I$(srcdir)/../src -I../lib -I$(srcdir)/../lib
@@ -65,39 +80,31 @@ all: liblw.a
.PHONY: all
.c.o:
- $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
+ @$(MKDEPDIR)
+ $(AM_V_CC)$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
liblw.a: $(OBJS)
rm -f $@
$(AR) $(ARFLAGS) $@ $(OBJS)
$(RANLIB) $@
-## Generated files in ../src, non-generated in $(srcdir)/../src.
-config_h = ../src/config.h $(srcdir)/../src/conf_post.h
-lisp_h = $(srcdir)/../src/lisp.h
-## lisp.h includes this.
globals_h = ../src/globals.h
-src_h = $(config_h) $(lisp_h) $(globals_h)
-
$(globals_h):
- cd ../src && $(MAKE) $(MFLAGS) globals.h
-
-lwlib-utils.o: $(src_h) lwlib-utils.c lwlib-utils.h lwlib.h
-lwlib.o: $(src_h) lwlib.c lwlib.h lwlib-int.h lwlib-utils.h \
- lwlib-Xlw.h lwlib-Xm.h lwlib-Xaw.h
-lwlib-Xlw.o: $(src_h) lwlib-Xlw.c lwlib.h lwlib-int.h lwlib-Xlw.h xlwmenu.h
-lwlib-Xaw.o: $(src_h) lwlib-Xaw.c lwlib-Xaw.h lwlib.h lwlib-int.h
-lwlib-Xm.o: $(src_h) lwlib-Xm.c lwlib-Xm.h lwlib.h lwlib-int.h lwlib-utils.h
-xlwmenu.o: $(src_h) xlwmenu.c xlwmenu.h lwlib.h xlwmenuP.h \
- $(srcdir)/../src/xterm.h
-
-mostlyclean:
+ $(MAKE) -C ../src globals.h
+
+## Insert either autodeps.mk (if AUTO_DEPEND), else deps.mk.
+@lwlib_deps_frag@
+
+.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean
+
+clean mostlyclean:
rm -f *.o liblw.a \#*
+ -rm -rf ${DEPDIR}
-clean: mostlyclean
distclean: clean
rm -f Makefile
-maintainer-clean: distclean
+
+bootstrap-clean maintainer-clean: distclean
rm -f TAGS
diff --git a/lwlib/autodeps.mk b/lwlib/autodeps.mk
new file mode 100644
index 00000000000..f7109295ce2
--- /dev/null
+++ b/lwlib/autodeps.mk
@@ -0,0 +1,5 @@
+### autodeps.mk --- lwlib/Makefile fragment for GNU Emacs
+
+## This is inserted in lwlib/Makefile if AUTO_DEPEND=yes.
+
+-include $(ALLOBJS:%.o=${DEPDIR}/%.d)
diff --git a/lwlib/deps.mk b/lwlib/deps.mk
new file mode 100644
index 00000000000..6355ec62e62
--- /dev/null
+++ b/lwlib/deps.mk
@@ -0,0 +1,43 @@
+### deps.mk --- lwlib/Makefile fragment for GNU Emacs
+
+# Copyright (C) 1992, 1993 Lucid, Inc.
+# Copyright (C) 1994, 2001-2014 Free Software Foundation, Inc.
+#
+# This file is part of the Lucid Widget Library.
+#
+# The Lucid Widget Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 1, or (at your option)
+# any later version.
+#
+# The Lucid Widget Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+### Commentary:
+
+## This file is inserted in lwlib/Makefile if AUTO_DEPEND=no.
+## It defines static dependencies between the various source files.
+
+### Code:
+
+## Generated files in ../src, non-generated in $(srcdir)/../src.
+config_h = ../src/config.h $(srcdir)/../src/conf_post.h
+lisp_h = $(srcdir)/../src/lisp.h
+## lisp.h includes this.
+src_h = $(config_h) $(lisp_h) $(globals_h)
+
+lwlib-utils.o: $(src_h) lwlib-utils.c lwlib-utils.h lwlib.h
+lwlib.o: $(src_h) lwlib.c lwlib.h lwlib-int.h lwlib-utils.h \
+ lwlib-Xlw.h lwlib-Xm.h lwlib-Xaw.h
+lwlib-Xlw.o: $(src_h) lwlib-Xlw.c lwlib.h lwlib-int.h lwlib-Xlw.h xlwmenu.h
+lwlib-Xaw.o: $(src_h) lwlib-Xaw.c lwlib-Xaw.h lwlib.h lwlib-int.h
+lwlib-Xm.o: $(src_h) lwlib-Xm.c lwlib-Xm.h lwlib.h lwlib-int.h lwlib-utils.h
+xlwmenu.o: $(src_h) xlwmenu.c xlwmenu.h lwlib.h xlwmenuP.h \
+ $(srcdir)/../src/xterm.h
+
+### deps.mk ends here
diff --git a/lwlib/lwlib-Xm.c b/lwlib/lwlib-Xm.c
index bbb9657d7a1..4d48e64cb14 100644
--- a/lwlib/lwlib-Xm.c
+++ b/lwlib/lwlib-Xm.c
@@ -79,7 +79,6 @@ static destroyed_instance *make_destroyed_instance (char *, char *,
Boolean);
static void free_destroyed_instance (destroyed_instance*);
Widget first_child (Widget);
-Boolean lw_motif_widget_p (Widget);
static XmString resource_motif_string (Widget, char *);
static void destroy_all_children (Widget, int);
static void xm_update_label (widget_instance *, Widget, widget_value *);
@@ -99,7 +98,6 @@ static void xm_update_menu (widget_instance *, Widget, widget_value *,
static void xm_update_text (widget_instance *, Widget, widget_value *);
static void xm_update_text_field (widget_instance *, Widget,
widget_value *);
-void xm_update_one_value (widget_instance *, Widget, widget_value *);
static void activate_button (Widget, XtPointer, XtPointer);
static Widget make_dialog (char *, Widget, Boolean, char *, char *,
Boolean, Boolean, Boolean, int, int);
@@ -107,21 +105,16 @@ static destroyed_instance* find_matching_instance (widget_instance*);
static void mark_dead_instance_destroyed (Widget, XtPointer, XtPointer);
static void recenter_widget (Widget);
static Widget recycle_instance (destroyed_instance*);
-Widget xm_create_dialog (widget_instance*);
static Widget make_menubar (widget_instance*);
static void remove_grabs (Widget, XtPointer, XtPointer);
static Widget make_popup_menu (widget_instance*);
static Widget make_main (widget_instance*);
-void xm_destroy_instance (widget_instance*);
-void xm_popup_menu (Widget, XEvent *);
static void set_min_dialog_size (Widget);
static void do_call (Widget, XtPointer, enum do_call_type);
static void xm_generic_callback (Widget, XtPointer, XtPointer);
static void xm_nosel_callback (Widget, XtPointer, XtPointer);
static void xm_pull_down_callback (Widget, XtPointer, XtPointer);
static void xm_pop_down_callback (Widget, XtPointer, XtPointer);
-void xm_set_keyboard_focus (Widget, Widget);
-void xm_set_main_areas (Widget, Widget, Widget);
static void xm_internal_update_other_instances (Widget, XtPointer,
XtPointer);
static void xm_arm_callback (Widget, XtPointer, XtPointer);
@@ -170,8 +163,8 @@ make_destroyed_instance (char* name,
{
destroyed_instance* instance =
(destroyed_instance*) xmalloc (sizeof (destroyed_instance));
- instance->name = safe_strdup (name);
- instance->type = safe_strdup (type);
+ instance->name = xstrdup (name);
+ instance->type = xstrdup (type);
instance->widget = widget;
instance->parent = parent;
instance->pop_up_p = pop_up_p;
@@ -953,10 +946,7 @@ xm_update_one_value (widget_instance* instance,
XtVaGetValues (toggle, XmNset, &set, NULL);
if (set)
- {
- xfree (val->value);
- val->value = safe_strdup (XtName (toggle));
- }
+ dupstring (&val->value, XtName (toggle));
}
val->edited = True;
}
@@ -979,7 +969,7 @@ xm_update_one_value (widget_instance* instance,
if (pos_list [j] == i)
{
cur->selected = True;
- val->value = safe_strdup (cur->name);
+ val->value = xstrdup (cur->name);
}
}
val->edited = 1;
diff --git a/lwlib/lwlib-int.h b/lwlib/lwlib-int.h
index 570dcf5f11b..f2def4cdd0e 100644
--- a/lwlib/lwlib-int.h
+++ b/lwlib/lwlib-int.h
@@ -23,8 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lwlib.h"
-extern char *safe_strdup (const char *);
-
struct widget_xft_data;
typedef struct _widget_instance
diff --git a/lwlib/lwlib-widget.h b/lwlib/lwlib-widget.h
new file mode 100644
index 00000000000..8901964ff55
--- /dev/null
+++ b/lwlib/lwlib-widget.h
@@ -0,0 +1,103 @@
+/*
+Copyright (C) 1992, 1993 Lucid, Inc.
+Copyright (C) 1994, 1999-2014 Free Software Foundation, Inc.
+
+This file is part of the Lucid Widget Library.
+
+The Lucid Widget Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 1, or (at your option)
+any later version.
+
+The Lucid Widget Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This part is separate from lwlib.h because it does not need X,
+ and thus can be used by non-X code in Emacs proper. */
+
+#ifndef LWLIB_WIDGET_H
+#define LWLIB_WIDGET_H
+
+typedef enum
+{
+ NO_CHANGE = 0,
+ INVISIBLE_CHANGE = 1,
+ VISIBLE_CHANGE = 2,
+ STRUCTURAL_CHANGE = 3
+} change_type;
+
+enum button_type
+{
+ BUTTON_TYPE_NONE,
+ BUTTON_TYPE_TOGGLE,
+ BUTTON_TYPE_RADIO
+};
+
+typedef struct _widget_value
+{
+ /* Name of widget. */
+ Lisp_Object lname;
+ char *name;
+
+ /* Value (meaning depend on widget type). */
+ char *value;
+
+ /* Keyboard equivalent. no implications for XtTranslations. */
+ Lisp_Object lkey;
+ 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. */
+ bool enabled;
+
+ /* True if selected. */
+ bool selected;
+
+ /* True if was edited (maintained by get_value). */
+ bool edited;
+
+#ifdef HAVE_NTGUI
+ /* True if menu title. */
+ bool title;
+#endif
+
+ /* The type of a button. */
+ enum button_type button_type;
+
+ /* 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_X_TOOLKIT
+ /* Type of change (maintained by lw library). */
+ change_type change;
+
+ /* Type of this widget's change, but not counting the other widgets
+ found in the `next' field. */
+ change_type this_one_change;
+
+ /* Slot for the toolkit dependent part. Always initialize to NULL. */
+ void *toolkit_data;
+
+ /* Whether we should free the toolkit data slot when freeing the
+ widget_value itself. */
+ bool free_toolkit_data;
+#endif
+
+} widget_value;
+
+#endif
diff --git a/lwlib/lwlib.c b/lwlib/lwlib.c
index f3e80160ebf..7f2f753c1d4 100644
--- a/lwlib/lwlib.c
+++ b/lwlib/lwlib.c
@@ -71,7 +71,6 @@ static widget_value *merge_widget_value (widget_value *,
widget_value *,
int, int *);
static void instantiate_widget_instance (widget_instance *);
-static void safe_free_str (char *);
static void free_widget_value_tree (widget_value *);
static widget_value *copy_widget_value_tree (widget_value *,
change_type);
@@ -99,63 +98,6 @@ static void destroy_one_instance (widget_instance *);
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);
- /* utility functions for widget_instance and widget_info */
-char *
-safe_strdup (const char *s)
-{
- return s ? xstrdup (s) : 0;
-}
-
-static void
-safe_free_str (char *s)
-{
- xfree (s);
-}
-
-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)
@@ -185,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 *
@@ -198,10 +140,11 @@ copy_widget_value_tree (widget_value *val, change_type change)
if (val == (widget_value *) 1)
return val;
- copy = malloc_widget_value ();
- copy->name = safe_strdup (val->name);
- copy->value = safe_strdup (val->value);
- copy->key = safe_strdup (val->key);
+ 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;
copy->help = val->help;
copy->enabled = val->enabled;
copy->button_type = val->button_type;
@@ -228,8 +171,8 @@ allocate_widget_info (const char* type,
lw_callback highlight_cb)
{
widget_info* info = (widget_info*) xmalloc (sizeof (widget_info));
- info->type = safe_strdup (type);
- info->name = safe_strdup (name);
+ info->type = xstrdup (type);
+ info->name = xstrdup (name);
info->id = id;
info->val = copy_widget_value_tree (val, STRUCTURAL_CHANGE);
info->busy = False;
@@ -248,8 +191,8 @@ allocate_widget_info (const char* type,
static void
free_widget_info (widget_info *info)
{
- safe_free_str (info->type);
- safe_free_str (info->name);
+ xfree (info->type);
+ xfree (info->name);
free_widget_value_tree (info->val);
memset ((void*)info, 0xDEADBEEF, sizeof (widget_info));
xfree (info);
@@ -431,24 +374,21 @@ merge_widget_value (widget_value *val1,
EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "name change",
val1->name, val2->name);
change = max (change, STRUCTURAL_CHANGE);
- safe_free_str (val1->name);
- val1->name = safe_strdup (val2->name);
+ dupstring (&val1->name, val2->name);
}
if (safe_strcmp (val1->value, val2->value))
{
EXPLAIN (val1->name, change, VISIBLE_CHANGE, "value change",
val1->value, val2->value);
change = max (change, VISIBLE_CHANGE);
- safe_free_str (val1->value);
- val1->value = safe_strdup (val2->value);
+ dupstring (&val1->value, val2->value);
}
if (safe_strcmp (val1->key, val2->key))
{
EXPLAIN (val1->name, change, VISIBLE_CHANGE, "key change",
val1->key, val2->key);
change = max (change, VISIBLE_CHANGE);
- safe_free_str (val1->key);
- val1->key = safe_strdup (val2->key);
+ dupstring (&val1->key, val2->key);
}
if (! EQ (val1->help, val2->help))
{
diff --git a/lwlib/lwlib.h b/lwlib/lwlib.h
index 0e646a26b99..7d87facb903 100644
--- a/lwlib/lwlib.h
+++ b/lwlib/lwlib.h
@@ -42,22 +42,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
** main: ("name")
*/
-typedef unsigned long LWLIB_ID;
+#include "lwlib-widget.h"
-typedef enum _change_type
-{
- NO_CHANGE = 0,
- INVISIBLE_CHANGE = 1,
- VISIBLE_CHANGE = 2,
- STRUCTURAL_CHANGE = 3
-} change_type;
-
-enum button_type
-{
- BUTTON_TYPE_NONE,
- BUTTON_TYPE_TOGGLE,
- BUTTON_TYPE_RADIO
-};
+typedef unsigned int LWLIB_ID;
/* Menu separator types. */
@@ -81,51 +68,6 @@ enum menu_separator
SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT_DASH
};
-typedef struct _widget_value
-{
- /* name of widget */
- Lisp_Object lname;
- char* name;
- /* value (meaning depend on widget type) */
- char* value;
- /* keyboard equivalent. no implications for XtTranslations */
- Lisp_Object lkey;
- 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 */
- Boolean enabled;
- /* true if selected */
- Boolean selected;
- /* true if was edited (maintained by get_value) */
- Boolean edited;
- /* The type of a button. */
- enum button_type button_type;
- /* true if has changed (maintained by lw library) */
- change_type change;
- /* true if this widget itself has changed,
- but not counting the other widgets found in the `next' field. */
- change_type this_one_change;
- /* Contents of the sub-widgets, also selected slot for checkbox */
- struct _widget_value* contents;
- /* data passed to callback */
- XtPointer call_data;
- /* next one in the list */
- struct _widget_value* next;
- /* slot for the toolkit dependent part. Always initialize to NULL. */
- void* toolkit_data;
- /* 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;
-
typedef void (*lw_callback) (Widget w, LWLIB_ID id, void* data);
@@ -153,8 +95,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/lwlib/xlwmenu.c b/lwlib/xlwmenu.c
index a4a18f0ba45..6f4db562e0b 100644
--- a/lwlib/xlwmenu.c
+++ b/lwlib/xlwmenu.c
@@ -1863,16 +1863,9 @@ openXftFont (XlwMenuWidget mw)
fname[i] = '-';
}
- mw->menu.font = XLoadQueryFont (XtDisplay (mw), fname);
- if (!mw->menu.font)
- {
- mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname);
- if (!mw->menu.xft_font)
- {
- fprintf (stderr, "Can't find font '%s'\n", fname);
- mw->menu.xft_font = getDefaultXftFont (mw);
- }
- }
+ mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname);
+ if (!mw->menu.xft_font)
+ mw->menu.xft_font = getDefaultXftFont (mw);
}
if (fname != mw->menu.fontName) xfree (fname);
@@ -1889,15 +1882,6 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
Window window = RootWindowOfScreen (DefaultScreenOfDisplay (XtDisplay (mw)));
Display* display = XtDisplay (mw);
-#if 0
- widget_value *tem = (widget_value *) XtMalloc (sizeof (widget_value));
-
- /* _XtCreate is freeing the object that was passed to us,
- so make a copy that we will actually keep. */
- memcpy (tem, mw->menu.contents, sizeof (widget_value));
- mw->menu.contents = tem;
-#endif
-
/* mw->menu.cursor = XCreateFontCursor (display, mw->menu.cursor_shape); */
mw->menu.cursor = mw->menu.cursor_shape;
@@ -2074,19 +2058,15 @@ XlwMenuDestroy (Widget w)
XFreePixmap (XtDisplay (mw), mw->menu.gray_pixmap);
mw->menu.gray_pixmap = (Pixmap) -1;
-#if 0
- /* Do free mw->menu.contents because nowadays we copy it
- during initialization. */
- XtFree (mw->menu.contents);
-#endif
-
/* Don't free mw->menu.contents because that comes from our creator.
The `*_stack' elements are just pointers into `contents' so leave
that alone too. But free the stacks themselves. */
if (mw->menu.old_stack) XtFree ((char *) mw->menu.old_stack);
if (mw->menu.new_stack) XtFree ((char *) mw->menu.new_stack);
- /* Remember, you can't free anything that came from the resource
+ /* Original comment was:
+
+ Remember, you can't free anything that came from the resource
database. This includes:
mw->menu.cursor
mw->menu.top_shadow_pixmap
@@ -2095,7 +2075,11 @@ XlwMenuDestroy (Widget w)
Also the color cells of top_shadow_color, bottom_shadow_color,
foreground, and button_foreground will never be freed until this
client exits. Nice, eh?
- */
+
+ But now I can free font without any visible glitches. */
+
+ if (mw->menu.font)
+ XFreeFont (XtDisplay (mw), mw->menu.font);
#ifdef HAVE_XFT
if (mw->menu.windows [0].xft_draw)