aboutsummaryrefslogtreecommitdiffstats
path: root/lwlib
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2019-04-24 12:31:37 +0900
committerYAMAMOTO Mitsuharu2019-04-24 12:31:37 +0900
commit5f4e8e2e088de9fb76cb631077c6eddd3219f594 (patch)
treeabb80bc8ec36c28d4eef08b92db90a142f641be6 /lwlib
parent1828e9a9b7481572448284a8e5925bf97f2145f7 (diff)
downloademacs-5f4e8e2e088de9fb76cb631077c6eddd3219f594.tar.gz
emacs-5f4e8e2e088de9fb76cb631077c6eddd3219f594.zip
Don't link libXft when using cairo
* configure.ac: Check cairo early. Don't try Xft if cairo is used. * lwlib/lwlib-utils.h [USE_CAIRO]: Include cairo.h and fontconfig.h. (XftFont, XftDraw, XftColor, XGlyphInfo) [USE_CAIRO]: New typedefs. (XftFontOpenName, XftFontClose, XftDrawCreate, XftDrawDestroy) (XftDrawRect, XftDrawStringUtf8, XftTextExtentsUtf8) [USE_CAIRO]: New macros. (crxft_font_open_name, crxft_font_close, crxft_draw_create) (crxft_draw_rect, crxft_draw_string, crxft_text_extents) [USE_CAIRO]: New externs. * lwlib/lwlib-utils.c [USE_CAIRO]: Include math.h, cairo-ft.h, and cairo-xlib.h. (crxft_font_open_name, crxft_font_close, crxft_draw_create) (crxft_set_source_color, crxft_draw_rect, crxft_draw_string) (crxft_text_extents) [USE_CAIRO]: New Xft compatibility functions. * lwlib/xlwmenuP.h [USE_CAIRO]: Include lwlib-utils.h. * lwlib/xlwmenu.c (display_menu_item) [USE_CAIRO]: Call cairo_surface_mark_dirty and cairo_surface_flush. * lwlib/lwlib-Xaw.c [USE_CAIRO]: Include stdlib.h and lwlib-utils.h. (draw_text) [USE_CAIRO]: Call cairo_surface_flush. * src/xsettings.c [USE_CAIRO]: Include fontconfig.h (apply_xft_settings) [!HAVE_XFT]: Don't call XftDefaultSubstitute or XftDefaultSet. * lwlib/lwlib-Xaw.c: * lwlib/lwlib-int.h: * lwlib/xlwmenu.c: * lwlib/xlwmenuP.h: * src/xrdb.c: * src/xsettings.c: * src/xterm.c: Replace all #ifdef HAVE_XFT with #if defined USE_CAIRO || defined HAVE_XFT. * src/xfns.c (x_default_font_parameter): Replace #ifdef HAVE_XFT with #if defined USE_CAIRO || defined HAVE_XFT.
Diffstat (limited to 'lwlib')
-rw-r--r--lwlib/lwlib-Xaw.c28
-rw-r--r--lwlib/lwlib-int.h2
-rw-r--r--lwlib/lwlib-utils.c140
-rw-r--r--lwlib/lwlib-utils.h45
-rw-r--r--lwlib/xlwmenu.c43
-rw-r--r--lwlib/xlwmenuP.h10
6 files changed, 236 insertions, 32 deletions
diff --git a/lwlib/lwlib-Xaw.c b/lwlib/lwlib-Xaw.c
index a00f8aa73f9..0801c944008 100644
--- a/lwlib/lwlib-Xaw.c
+++ b/lwlib/lwlib-Xaw.c
@@ -50,8 +50,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
50 50
51#include <X11/Xatom.h> 51#include <X11/Xatom.h>
52 52
53#ifdef HAVE_XFT 53#if defined USE_CAIRO || defined HAVE_XFT
54#ifdef USE_CAIRO
55#include <stdlib.h>
56#include "lwlib-utils.h"
57#else /* HAVE_XFT */
54#include <X11/Xft/Xft.h> 58#include <X11/Xft/Xft.h>
59#endif
55 60
56struct widget_xft_data 61struct widget_xft_data
57{ 62{
@@ -79,7 +84,7 @@ lw_xaw_widget_p (Widget widget)
79} 84}
80 85
81 86
82#ifdef HAVE_XFT 87#if defined USE_CAIRO || defined HAVE_XFT
83static void 88static void
84fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font) 89fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font)
85{ 90{
@@ -210,6 +215,9 @@ draw_text (struct widget_xft_data *data, char *lbl, int inverse)
210 /* 1.2 gives reasonable line spacing. */ 215 /* 1.2 gives reasonable line spacing. */
211 y += data->xft_font->height * 1.2; 216 y += data->xft_font->height * 1.2;
212 } 217 }
218#ifdef USE_CAIRO
219 cairo_surface_flush (cairo_get_target (data->xft_draw));
220#endif
213 221
214} 222}
215 223
@@ -307,7 +315,7 @@ xaw_update_one_widget (widget_instance *instance,
307 if (XtIsSubclass (widget, dialogWidgetClass)) 315 if (XtIsSubclass (widget, dialogWidgetClass))
308 { 316 {
309 317
310#ifdef HAVE_XFT 318#if defined USE_CAIRO || defined HAVE_XFT
311 if (instance->xft_data && instance->xft_data[0].xft_font) 319 if (instance->xft_data && instance->xft_data[0].xft_font)
312 { 320 {
313 set_text (&instance->xft_data[0], instance->parent, 321 set_text (&instance->xft_data[0], instance->parent,
@@ -339,7 +347,7 @@ xaw_update_one_widget (widget_instance *instance,
339 XtSetArg (al[ac], XtNlabel, val->value);ac++; 347 XtSetArg (al[ac], XtNlabel, val->value);ac++;
340 /* Force centered button text. Se above. */ 348 /* Force centered button text. Se above. */
341 XtSetArg (al[ac], XtNjustify, XtJustifyCenter);ac++; 349 XtSetArg (al[ac], XtNjustify, XtJustifyCenter);ac++;
342#ifdef HAVE_XFT 350#if defined USE_CAIRO || defined HAVE_XFT
343 if (instance->xft_data && instance->xft_data[0].xft_font) 351 if (instance->xft_data && instance->xft_data[0].xft_font)
344 { 352 {
345 int th; 353 int th;
@@ -473,7 +481,7 @@ static XtActionsRec xaw_actions [] = {
473}; 481};
474static Boolean actions_initted = False; 482static Boolean actions_initted = False;
475 483
476#ifdef HAVE_XFT 484#if defined USE_CAIRO || defined HAVE_XFT
477static XtActionsRec button_actions[] = 485static XtActionsRec button_actions[] =
478 { 486 {
479 { "my_reset", command_reset }, 487 { "my_reset", command_reset },
@@ -506,7 +514,7 @@ make_dialog (char* name,
506 Widget dialog; 514 Widget dialog;
507 Widget button; 515 Widget button;
508 XtTranslations override; 516 XtTranslations override;
509#ifdef HAVE_XFT 517#if defined USE_CAIRO || defined HAVE_XFT
510 XftFont *xft_font = 0; 518 XftFont *xft_font = 0;
511 XtTranslations button_override; 519 XtTranslations button_override;
512#endif 520#endif
@@ -521,7 +529,7 @@ make_dialog (char* name,
521 XtAppContext app = XtWidgetToApplicationContext (parent); 529 XtAppContext app = XtWidgetToApplicationContext (parent);
522 XtAppAddActions (app, xaw_actions, 530 XtAppAddActions (app, xaw_actions,
523 sizeof (xaw_actions) / sizeof (xaw_actions[0])); 531 sizeof (xaw_actions) / sizeof (xaw_actions[0]));
524#ifdef HAVE_XFT 532#if defined USE_CAIRO || defined HAVE_XFT
525 XtAppAddActions (app, button_actions, 533 XtAppAddActions (app, button_actions,
526 sizeof (button_actions) / sizeof (button_actions[0])); 534 sizeof (button_actions) / sizeof (button_actions[0]));
527#endif 535#endif
@@ -546,7 +554,7 @@ make_dialog (char* name,
546 override = XtParseTranslationTable (dialogOverride); 554 override = XtParseTranslationTable (dialogOverride);
547 XtOverrideTranslations (dialog, override); 555 XtOverrideTranslations (dialog, override);
548 556
549#ifdef HAVE_XFT 557#if defined USE_CAIRO || defined HAVE_XFT
550 { 558 {
551 int num; 559 int num;
552 Widget *ch = NULL; 560 Widget *ch = NULL;
@@ -618,7 +626,7 @@ make_dialog (char* name,
618 sprintf (button_name, "button%d", ++bc); 626 sprintf (button_name, "button%d", ++bc);
619 button = XtCreateManagedWidget (button_name, commandWidgetClass, 627 button = XtCreateManagedWidget (button_name, commandWidgetClass,
620 dialog, av, ac); 628 dialog, av, ac);
621#ifdef HAVE_XFT 629#if defined USE_CAIRO || defined HAVE_XFT
622 if (xft_font) 630 if (xft_font)
623 { 631 {
624 fill_xft_data (&instance->xft_data[bc], button, xft_font); 632 fill_xft_data (&instance->xft_data[bc], button, xft_font);
@@ -651,7 +659,7 @@ make_dialog (char* name,
651 sprintf (button_name, "button%d", ++bc); 659 sprintf (button_name, "button%d", ++bc);
652 button = XtCreateManagedWidget (button_name, commandWidgetClass, 660 button = XtCreateManagedWidget (button_name, commandWidgetClass,
653 dialog, av, ac); 661 dialog, av, ac);
654#ifdef HAVE_XFT 662#if defined USE_CAIRO || defined HAVE_XFT
655 if (xft_font) 663 if (xft_font)
656 { 664 {
657 fill_xft_data (&instance->xft_data[bc], button, xft_font); 665 fill_xft_data (&instance->xft_data[bc], button, xft_font);
diff --git a/lwlib/lwlib-int.h b/lwlib/lwlib-int.h
index 28b1fb9508d..9f788e7c0c2 100644
--- a/lwlib/lwlib-int.h
+++ b/lwlib/lwlib-int.h
@@ -30,7 +30,7 @@ typedef struct _widget_instance
30 Widget widget; 30 Widget widget;
31 Widget parent; 31 Widget parent;
32 Boolean pop_up_p; 32 Boolean pop_up_p;
33#ifdef HAVE_XFT 33#if defined USE_CAIRO || defined HAVE_XFT
34 struct widget_xft_data *xft_data; 34 struct widget_xft_data *xft_data;
35#endif 35#endif
36 struct _widget_info* info; 36 struct _widget_info* info;
diff --git a/lwlib/lwlib-utils.c b/lwlib/lwlib-utils.c
index 7c60bdb056d..2c0a931f9cb 100644
--- a/lwlib/lwlib-utils.c
+++ b/lwlib/lwlib-utils.c
@@ -137,3 +137,143 @@ XtWidgetBeingDestroyedP (Widget widget)
137{ 137{
138 return widget->core.being_destroyed; 138 return widget->core.being_destroyed;
139} 139}
140
141#ifdef USE_CAIRO
142/* Xft emulation on cairo. */
143#include <math.h>
144#include <cairo-ft.h>
145#include <cairo-xlib.h>
146
147XftFont *
148crxft_font_open_name (Display *dpy, int screen, const char *name)
149{
150 XftFont *pub = NULL;
151 FcPattern *pattern = FcNameParse ((FcChar8 *) name);
152 if (pattern)
153 {
154 FcConfigSubstitute (NULL, pattern, FcMatchPattern);
155 double dpi;
156 if (FcPatternGetDouble (pattern, FC_DPI, 0, &dpi) == FcResultNoMatch)
157 {
158 char *v = XGetDefault (dpy, "Xft", FC_DPI);
159 if (v == NULL || sscanf (v, "%lf", &dpi) != 1)
160 dpi = ((DisplayHeight (dpy, screen) * 25.4)
161 / DisplayHeightMM (dpy, screen));
162 FcPatternAddDouble (pattern, FC_DPI, dpi);
163 }
164 FcDefaultSubstitute (pattern);
165 cairo_font_face_t *font_face
166 = cairo_ft_font_face_create_for_pattern (pattern);
167 if (font_face)
168 {
169 double pixel_size;
170 if ((FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &pixel_size)
171 != FcResultMatch)
172 || pixel_size < 1)
173 pixel_size = 10;
174
175 pub = xmalloc (sizeof (*pub));
176 cairo_matrix_t font_matrix, ctm;
177 cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size);
178 cairo_matrix_init_identity (&ctm);
179 cairo_font_options_t *options = cairo_font_options_create ();
180 cairo_ft_font_options_substitute (options, pattern);
181 pub->scaled_font = cairo_scaled_font_create (font_face, &font_matrix,
182 &ctm, options);
183 cairo_font_face_destroy (font_face);
184 cairo_font_options_destroy (options);
185
186 cairo_font_extents_t extents;
187 cairo_scaled_font_extents (pub->scaled_font, &extents);
188 pub->ascent = lround (extents.ascent);
189 pub->descent = lround (extents.descent);
190 pub->height = lround (extents.height);
191 pub->max_advance_width = lround (extents.max_x_advance);
192 }
193 FcPatternDestroy (pattern);
194 }
195 return pub;
196}
197
198void
199crxft_font_close (XftFont *pub)
200{
201 cairo_scaled_font_destroy (pub->scaled_font);
202 xfree (pub);
203}
204
205cairo_t *
206crxft_draw_create (Display *dpy, Drawable drawable, Visual *visual)
207{
208 cairo_t *cr = NULL;
209 Window root;
210 int x, y;
211 unsigned int width, height, border_width, depth;
212
213 if (!XGetGeometry (dpy, drawable, &root, &x, &y, &width, &height,
214 &border_width, &depth))
215 return NULL;
216
217 cairo_surface_t *surface = cairo_xlib_surface_create (dpy, drawable, visual,
218 width, height);
219 if (surface)
220 {
221 cr = cairo_create (surface);
222 cairo_surface_destroy (surface);
223 }
224
225 return cr;
226}
227
228static void
229crxft_set_source_color (cairo_t *cr, const XftColor *color)
230{
231 cairo_set_source_rgba (cr, color->color.red / 65535.0,
232 color->color.green / 65535.0,
233 color->color.blue / 65535.0,
234 color->color.alpha / 65535.0);
235}
236
237void
238crxft_draw_rect (cairo_t *cr, const XftColor *color, int x, int y,
239 unsigned int width, unsigned int height)
240{
241 crxft_set_source_color (cr, color);
242 cairo_rectangle (cr, x, y, width, height);
243 cairo_fill (cr);
244}
245
246void
247crxft_draw_string (cairo_t *cr, const XftColor *color, XftFont *pub,
248 int x, int y, const FcChar8 *string, int len)
249{
250 char *buf = xmalloc (len + 1);
251 memcpy (buf, string, len);
252 buf[len] = '\0';
253 crxft_set_source_color (cr, color);
254 cairo_set_scaled_font (cr, pub->scaled_font);
255 cairo_move_to (cr, x, y);
256 cairo_show_text (cr, buf);
257 xfree (buf);
258}
259
260void
261crxft_text_extents (XftFont *pub, const FcChar8 *string, int len,
262 XGlyphInfo *extents)
263{
264 char *buf = xmalloc (len + 1);
265 memcpy (buf, string, len);
266 buf[len] = '\0';
267 cairo_text_extents_t text_extents;
268 cairo_scaled_font_text_extents (pub->scaled_font, buf, &text_extents);
269 xfree (buf);
270 extents->x = ceil (- text_extents.x_bearing);
271 extents->y = ceil (- text_extents.y_bearing);
272 extents->width = (ceil (text_extents.x_bearing + text_extents.width)
273 + extents->x);
274 extents->height = (ceil (text_extents.y_bearing + text_extents.height)
275 + extents->y);
276 extents->xOff = lround (text_extents.x_advance);
277 extents->yOff = lround (text_extents.y_advance);
278}
279#endif /* USE_CAIRO */
diff --git a/lwlib/lwlib-utils.h b/lwlib/lwlib-utils.h
index ec3daab94ef..64372f19ad2 100644
--- a/lwlib/lwlib-utils.h
+++ b/lwlib/lwlib-utils.h
@@ -15,4 +15,49 @@ Widget *XtCompositeChildren (Widget, unsigned int *);
15Boolean 15Boolean
16XtWidgetBeingDestroyedP (Widget widget); 16XtWidgetBeingDestroyedP (Widget widget);
17 17
18#ifdef USE_CAIRO
19
20#include <cairo.h>
21#include <fontconfig/fontconfig.h>
22
23typedef struct {
24 cairo_scaled_font_t *scaled_font;
25 int ascent, descent, height, max_advance_width;
26} XftFont;
27
28typedef cairo_t XftDraw;
29
30typedef struct {
31 unsigned long pixel;
32 struct {unsigned short red, green, blue, alpha;} color;
33} XftColor;
34
35#ifdef HAVE_XRENDER
36#include <X11/extensions/Xrender.h>
37#else
38typedef struct {
39 unsigned short width, height;
40 short x, y, xOff, yOff;
41} XGlyphInfo;
42#endif
43
44#define XftFontOpenName crxft_font_open_name
45extern XftFont *crxft_font_open_name (Display *, int, const char *);
46#define XftFontClose(dpy, pub) crxft_font_close (pub)
47extern void crxft_font_close (XftFont *);
48#define XftDrawCreate(dpy, drawable, visual, colormap) \
49 crxft_draw_create (dpy, drawable, visual)
50extern cairo_t *crxft_draw_create (Display *, Drawable, Visual *);
51#define XftDrawDestroy cairo_destroy
52#define XftDrawRect crxft_draw_rect
53extern void crxft_draw_rect (cairo_t *, const XftColor *, int, int,
54 unsigned int, unsigned int);
55#define XftDrawStringUtf8 crxft_draw_string
56extern void crxft_draw_string (cairo_t *, const XftColor *, XftFont *,
57 int, int, const FcChar8 *, int);
58#define XftTextExtentsUtf8(dpy, pub, string, len, extents) \
59 crxft_text_extents (pub, string, len, extents)
60extern void crxft_text_extents (XftFont *, const FcChar8 *, int, XGlyphInfo *);
61
62#endif /* USE_CAIRO */
18#endif /* _LWLIB_UTILS_H_ */ 63#endif /* _LWLIB_UTILS_H_ */
diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c
index a5704cbfb53..6292c840f5d 100644
--- a/lwlib/xlwmenu.c
+++ b/lwlib/xlwmenu.c
@@ -107,7 +107,7 @@ xlwMenuResources[] =
107 {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet), 107 {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
108 offset(menu.fontSet), XtRFontSet, NULL}, 108 offset(menu.fontSet), XtRFontSet, NULL},
109#endif 109#endif
110#ifdef HAVE_XFT 110#if defined USE_CAIRO || defined HAVE_XFT
111#define DEFAULT_FONTNAME "Sans-10" 111#define DEFAULT_FONTNAME "Sans-10"
112#else 112#else
113#define DEFAULT_FONTNAME "XtDefaultFont" 113#define DEFAULT_FONTNAME "XtDefaultFont"
@@ -325,7 +325,7 @@ string_width (XlwMenuWidget mw, char *s)
325{ 325{
326 XCharStruct xcs; 326 XCharStruct xcs;
327 int drop; 327 int drop;
328#ifdef HAVE_XFT 328#if defined USE_CAIRO || defined HAVE_XFT
329 if (mw->menu.xft_font) 329 if (mw->menu.xft_font)
330 { 330 {
331 XGlyphInfo gi; 331 XGlyphInfo gi;
@@ -349,7 +349,7 @@ string_width (XlwMenuWidget mw, char *s)
349 349
350} 350}
351 351
352#ifdef HAVE_XFT 352#if defined USE_CAIRO || defined HAVE_XFT
353#define MENU_FONT_HEIGHT(mw) \ 353#define MENU_FONT_HEIGHT(mw) \
354 ((mw)->menu.xft_font != NULL \ 354 ((mw)->menu.xft_font != NULL \
355 ? (mw)->menu.xft_font->height \ 355 ? (mw)->menu.xft_font->height \
@@ -965,7 +965,7 @@ display_menu_item (XlwMenuWidget mw,
965 int width; 965 int width;
966 enum menu_separator separator; 966 enum menu_separator separator;
967 int separator_p = lw_separator_p (val->name, &separator, 0); 967 int separator_p = lw_separator_p (val->name, &separator, 0);
968#ifdef HAVE_XFT 968#if defined USE_CAIRO || defined HAVE_XFT
969 XftColor *xftfg; 969 XftColor *xftfg;
970#endif 970#endif
971 971
@@ -1005,7 +1005,7 @@ display_menu_item (XlwMenuWidget mw,
1005 else 1005 else
1006 text_gc = mw->menu.disabled_gc; 1006 text_gc = mw->menu.disabled_gc;
1007 deco_gc = mw->menu.foreground_gc; 1007 deco_gc = mw->menu.foreground_gc;
1008#ifdef HAVE_XFT 1008#if defined USE_CAIRO || defined HAVE_XFT
1009 xftfg = val->enabled ? &mw->menu.xft_fg : &mw->menu.xft_disabled_fg; 1009 xftfg = val->enabled ? &mw->menu.xft_fg : &mw->menu.xft_disabled_fg;
1010#endif 1010#endif
1011 1011
@@ -1032,10 +1032,13 @@ display_menu_item (XlwMenuWidget mw,
1032 x_offset += ws->button_width; 1032 x_offset += ws->button_width;
1033 1033
1034 1034
1035#ifdef HAVE_XFT 1035#if defined USE_CAIRO || defined HAVE_XFT
1036 if (ws->xft_draw) 1036 if (ws->xft_draw)
1037 { 1037 {
1038 int draw_y = y + v_spacing + shadow; 1038 int draw_y = y + v_spacing + shadow;
1039#ifdef USE_CAIRO
1040 cairo_surface_mark_dirty (cairo_get_target (ws->xft_draw));
1041#endif
1039 XftDrawStringUtf8 (ws->xft_draw, xftfg, 1042 XftDrawStringUtf8 (ws->xft_draw, xftfg,
1040 mw->menu.xft_font, 1043 mw->menu.xft_font,
1041 x_offset, draw_y + font_ascent, 1044 x_offset, draw_y + font_ascent,
@@ -1078,7 +1081,7 @@ display_menu_item (XlwMenuWidget mw,
1078 } 1081 }
1079 else if (val->key) 1082 else if (val->key)
1080 { 1083 {
1081#ifdef HAVE_XFT 1084#if defined USE_CAIRO || defined HAVE_XFT
1082 if (ws->xft_draw) 1085 if (ws->xft_draw)
1083 { 1086 {
1084 int draw_x = ws->width - ws->max_rest_width 1087 int draw_x = ws->width - ws->max_rest_width
@@ -1119,6 +1122,10 @@ display_menu_item (XlwMenuWidget mw,
1119 draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, 1122 draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height,
1120 True, False); 1123 True, False);
1121 } 1124 }
1125#ifdef USE_CAIRO
1126 if (ws->xft_draw)
1127 cairo_surface_flush (cairo_get_target (ws->xft_draw));
1128#endif
1122 1129
1123 if (highlighted_p) 1130 if (highlighted_p)
1124 draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, False, 1131 draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, False,
@@ -1320,7 +1327,7 @@ make_windows_if_needed (XlwMenuWidget mw, int n)
1320 XtAddEventHandler (windows [i].w, ExposureMask, False, expose_cb, mw); 1327 XtAddEventHandler (windows [i].w, ExposureMask, False, expose_cb, mw);
1321 windows [i].window = XtWindow (windows [i].w); 1328 windows [i].window = XtWindow (windows [i].w);
1322 windows [i].pixmap = None; 1329 windows [i].pixmap = None;
1323#ifdef HAVE_XFT 1330#if defined USE_CAIRO || defined HAVE_XFT
1324 windows [i].xft_draw = 0; 1331 windows [i].xft_draw = 0;
1325#endif 1332#endif
1326 set_window_type (windows [i].w, mw); 1333 set_window_type (windows [i].w, mw);
@@ -1411,7 +1418,7 @@ create_pixmap_for_menu (window_state* ws, XlwMenuWidget mw)
1411 ws->pixmap = XCreatePixmap (XtDisplay (ws->w), ws->window, 1418 ws->pixmap = XCreatePixmap (XtDisplay (ws->w), ws->window,
1412 ws->width, ws->height, 1419 ws->width, ws->height,
1413 DefaultDepthOfScreen (XtScreen (ws->w))); 1420 DefaultDepthOfScreen (XtScreen (ws->w)));
1414#ifdef HAVE_XFT 1421#if defined USE_CAIRO || defined HAVE_XFT
1415 if (ws->xft_draw) 1422 if (ws->xft_draw)
1416 XftDrawDestroy (ws->xft_draw); 1423 XftDrawDestroy (ws->xft_draw);
1417 if (mw->menu.xft_font) 1424 if (mw->menu.xft_font)
@@ -1831,7 +1838,7 @@ release_shadow_gcs (XlwMenuWidget mw)
1831 XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc); 1838 XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc);
1832} 1839}
1833 1840
1834#ifdef HAVE_XFT 1841#if defined USE_CAIRO || defined HAVE_XFT
1835static XftFont * 1842static XftFont *
1836getDefaultXftFont (XlwMenuWidget mw) 1843getDefaultXftFont (XlwMenuWidget mw)
1837{ 1844{
@@ -1887,7 +1894,7 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
1887 gray_width, gray_height, 1894 gray_width, gray_height,
1888 (unsigned long)1, (unsigned long)0, 1); 1895 (unsigned long)1, (unsigned long)0, 1);
1889 1896
1890#ifdef HAVE_XFT 1897#if defined USE_CAIRO || defined HAVE_XFT
1891 if (openXftFont (mw)) 1898 if (openXftFont (mw))
1892 ; 1899 ;
1893 else 1900 else
@@ -1933,7 +1940,7 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
1933 mw->menu.windows [0].height = 0; 1940 mw->menu.windows [0].height = 0;
1934 mw->menu.windows [0].max_rest_width = 0; 1941 mw->menu.windows [0].max_rest_width = 0;
1935 mw->menu.windows [0].pixmap = None; 1942 mw->menu.windows [0].pixmap = None;
1936#ifdef HAVE_XFT 1943#if defined USE_CAIRO || defined HAVE_XFT
1937 mw->menu.windows [0].xft_draw = 0; 1944 mw->menu.windows [0].xft_draw = 0;
1938#endif 1945#endif
1939 size_menu (mw, 0); 1946 size_menu (mw, 0);
@@ -1981,7 +1988,7 @@ XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
1981 set_window_type (mw->menu.windows [0].w, mw); 1988 set_window_type (mw->menu.windows [0].w, mw);
1982 create_pixmap_for_menu (&mw->menu.windows [0], mw); 1989 create_pixmap_for_menu (&mw->menu.windows [0], mw);
1983 1990
1984#ifdef HAVE_XFT 1991#if defined USE_CAIRO || defined HAVE_XFT
1985 if (mw->menu.xft_font) 1992 if (mw->menu.xft_font)
1986 { 1993 {
1987 XColor colors[3]; 1994 XColor colors[3];
@@ -2078,7 +2085,7 @@ XlwMenuDestroy (Widget w)
2078 if (mw->menu.font) 2085 if (mw->menu.font)
2079 XFreeFont (XtDisplay (mw), mw->menu.font); 2086 XFreeFont (XtDisplay (mw), mw->menu.font);
2080 2087
2081#ifdef HAVE_XFT 2088#if defined USE_CAIRO || defined HAVE_XFT
2082 if (mw->menu.windows [0].xft_draw) 2089 if (mw->menu.windows [0].xft_draw)
2083 XftDrawDestroy (mw->menu.windows [0].xft_draw); 2090 XftDrawDestroy (mw->menu.windows [0].xft_draw);
2084 if (mw->menu.xft_font) 2091 if (mw->menu.xft_font)
@@ -2092,7 +2099,7 @@ XlwMenuDestroy (Widget w)
2092 { 2099 {
2093 if (mw->menu.windows [i].pixmap != None) 2100 if (mw->menu.windows [i].pixmap != None)
2094 XFreePixmap (XtDisplay (mw), mw->menu.windows [i].pixmap); 2101 XFreePixmap (XtDisplay (mw), mw->menu.windows [i].pixmap);
2095#ifdef HAVE_XFT 2102#if defined USE_CAIRO || defined HAVE_XFT
2096 if (mw->menu.windows [i].xft_draw) 2103 if (mw->menu.windows [i].xft_draw)
2097 XftDrawDestroy (mw->menu.windows [i].xft_draw); 2104 XftDrawDestroy (mw->menu.windows [i].xft_draw);
2098#endif 2105#endif
@@ -2102,7 +2109,7 @@ XlwMenuDestroy (Widget w)
2102 XtFree ((char *) mw->menu.windows); 2109 XtFree ((char *) mw->menu.windows);
2103} 2110}
2104 2111
2105#ifdef HAVE_XFT 2112#if defined USE_CAIRO || defined HAVE_XFT
2106static int 2113static int
2107fontname_changed (XlwMenuWidget newmw, 2114fontname_changed (XlwMenuWidget newmw,
2108 XlwMenuWidget oldmw) 2115 XlwMenuWidget oldmw)
@@ -2134,7 +2141,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new,
2134 2141
2135 if (newmw->core.background_pixel != oldmw->core.background_pixel 2142 if (newmw->core.background_pixel != oldmw->core.background_pixel
2136 || newmw->menu.foreground != oldmw->menu.foreground 2143 || newmw->menu.foreground != oldmw->menu.foreground
2137#ifdef HAVE_XFT 2144#if defined USE_CAIRO || defined HAVE_XFT
2138 || fontname_changed (newmw, oldmw) 2145 || fontname_changed (newmw, oldmw)
2139#endif 2146#endif
2140#ifdef HAVE_X_I18N 2147#ifdef HAVE_X_I18N
@@ -2170,7 +2177,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new,
2170 } 2177 }
2171 } 2178 }
2172 2179
2173#ifdef HAVE_XFT 2180#if defined USE_CAIRO || defined HAVE_XFT
2174 if (fontname_changed (newmw, oldmw)) 2181 if (fontname_changed (newmw, oldmw))
2175 { 2182 {
2176 int i; 2183 int i;
diff --git a/lwlib/xlwmenuP.h b/lwlib/xlwmenuP.h
index 610f83afe45..2a05d993541 100644
--- a/lwlib/xlwmenuP.h
+++ b/lwlib/xlwmenuP.h
@@ -23,9 +23,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
23 23
24#include "xlwmenu.h" 24#include "xlwmenu.h"
25#include <X11/CoreP.h> 25#include <X11/CoreP.h>
26#ifdef HAVE_XFT 26#if defined USE_CAIRO || defined HAVE_XFT
27#ifdef USE_CAIRO
28#include "lwlib-utils.h"
29#else /* HAVE_XFT */
27#include <X11/Xft/Xft.h> 30#include <X11/Xft/Xft.h>
28#endif 31#endif
32#endif
29 33
30/* Elements in the stack arrays. */ 34/* Elements in the stack arrays. */
31typedef struct _window_state 35typedef struct _window_state
@@ -42,7 +46,7 @@ typedef struct _window_state
42 46
43 /* Width of toggle buttons or radio buttons. */ 47 /* Width of toggle buttons or radio buttons. */
44 Dimension button_width; 48 Dimension button_width;
45#ifdef HAVE_XFT 49#if defined USE_CAIRO || defined HAVE_XFT
46 XftDraw* xft_draw; 50 XftDraw* xft_draw;
47#endif 51#endif
48} window_state; 52} window_state;
@@ -56,7 +60,7 @@ typedef struct _XlwMenu_part
56 XFontSet fontSet; 60 XFontSet fontSet;
57 XFontSetExtents *font_extents; 61 XFontSetExtents *font_extents;
58#endif 62#endif
59#ifdef HAVE_XFT 63#if defined USE_CAIRO || defined HAVE_XFT
60 int default_face; 64 int default_face;
61 XftFont* xft_font; 65 XftFont* xft_font;
62 XftColor xft_fg, xft_bg, xft_disabled_fg; 66 XftColor xft_fg, xft_bg, xft_disabled_fg;