diff options
author | Jan Djärv <jan.h.d@swipnet.se> | 2011-02-14 18:21:10 +0100 |
---|---|---|
committer | Jan Djärv <jan.h.d@swipnet.se> | 2011-02-14 18:21:10 +0100 |
commit | 3928f2b67e69cd22995558cc205a2fc6aa33d477 (patch) | |
tree | 1a384801162ad5afaa0e5fa7f4e8f0cb023d8d60 /lwlib | |
parent | 4bb81cc2ba5b44f97b14f7c7ae0dd6b972e71677 (diff) | |
download | emacs-3928f2b67e69cd22995558cc205a2fc6aa33d477.tar.gz |
Use *font for Xft font names for Lucid menus and dialogs.
* doc/emacs/xresources.texi (X Resources): Remove *faceName and replace it with
*font for Lucid.
* lwlib/lwlib-Xaw.c (make_dialog): Use *font even for Xft fonts. Try
XLoadQueryFont first and then Xft fonts.
* lwlib/xlwmenu.c (xlwmenu_default_font): Remove, does not work for
multi-display.
(xlwMenuResources): Remove XtNfaceName and XtNdefaultFace.
Make XtNFont a String resource.
(make_windows_if_needed): Call XFlush so later changes are seen by the
X server.
(remap_menubar): Use XtMoveWidget and then
XtResizeWidget/XtResizeWindow after XtPopup. Works better with
Compiz.
(make_drawing_gcs): Check if mw->menu.font is set.
(getDefaultXftFont): New function.
(openXftFont): faceName is now fontName. Try XLoadQueryFont first
and then XftFontOpenName.
(XlwMenuInitialize): Initialize mw->menu.font with XLoadQueryFont.
(XlwMenuClassInitialize): Remove initialization of
xlwmenu_default_font.
(fontname_changed): Renamed from facename_changed.
(XlwMenuSetValues): Use facename_changed.
* lwlib/xlwmenu.h: Remove Xt[CN]faceName and Xt[NC]defaultFace.
* lwlib/xlwmenuP.h (_XlwMenu_part): Remove faceName. Add fontName.
* src/xmenu.c (apply_systemfont_to_dialog): Apply to *dialog.font.
(apply_systemfont_to_menu): Set resources *menubar*font and
*popup*font. Remove defflt.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu before lw_create_widget.
* src/xrdb.c (x_load_resources): For LUCID and XFT, don't put a
resource that specifies helvetica for menus and dialogs.
Diffstat (limited to 'lwlib')
-rw-r--r-- | lwlib/ChangeLog | 28 | ||||
-rw-r--r-- | lwlib/lwlib-Xaw.c | 19 | ||||
-rw-r--r-- | lwlib/xlwmenu.c | 87 | ||||
-rw-r--r-- | lwlib/xlwmenu.h | 4 | ||||
-rw-r--r-- | lwlib/xlwmenuP.h | 2 |
5 files changed, 91 insertions, 49 deletions
diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog index 997cefc4f95..9a9c1fd3369 100644 --- a/lwlib/ChangeLog +++ b/lwlib/ChangeLog @@ -1,3 +1,31 @@ +2011-02-14 Jan Djärv <jan.h.d@swipnet.se> + + * xlwmenu.h: Remove Xt[CN]faceName and Xt[NC]defaultFace. + + * xlwmenuP.h (_XlwMenu_part): Remove faceName. Add fontName. + + * xlwmenu.c (xlwmenu_default_font): Remove, does not work for + multi-display. + (xlwMenuResources): Remove XtNfaceName and XtNdefaultFace. + Make XtNFont a String resource. + (make_windows_if_needed): Call XFlush so later changes are seen by the + X server. + (remap_menubar): Use XtMoveWidget and then + XtResizeWidget/XtResizeWindow after XtPopup. Works better with + Compiz. + (make_drawing_gcs): Check if mw->menu.font is set. + (getDefaultXftFont): New function. + (openXftFont): faceName is now fontName. Try XLoadQueryFont first + and then XftFontOpenName. + (XlwMenuInitialize): Initialize mw->menu.font with XLoadQueryFont. + (XlwMenuClassInitialize): Remove initialization of + xlwmenu_default_font. + (fontname_changed): Renamed from facename_changed. + (XlwMenuSetValues): Use facename_changed. + + * lwlib-Xaw.c (make_dialog): Use *font even for Xft fonts. Try + XLoadQueryFont first and then Xft fonts. + 2011-02-13 Glenn Morris <rgm@gnu.org> * lwlib-utils.c (index, rindex): Don't undef (neither used in lwlib/, diff --git a/lwlib/lwlib-Xaw.c b/lwlib/lwlib-Xaw.c index 19c2440989d..9c9a007bc15 100644 --- a/lwlib/lwlib-Xaw.c +++ b/lwlib/lwlib-Xaw.c @@ -577,13 +577,20 @@ make_dialog (char* name, if (w) { XtResource rec[] = - { { "faceName", "FaceName", XtRString, sizeof(String), 0, XtRString, - (XtPointer)"Sans-14" }}; - char *faceName; - XtVaGetSubresources (dialog, &faceName, "Dialog", "dialog", + { { "font", "Font", XtRString, sizeof(String), 0, XtRString, + (XtPointer)"Sans-10" }}; + char *fontName = NULL; + XtVaGetSubresources (dialog, &fontName, "Dialog", "dialog", rec, 1, (String)NULL); - if (strcmp ("none", faceName) != 0) - xft_font = openFont (dialog, faceName); + if (fontName) + { + XFontStruct *xfn = XLoadQueryFont (XtDisplay (dialog), fontName); + if (!xfn) + xft_font = openFont (dialog, fontName); + else + XFreeFont (XtDisplay (dialog), xfn); + } + if (xft_font) { instance->nr_xft_data = left_buttons + right_buttons + 1; diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c index 065d81e1fde..5b97f2bf999 100644 --- a/lwlib/xlwmenu.c +++ b/lwlib/xlwmenu.c @@ -71,8 +71,6 @@ extern char *gray_bitmap_bits; static int pointer_grabbed; static XEvent menu_post_event; -static XFontStruct *xlwmenu_default_font; - static char xlwMenuTranslations [] = "<BtnDown>: start()\n\ @@ -131,14 +129,12 @@ xlwMenuResources[] = offset(menu.fontSet), XtRFontSet, NULL}, #endif #ifdef HAVE_XFT -#define DEFAULT_FACENAME "Sans-10" - {XtNfaceName, XtCFaceName, XtRString, sizeof(String), - offset(menu.faceName), XtRString, DEFAULT_FACENAME}, - {XtNdefaultFace, XtCDefaultFace, XtRInt, sizeof(int), - offset(menu.default_face), XtRImmediate, (XtPointer)1}, +#define DEFAULT_FONTNAME "Sans-10" +#else +#define DEFAULT_FONTNAME "XtDefaultFont" #endif - {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), - offset(menu.font), XtRString, "XtDefaultFont"}, + {XtNfont, XtCFont, XtRString, sizeof(String), + offset(menu.fontName), XtRString, DEFAULT_FONTNAME }, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), offset(menu.foreground), XtRString, "XtDefaultForeground"}, {XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel), @@ -1352,6 +1348,7 @@ make_windows_if_needed (XlwMenuWidget mw, int n) #endif set_window_type (windows [i].w, mw); } + XFlush (XtDisplay (mw)); } /* Value is non-zero if WINDOW is part of menu bar widget W. */ @@ -1534,10 +1531,12 @@ remap_menubar (XlwMenuWidget mw) fit_to_screen (mw, ws, previous_ws, mw->menu.horizontal && i == 1); - XtVaSetValues (ws->w, XtNwidth, ws->width, XtNheight, ws->height, - XtNx, ws->x, XtNy, ws->y, NULL); create_pixmap_for_menu (ws, mw); + XtMoveWidget (ws->w, ws->x, ws->y); XtPopup (ws->w, XtGrabNone); + XtResizeWidget (ws->w, ws->width, ws->height, + mw->core.border_width); + XtResizeWindow (ws->w); display_menu (mw, i, False, &selection_position, NULL, NULL); } @@ -1613,14 +1612,17 @@ make_drawing_gcs (XlwMenuWidget mw) XtGCMask mask = GCForeground | GCBackground; #ifdef HAVE_X_I18N - if (!mw->menu.fontSet) + if (!mw->menu.fontSet && mw->menu.font) { xgcv.font = mw->menu.font->fid; mask |= GCFont; } #else - xgcv.font = mw->menu.font->fid; - mask |= GCFont; + if (mw->menu.font) + { + xgcv.font = mw->menu.font->fid; + mask |= GCFont; + } #endif xgcv.foreground = mw->menu.foreground; xgcv.background = mw->core.background_pixel; @@ -1847,13 +1849,20 @@ release_shadow_gcs (XlwMenuWidget mw) } #ifdef HAVE_XFT +static XftFont * +getDefaultXftFont (XlwMenuWidget mw) +{ + int screen = XScreenNumberOfScreen (mw->core.screen); + return XftFontOpenName (XtDisplay (mw), screen, DEFAULT_FONTNAME); +} + static int openXftFont (XlwMenuWidget mw) { - char *fname = mw->menu.faceName; + char *fname = mw->menu.fontName; mw->menu.xft_font = 0; - mw->menu.default_face = fname && strcmp (fname, DEFAULT_FACENAME) == 0; + mw->menu.default_face = fname && strcmp (fname, DEFAULT_FONTNAME) == 0; if (fname && strcmp (fname, "none") != 0) { @@ -1864,20 +1873,23 @@ openXftFont (XlwMenuWidget mw) --i; if (fname[i] == ' ') { - fname = xstrdup (mw->menu.faceName); + fname = xstrdup (mw->menu.fontName); fname[i] = '-'; } - mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname); - if (!mw->menu.xft_font) + mw->menu.font = XLoadQueryFont (XtDisplay (mw), fname); + if (!mw->menu.font) { - fprintf (stderr, "Can't find font '%s'\n", fname); - mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, - DEFAULT_FACENAME); + 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); + } } } - if (fname != mw->menu.faceName) free (fname); + if (fname != mw->menu.fontName) free (fname); return mw->menu.xft_font != 0; } @@ -1913,19 +1925,19 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args) ; else #endif - - if (!mw->menu.font) { - if (!xlwmenu_default_font) - xlwmenu_default_font = XLoadQueryFont (display, "fixed"); - mw->menu.font = xlwmenu_default_font; - if (!mw->menu.font) + mw->menu.font = XLoadQueryFont (display, mw->menu.fontName); + if (!mw->menu.font) { - fprintf (stderr, "Menu font fixed not found, can't continue.\n"); - abort (); + mw->menu.font = XLoadQueryFont (display, "fixed"); + if (!mw->menu.font) + { + fprintf (stderr, "Menu font fixed not found, can't continue.\n"); + abort (); + } } } - + #ifdef HAVE_X_I18N if (mw->menu.fontSet) mw->menu.font_extents = XExtentsOfFontSet (mw->menu.fontSet); @@ -1966,7 +1978,6 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args) static void XlwMenuClassInitialize (void) { - xlwmenu_default_font = 0; } static void @@ -2126,13 +2137,13 @@ XlwMenuDestroy (Widget w) #ifdef HAVE_XFT static int -facename_changed (XlwMenuWidget newmw, +fontname_changed (XlwMenuWidget newmw, XlwMenuWidget oldmw) { - /* This will fore a new XftFont even if the same string is set. + /* This will force a new XftFont even if the same string is set. This is good, as rendering parameters may have changed and we just want to do a redisplay. */ - return newmw->menu.faceName != oldmw->menu.faceName; + return newmw->menu.fontName != oldmw->menu.fontName; } #endif @@ -2158,7 +2169,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new, if (newmw->core.background_pixel != oldmw->core.background_pixel || newmw->menu.foreground != oldmw->menu.foreground #ifdef HAVE_XFT - || facename_changed (newmw, oldmw) + || fontname_changed (newmw, oldmw) #endif #ifdef HAVE_X_I18N || newmw->menu.fontSet != oldmw->menu.fontSet @@ -2193,7 +2204,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new, } #ifdef HAVE_XFT - if (facename_changed (newmw, oldmw)) + if (fontname_changed (newmw, oldmw)) { int i; int screen = XScreenNumberOfScreen (newmw->core.screen); diff --git a/lwlib/xlwmenu.h b/lwlib/xlwmenu.h index 1f0f973d7b9..fad2aafb3d7 100644 --- a/lwlib/xlwmenu.h +++ b/lwlib/xlwmenu.h @@ -58,10 +58,6 @@ Boston, MA 02110-1301, USA. */ #define XtCResizeToPreferred "ResizeToPreferred" #define XtNallowResize "allowResize" #define XtCAllowResize "AllowResize" -#define XtNfaceName "faceName" -#define XtCFaceName "FaceName" -#define XtNdefaultFace "defaultFace" -#define XtCDefaultFace "DefaultFace" /* Motif-compatible resource names */ #define XmNshadowThickness "shadowThickness" diff --git a/lwlib/xlwmenuP.h b/lwlib/xlwmenuP.h index b7ea9de54f7..0aca2f8ea89 100644 --- a/lwlib/xlwmenuP.h +++ b/lwlib/xlwmenuP.h @@ -59,11 +59,11 @@ typedef struct _XlwMenu_part XFontSetExtents *font_extents; #endif #ifdef HAVE_XFT - String faceName; int default_face; XftFont* xft_font; XftColor xft_fg, xft_bg, xft_disabled_fg; #endif + String fontName; XFontStruct* font; Pixel foreground; Pixel disabled_foreground; |