X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/678fb7066698ebfe3aecba722294025ed26da01b..0882152e225d4cb722782545441fd38a22cacef5:/lwlib/xlwmenu.c diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c index 0a328f09f1..6f4db562e0 100644 --- a/lwlib/xlwmenu.c +++ b/lwlib/xlwmenu.c @@ -1,7 +1,7 @@ /* Implements a lightweight menubar widget. Copyright (C) 1992 Lucid, Inc. -Copyright (C) 1994-1995, 1997, 1999-2012 Free Software Foundation, Inc. +Copyright (C) 1994-1995, 1997, 1999-2014 Free Software Foundation, Inc. This file is part of the Lucid Widget Library. @@ -16,21 +16,16 @@ 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; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. */ +along with GNU Emacs. If not, see . */ /* Created by devin@lucid.com */ -#ifdef HAVE_CONFIG_H #include -#endif #include #include #include -#include #include #if (defined __sun) && !(defined SUNOS41) @@ -49,22 +44,12 @@ Boston, MA 02110-1301, USA. */ #ifdef emacs -/* Defined in xfns.c. When config.h defines `static' as empty, we get - redefinition errors when gray_bitmap is included more than once, so - we're referring to the one include in xfns.c here. */ - -extern int gray_bitmap_width; -extern int gray_bitmap_height; -extern char *gray_bitmap_bits; - #include +#include "bitmaps/gray.xbm" #else /* not emacs */ #include -#define gray_bitmap_width gray_width -#define gray_bitmap_height gray_height -#define gray_bitmap_bits gray_bits #endif /* not emacs */ @@ -200,7 +185,6 @@ static void Key(Widget w, XEvent *ev, String *params, Cardinal *num_params); static void Nothing(Widget w, XEvent *ev, String *params, Cardinal *num_params); static int separator_height (enum menu_separator); static void pop_up_menu (XlwMenuWidget, XButtonPressedEvent *); -static void abort_gracefully (Widget w) NO_RETURN; static XtActionsRec xlwMenuActionsList [] = @@ -283,7 +267,7 @@ ungrab_all (Widget w, Time ungrabtime) /* Like abort, but remove grabs from widget W before. */ -static void +static _Noreturn void abort_gracefully (Widget w) { if (XtIsShell (XtParent (w))) @@ -1871,7 +1855,7 @@ openXftFont (XlwMenuWidget mw) int screen = XScreenNumberOfScreen (mw->core.screen); int len = strlen (fname), i = len-1; /* Try to convert Gtk-syntax (Sans 9) to Xft syntax Sans-9. */ - while (i > 0 && isdigit (fname[i])) + while (i > 0 && '0' <= fname[i] && fname[i] <= '9') --i; if (fname[i] == ' ') { @@ -1879,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); @@ -1905,21 +1882,12 @@ 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; mw->menu.gray_pixmap - = XCreatePixmapFromBitmapData (display, window, gray_bitmap_bits, - gray_bitmap_width, gray_bitmap_height, + = XCreatePixmapFromBitmapData (display, window, gray_bits, + gray_width, gray_height, (unsigned long)1, (unsigned long)0, 1); #ifdef HAVE_XFT @@ -2090,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 @@ -2111,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)