summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/emacs/ChangeLog5
-rw-r--r--doc/emacs/xresources.texi25
-rw-r--r--etc/NEWS5
-rw-r--r--lwlib/ChangeLog28
-rw-r--r--lwlib/lwlib-Xaw.c19
-rw-r--r--lwlib/xlwmenu.c87
-rw-r--r--lwlib/xlwmenu.h4
-rw-r--r--lwlib/xlwmenuP.h2
-rw-r--r--src/ChangeLog11
-rw-r--r--src/xmenu.c42
-rw-r--r--src/xrdb.c6
11 files changed, 139 insertions, 95 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog
index d04c0322862..ec57887a154 100644
--- a/doc/emacs/ChangeLog
+++ b/doc/emacs/ChangeLog
@@ -1,3 +1,8 @@
+2011-02-14 Jan Djärv <jan.h.d@swipnet.se>
+
+ * xresources.texi (X Resources): Remove *faceName and replace it with
+ *font for Lucid.
+
2011-02-05 Chong Yidong <cyd@stupidchicken.com>
* rmail.texi (Rmail Display): Document Rmail MIME support more
diff --git a/doc/emacs/xresources.texi b/doc/emacs/xresources.texi
index 1482bbd0469..41a09a5f713 100644
--- a/doc/emacs/xresources.texi
+++ b/doc/emacs/xresources.texi
@@ -428,29 +428,20 @@ and has its own resources. The resource specifications start with
@end iftex
@example
-Emacs.pane.menubar.faceName: Courier-12
+Emacs.pane.menubar.font: Courier-12
@end example
@noindent
-To specify a font, use fontconfig font names as values to the @code{faceName}
-resource.
-
-If Emacs is not built with the Xft library, Lucid menus and dialogs
-can only display old style fonts. If Emacs is built with Xft and you
-prefer the old fonts, you have to specify @samp{none} to
-@code{faceName}:
+To specify a font, use fontconfig font names as values to the @code{font}
+resource, or old style names:
@example
-Emacs.pane.menubar.faceName: none
-Emacs.pane.dialog.faceName: none
+Emacs.pane.menubar.font: lucidasanstypewriter-10
@end example
@noindent
-To specify a non-Xft font, use @code{font}. For example:
-
-@example
-Emacs.pane.menubar.font: lucidasanstypewriter-10
-@end example
+Emacs first tries to open the font as an old style font, and if that fails
+as an fontconfig font. In rare cases, Emacs might do the wrong thing.
@noindent
The Lucid menus can display multilingual text in your locale with old style
@@ -480,7 +471,7 @@ Emacs.menu*.font: 8x16
For dialog boxes, use @samp{dialog*}:
@example
-Emacs.dialog*.faceName: Sans-12
+Emacs.dialog*.font: Sans-12
@end example
@noindent
@@ -495,8 +486,6 @@ approach should work on both kinds of systems.
Here is a list of the specific resources for menu bars and pop-up menus:
@table @code
-@item faceName
-Xft font for menu item text.
@item font
Font for menu item text.
@item fontSet
diff --git a/etc/NEWS b/etc/NEWS
index a6461b2c60e..3cc463db4a8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -137,9 +137,8 @@ theme when Emacs is built with GTK.
off by customizing x-gtk-use-system-tooltips.
** Lucid menus and dialogs can display antialiased fonts if Emacs is built
-with Xft. To change font, use X resource faceName, for example:
-Emacs.pane.menubar.faceName: Courier-12
-Set faceName to none and use font to use the old X fonts.
+with Xft. To change font, use the X resource font, for example:
+Emacs.pane.menubar.font: Courier-12
+++
** Enhanced support for characters that have no glyphs in available fonts
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;
diff --git a/src/ChangeLog b/src/ChangeLog
index 7f4e13b733f..54d9a32804d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2011-02-14 Jan Djärv <jan.h.d@swipnet.se>
+
+ * xrdb.c (x_load_resources): For LUCID and XFT, don't put a
+ resource that specifies helvetica for menus and dialogs.
+
+ * 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.
+
2011-02-14 Tom Tromey <tromey@redhat.com>
* keyboard.h: Remove obsolete comment.
diff --git a/src/xmenu.c b/src/xmenu.c
index ad1a764eab8..934db0f0406 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -887,31 +887,26 @@ apply_systemfont_to_dialog (Widget w)
{
XrmDatabase db = XtDatabase (XtDisplay (w));
if (db)
- XrmPutStringResource (&db, "*dialog.faceName", fn);
+ XrmPutStringResource (&db, "*dialog.font", fn);
}
}
static void
-apply_systemfont_to_menu (Widget w)
+apply_systemfont_to_menu (struct frame *f, Widget w)
{
const char *fn = xsettings_get_system_normal_font ();
- int defflt;
- if (!fn) return;
-
- if (XtIsShell (w)) /* popup menu */
+ if (fn)
{
- Widget *childs = NULL;
-
- XtVaGetValues (w, XtNchildren, &childs, NULL);
- if (*childs) w = *childs;
+ XrmDatabase db = XtDatabase (XtDisplay (w));
+ if (db)
+ {
+ XrmPutStringResource (&db, "*menubar*font", fn);
+ XrmPutStringResource (&db, "*popup*font", fn);
+ }
}
-
- /* Only use system font if the default is used for the menu. */
- XtVaGetValues (w, XtNdefaultFace, &defflt, NULL);
- if (defflt)
- XtVaSetValues (w, XtNfaceName, fn, NULL);
}
+
#endif
/* Set the contents of the menubar widgets of frame F.
@@ -1210,7 +1205,11 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
char menuOverride[] = "Ctrl<KeyPress>g: MenuGadgetEscape()";
XtTranslations override = XtParseTranslationTable (menuOverride);
- menubar_widget = lw_create_widget ("menubar", "menubar", id, first_wv,
+#ifdef USE_LUCID
+ apply_systemfont_to_menu (f, f->output_data.x->column_widget);
+#endif
+ menubar_widget = lw_create_widget ("menubar", "menubar", id,
+ first_wv,
f->output_data.x->column_widget,
0,
popup_activate_callback,
@@ -1221,9 +1220,6 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
/* Make menu pop down on C-g. */
XtOverrideTranslations (menubar_widget, override);
-#ifdef USE_LUCID
- apply_systemfont_to_menu (menubar_widget);
-#endif
}
{
@@ -1542,6 +1538,10 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv,
if (! FRAME_X_P (f))
abort ();
+#ifdef USE_LUCID
+ apply_systemfont_to_menu (f, f->output_data.x->widget);
+#endif
+
menu_id = widget_id_tick++;
menu = lw_create_widget ("popup", first_wv->name, menu_id, first_wv,
f->output_data.x->widget, 1, 0,
@@ -1549,10 +1549,6 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv,
popup_deactivate_callback,
menu_highlight_callback);
-#ifdef USE_LUCID
- apply_systemfont_to_menu (menu);
-#endif
-
dummy.type = ButtonPress;
dummy.serial = 0;
dummy.send_event = 0;
diff --git a/src/xrdb.c b/src/xrdb.c
index 90afe32bb66..01714900752 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -546,12 +546,14 @@ x_load_resources (Display *display, const char *xrm_string,
#else /* not USE_MOTIF */
- sprintf (line, "Emacs.dialog*.font: %s", helv);
- XrmPutLineResource (&rdb, line);
sprintf (line, "Emacs.dialog*.background: grey75");
XrmPutLineResource (&rdb, line);
+#if !defined (HAVE_XFT) || !defined (USE_LUCID)
+ sprintf (line, "Emacs.dialog*.font: %s", helv);
+ XrmPutLineResource (&rdb, line);
sprintf (line, "*XlwMenu*font: %s", helv);
XrmPutLineResource (&rdb, line);
+#endif
sprintf (line, "*XlwMenu*background: grey75");
XrmPutLineResource (&rdb, line);
sprintf (line, "Emacs*verticalScrollBar.background: grey75");