aboutsummaryrefslogtreecommitdiffstats
path: root/lwlib
diff options
context:
space:
mode:
authorJan Djärv2011-02-14 18:21:10 +0100
committerJan Djärv2011-02-14 18:21:10 +0100
commit3928f2b67e69cd22995558cc205a2fc6aa33d477 (patch)
tree1a384801162ad5afaa0e5fa7f4e8f0cb023d8d60 /lwlib
parent4bb81cc2ba5b44f97b14f7c7ae0dd6b972e71677 (diff)
downloademacs-3928f2b67e69cd22995558cc205a2fc6aa33d477.tar.gz
emacs-3928f2b67e69cd22995558cc205a2fc6aa33d477.zip
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/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
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 @@
12011-02-14 Jan Djärv <jan.h.d@swipnet.se>
2
3 * xlwmenu.h: Remove Xt[CN]faceName and Xt[NC]defaultFace.
4
5 * xlwmenuP.h (_XlwMenu_part): Remove faceName. Add fontName.
6
7 * xlwmenu.c (xlwmenu_default_font): Remove, does not work for
8 multi-display.
9 (xlwMenuResources): Remove XtNfaceName and XtNdefaultFace.
10 Make XtNFont a String resource.
11 (make_windows_if_needed): Call XFlush so later changes are seen by the
12 X server.
13 (remap_menubar): Use XtMoveWidget and then
14 XtResizeWidget/XtResizeWindow after XtPopup. Works better with
15 Compiz.
16 (make_drawing_gcs): Check if mw->menu.font is set.
17 (getDefaultXftFont): New function.
18 (openXftFont): faceName is now fontName. Try XLoadQueryFont first
19 and then XftFontOpenName.
20 (XlwMenuInitialize): Initialize mw->menu.font with XLoadQueryFont.
21 (XlwMenuClassInitialize): Remove initialization of
22 xlwmenu_default_font.
23 (fontname_changed): Renamed from facename_changed.
24 (XlwMenuSetValues): Use facename_changed.
25
26 * lwlib-Xaw.c (make_dialog): Use *font even for Xft fonts. Try
27 XLoadQueryFont first and then Xft fonts.
28
12011-02-13 Glenn Morris <rgm@gnu.org> 292011-02-13 Glenn Morris <rgm@gnu.org>
2 30
3 * lwlib-utils.c (index, rindex): Don't undef (neither used in lwlib/, 31 * 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,
577 if (w) 577 if (w)
578 { 578 {
579 XtResource rec[] = 579 XtResource rec[] =
580 { { "faceName", "FaceName", XtRString, sizeof(String), 0, XtRString, 580 { { "font", "Font", XtRString, sizeof(String), 0, XtRString,
581 (XtPointer)"Sans-14" }}; 581 (XtPointer)"Sans-10" }};
582 char *faceName; 582 char *fontName = NULL;
583 XtVaGetSubresources (dialog, &faceName, "Dialog", "dialog", 583 XtVaGetSubresources (dialog, &fontName, "Dialog", "dialog",
584 rec, 1, (String)NULL); 584 rec, 1, (String)NULL);
585 if (strcmp ("none", faceName) != 0) 585 if (fontName)
586 xft_font = openFont (dialog, faceName); 586 {
587 XFontStruct *xfn = XLoadQueryFont (XtDisplay (dialog), fontName);
588 if (!xfn)
589 xft_font = openFont (dialog, fontName);
590 else
591 XFreeFont (XtDisplay (dialog), xfn);
592 }
593
587 if (xft_font) 594 if (xft_font)
588 { 595 {
589 instance->nr_xft_data = left_buttons + right_buttons + 1; 596 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;
71static int pointer_grabbed; 71static int pointer_grabbed;
72static XEvent menu_post_event; 72static XEvent menu_post_event;
73 73
74static XFontStruct *xlwmenu_default_font;
75
76static char 74static char
77xlwMenuTranslations [] = 75xlwMenuTranslations [] =
78"<BtnDown>: start()\n\ 76"<BtnDown>: start()\n\
@@ -131,14 +129,12 @@ xlwMenuResources[] =
131 offset(menu.fontSet), XtRFontSet, NULL}, 129 offset(menu.fontSet), XtRFontSet, NULL},
132#endif 130#endif
133#ifdef HAVE_XFT 131#ifdef HAVE_XFT
134#define DEFAULT_FACENAME "Sans-10" 132#define DEFAULT_FONTNAME "Sans-10"
135 {XtNfaceName, XtCFaceName, XtRString, sizeof(String), 133#else
136 offset(menu.faceName), XtRString, DEFAULT_FACENAME}, 134#define DEFAULT_FONTNAME "XtDefaultFont"
137 {XtNdefaultFace, XtCDefaultFace, XtRInt, sizeof(int),
138 offset(menu.default_face), XtRImmediate, (XtPointer)1},
139#endif 135#endif
140 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), 136 {XtNfont, XtCFont, XtRString, sizeof(String),
141 offset(menu.font), XtRString, "XtDefaultFont"}, 137 offset(menu.fontName), XtRString, DEFAULT_FONTNAME },
142 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), 138 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
143 offset(menu.foreground), XtRString, "XtDefaultForeground"}, 139 offset(menu.foreground), XtRString, "XtDefaultForeground"},
144 {XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel), 140 {XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel),
@@ -1352,6 +1348,7 @@ make_windows_if_needed (XlwMenuWidget mw, int n)
1352#endif 1348#endif
1353 set_window_type (windows [i].w, mw); 1349 set_window_type (windows [i].w, mw);
1354 } 1350 }
1351 XFlush (XtDisplay (mw));
1355} 1352}
1356 1353
1357/* Value is non-zero if WINDOW is part of menu bar widget W. */ 1354/* Value is non-zero if WINDOW is part of menu bar widget W. */
@@ -1534,10 +1531,12 @@ remap_menubar (XlwMenuWidget mw)
1534 1531
1535 fit_to_screen (mw, ws, previous_ws, mw->menu.horizontal && i == 1); 1532 fit_to_screen (mw, ws, previous_ws, mw->menu.horizontal && i == 1);
1536 1533
1537 XtVaSetValues (ws->w, XtNwidth, ws->width, XtNheight, ws->height,
1538 XtNx, ws->x, XtNy, ws->y, NULL);
1539 create_pixmap_for_menu (ws, mw); 1534 create_pixmap_for_menu (ws, mw);
1535 XtMoveWidget (ws->w, ws->x, ws->y);
1540 XtPopup (ws->w, XtGrabNone); 1536 XtPopup (ws->w, XtGrabNone);
1537 XtResizeWidget (ws->w, ws->width, ws->height,
1538 mw->core.border_width);
1539 XtResizeWindow (ws->w);
1541 display_menu (mw, i, False, &selection_position, NULL, NULL); 1540 display_menu (mw, i, False, &selection_position, NULL, NULL);
1542 } 1541 }
1543 1542
@@ -1613,14 +1612,17 @@ make_drawing_gcs (XlwMenuWidget mw)
1613 XtGCMask mask = GCForeground | GCBackground; 1612 XtGCMask mask = GCForeground | GCBackground;
1614 1613
1615#ifdef HAVE_X_I18N 1614#ifdef HAVE_X_I18N
1616 if (!mw->menu.fontSet) 1615 if (!mw->menu.fontSet && mw->menu.font)
1617 { 1616 {
1618 xgcv.font = mw->menu.font->fid; 1617 xgcv.font = mw->menu.font->fid;
1619 mask |= GCFont; 1618 mask |= GCFont;
1620 } 1619 }
1621#else 1620#else
1622 xgcv.font = mw->menu.font->fid; 1621 if (mw->menu.font)
1623 mask |= GCFont; 1622 {
1623 xgcv.font = mw->menu.font->fid;
1624 mask |= GCFont;
1625 }
1624#endif 1626#endif
1625 xgcv.foreground = mw->menu.foreground; 1627 xgcv.foreground = mw->menu.foreground;
1626 xgcv.background = mw->core.background_pixel; 1628 xgcv.background = mw->core.background_pixel;
@@ -1847,13 +1849,20 @@ release_shadow_gcs (XlwMenuWidget mw)
1847} 1849}
1848 1850
1849#ifdef HAVE_XFT 1851#ifdef HAVE_XFT
1852static XftFont *
1853getDefaultXftFont (XlwMenuWidget mw)
1854{
1855 int screen = XScreenNumberOfScreen (mw->core.screen);
1856 return XftFontOpenName (XtDisplay (mw), screen, DEFAULT_FONTNAME);
1857}
1858
1850static int 1859static int
1851openXftFont (XlwMenuWidget mw) 1860openXftFont (XlwMenuWidget mw)
1852{ 1861{
1853 char *fname = mw->menu.faceName; 1862 char *fname = mw->menu.fontName;
1854 1863
1855 mw->menu.xft_font = 0; 1864 mw->menu.xft_font = 0;
1856 mw->menu.default_face = fname && strcmp (fname, DEFAULT_FACENAME) == 0; 1865 mw->menu.default_face = fname && strcmp (fname, DEFAULT_FONTNAME) == 0;
1857 1866
1858 if (fname && strcmp (fname, "none") != 0) 1867 if (fname && strcmp (fname, "none") != 0)
1859 { 1868 {
@@ -1864,20 +1873,23 @@ openXftFont (XlwMenuWidget mw)
1864 --i; 1873 --i;
1865 if (fname[i] == ' ') 1874 if (fname[i] == ' ')
1866 { 1875 {
1867 fname = xstrdup (mw->menu.faceName); 1876 fname = xstrdup (mw->menu.fontName);
1868 fname[i] = '-'; 1877 fname[i] = '-';
1869 } 1878 }
1870 1879
1871 mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname); 1880 mw->menu.font = XLoadQueryFont (XtDisplay (mw), fname);
1872 if (!mw->menu.xft_font) 1881 if (!mw->menu.font)
1873 { 1882 {
1874 fprintf (stderr, "Can't find font '%s'\n", fname); 1883 mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname);
1875 mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, 1884 if (!mw->menu.xft_font)
1876 DEFAULT_FACENAME); 1885 {
1886 fprintf (stderr, "Can't find font '%s'\n", fname);
1887 mw->menu.xft_font = getDefaultXftFont (mw);
1888 }
1877 } 1889 }
1878 } 1890 }
1879 1891
1880 if (fname != mw->menu.faceName) free (fname); 1892 if (fname != mw->menu.fontName) free (fname);
1881 1893
1882 return mw->menu.xft_font != 0; 1894 return mw->menu.xft_font != 0;
1883} 1895}
@@ -1913,19 +1925,19 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
1913 ; 1925 ;
1914 else 1926 else
1915#endif 1927#endif
1916
1917 if (!mw->menu.font)
1918 { 1928 {
1919 if (!xlwmenu_default_font) 1929 mw->menu.font = XLoadQueryFont (display, mw->menu.fontName);
1920 xlwmenu_default_font = XLoadQueryFont (display, "fixed"); 1930 if (!mw->menu.font)
1921 mw->menu.font = xlwmenu_default_font;
1922 if (!mw->menu.font)
1923 { 1931 {
1924 fprintf (stderr, "Menu font fixed not found, can't continue.\n"); 1932 mw->menu.font = XLoadQueryFont (display, "fixed");
1925 abort (); 1933 if (!mw->menu.font)
1934 {
1935 fprintf (stderr, "Menu font fixed not found, can't continue.\n");
1936 abort ();
1937 }
1926 } 1938 }
1927 } 1939 }
1928 1940
1929#ifdef HAVE_X_I18N 1941#ifdef HAVE_X_I18N
1930 if (mw->menu.fontSet) 1942 if (mw->menu.fontSet)
1931 mw->menu.font_extents = XExtentsOfFontSet (mw->menu.fontSet); 1943 mw->menu.font_extents = XExtentsOfFontSet (mw->menu.fontSet);
@@ -1966,7 +1978,6 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
1966static void 1978static void
1967XlwMenuClassInitialize (void) 1979XlwMenuClassInitialize (void)
1968{ 1980{
1969 xlwmenu_default_font = 0;
1970} 1981}
1971 1982
1972static void 1983static void
@@ -2126,13 +2137,13 @@ XlwMenuDestroy (Widget w)
2126 2137
2127#ifdef HAVE_XFT 2138#ifdef HAVE_XFT
2128static int 2139static int
2129facename_changed (XlwMenuWidget newmw, 2140fontname_changed (XlwMenuWidget newmw,
2130 XlwMenuWidget oldmw) 2141 XlwMenuWidget oldmw)
2131{ 2142{
2132 /* This will fore a new XftFont even if the same string is set. 2143 /* This will force a new XftFont even if the same string is set.
2133 This is good, as rendering parameters may have changed and 2144 This is good, as rendering parameters may have changed and
2134 we just want to do a redisplay. */ 2145 we just want to do a redisplay. */
2135 return newmw->menu.faceName != oldmw->menu.faceName; 2146 return newmw->menu.fontName != oldmw->menu.fontName;
2136} 2147}
2137#endif 2148#endif
2138 2149
@@ -2158,7 +2169,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new,
2158 if (newmw->core.background_pixel != oldmw->core.background_pixel 2169 if (newmw->core.background_pixel != oldmw->core.background_pixel
2159 || newmw->menu.foreground != oldmw->menu.foreground 2170 || newmw->menu.foreground != oldmw->menu.foreground
2160#ifdef HAVE_XFT 2171#ifdef HAVE_XFT
2161 || facename_changed (newmw, oldmw) 2172 || fontname_changed (newmw, oldmw)
2162#endif 2173#endif
2163#ifdef HAVE_X_I18N 2174#ifdef HAVE_X_I18N
2164 || newmw->menu.fontSet != oldmw->menu.fontSet 2175 || newmw->menu.fontSet != oldmw->menu.fontSet
@@ -2193,7 +2204,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new,
2193 } 2204 }
2194 2205
2195#ifdef HAVE_XFT 2206#ifdef HAVE_XFT
2196 if (facename_changed (newmw, oldmw)) 2207 if (fontname_changed (newmw, oldmw))
2197 { 2208 {
2198 int i; 2209 int i;
2199 int screen = XScreenNumberOfScreen (newmw->core.screen); 2210 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. */
58#define XtCResizeToPreferred "ResizeToPreferred" 58#define XtCResizeToPreferred "ResizeToPreferred"
59#define XtNallowResize "allowResize" 59#define XtNallowResize "allowResize"
60#define XtCAllowResize "AllowResize" 60#define XtCAllowResize "AllowResize"
61#define XtNfaceName "faceName"
62#define XtCFaceName "FaceName"
63#define XtNdefaultFace "defaultFace"
64#define XtCDefaultFace "DefaultFace"
65 61
66/* Motif-compatible resource names */ 62/* Motif-compatible resource names */
67#define XmNshadowThickness "shadowThickness" 63#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
59 XFontSetExtents *font_extents; 59 XFontSetExtents *font_extents;
60#endif 60#endif
61#ifdef HAVE_XFT 61#ifdef HAVE_XFT
62 String faceName;
63 int default_face; 62 int default_face;
64 XftFont* xft_font; 63 XftFont* xft_font;
65 XftColor xft_fg, xft_bg, xft_disabled_fg; 64 XftColor xft_fg, xft_bg, xft_disabled_fg;
66#endif 65#endif
66 String fontName;
67 XFontStruct* font; 67 XFontStruct* font;
68 Pixel foreground; 68 Pixel foreground;
69 Pixel disabled_foreground; 69 Pixel disabled_foreground;