diff options
Diffstat (limited to 'lwlib')
-rw-r--r-- | lwlib/Makefile.in | 2 | ||||
-rw-r--r-- | lwlib/lwlib-Xaw.c | 93 | ||||
-rw-r--r-- | lwlib/lwlib-int.h | 3 | ||||
-rw-r--r-- | lwlib/lwlib-utils.c | 140 | ||||
-rw-r--r-- | lwlib/lwlib-utils.h | 45 | ||||
-rw-r--r-- | lwlib/xlwmenu.c | 45 | ||||
-rw-r--r-- | lwlib/xlwmenuP.h | 10 |
7 files changed, 269 insertions, 69 deletions
diff --git a/lwlib/Makefile.in b/lwlib/Makefile.in index a9ff973ad56..e1d92872732 100644 --- a/lwlib/Makefile.in +++ b/lwlib/Makefile.in @@ -111,7 +111,7 @@ $(globals_h): .PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean clean mostlyclean: - rm -f *.o liblw.a \#* $(DEPDIR)/* + rm -f ./*.o liblw.a \#* $(DEPDIR)/* distclean: clean rm -f Makefile diff --git a/lwlib/lwlib-Xaw.c b/lwlib/lwlib-Xaw.c index 24b31fc2956..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/>. */ #include <X11/Xatom.h> -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT +#ifdef USE_CAIRO +#include <stdlib.h> +#include "lwlib-utils.h" +#else /* HAVE_XFT */ #include <X11/Xft/Xft.h> +#endif struct widget_xft_data { @@ -79,7 +84,7 @@ lw_xaw_widget_p (Widget widget) } -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT static void fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font) { @@ -113,6 +118,23 @@ fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font) data->p_width = data->p_height = 0; } +static void +destroy_xft_data (Widget widget, XtPointer closure, XtPointer call_data) +{ + struct widget_xft_data *xft_data = closure; + + for (int i = 0; xft_data[i].widget; ++i) + { + if (xft_data[i].xft_draw) + XftDrawDestroy (xft_data[i].xft_draw); + if (xft_data[i].p != None) + XFreePixmap (XtDisplay (widget), xft_data[i].p); + } + if (xft_data[0].xft_font) + XftFontClose (XtDisplay (widget), xft_data[0].xft_font); + xfree (xft_data); +} + static XftFont* openFont (Widget widget, char *name) { @@ -154,7 +176,7 @@ get_text_width_and_height (Widget widget, char *text, &gi); bp = cp ? cp + 1 : NULL; h += xft_font->height; - if (w < gi.width) w = gi.width; + if (w < gi.xOff) w = gi.xOff; } *height = h; @@ -170,11 +192,12 @@ draw_text (struct widget_xft_data *data, char *lbl, int inverse) int x = inverse ? 0 : 2; char *bp = lbl; - data->xft_draw = XftDrawCreate (XtDisplay (data->widget), - data->p, - DefaultVisual (XtDisplay (data->widget), - screen), - DefaultColormapOfScreen (sc)); + if (!data->xft_draw) + data->xft_draw = XftDrawCreate (XtDisplay (data->widget), + data->p, + DefaultVisual (XtDisplay (data->widget), + screen), + DefaultColormapOfScreen (sc)); XftDrawRect (data->xft_draw, inverse ? &data->xft_fg : &data->xft_bg, 0, 0, data->p_width, data->p_height); @@ -192,6 +215,9 @@ draw_text (struct widget_xft_data *data, char *lbl, int inverse) /* 1.2 gives reasonable line spacing. */ y += data->xft_font->height * 1.2; } +#ifdef USE_CAIRO + cairo_surface_flush (cairo_get_target (data->xft_draw)); +#endif } @@ -229,7 +255,7 @@ find_xft_data (Widget widget) } if (!inst || !inst->xft_data || !inst->xft_data[0].xft_font) return 0; - for (nr = 0; data == NULL && nr < inst->nr_xft_data; ++nr) + for (nr = 0; data == NULL && inst->xft_data[nr].widget; ++nr) { if (inst->xft_data[nr].widget == widget) data = &inst->xft_data[nr]; @@ -289,7 +315,7 @@ xaw_update_one_widget (widget_instance *instance, if (XtIsSubclass (widget, dialogWidgetClass)) { -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (instance->xft_data && instance->xft_data[0].xft_font) { set_text (&instance->xft_data[0], instance->parent, @@ -321,15 +347,15 @@ xaw_update_one_widget (widget_instance *instance, XtSetArg (al[ac], XtNlabel, val->value);ac++; /* Force centered button text. Se above. */ XtSetArg (al[ac], XtNjustify, XtJustifyCenter);ac++; -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (instance->xft_data && instance->xft_data[0].xft_font) { int th; int nr; - for (nr = 0; nr < instance->nr_xft_data; ++nr) + for (nr = 0; instance->xft_data[nr].widget; ++nr) if (instance->xft_data[nr].widget == widget) break; - if (nr < instance->nr_xft_data) + if (instance->xft_data[nr].widget) { set_text (&instance->xft_data[nr], instance->parent, val->value, 6); @@ -360,28 +386,6 @@ xaw_update_one_value (widget_instance *instance, void xaw_destroy_instance (widget_instance *instance) { -#ifdef HAVE_XFT - if (instance->xft_data) - { - int i; - for (i = 0; i < instance->nr_xft_data; ++i) - { - if (instance->xft_data[i].xft_draw) - XftDrawDestroy (instance->xft_data[i].xft_draw); - if (instance->xft_data[i].p != None) - { - XtVaSetValues (instance->xft_data[i].widget, XtNbitmap, None, - NULL); - XFreePixmap (XtDisplay (instance->widget), - instance->xft_data[i].p); - } - } - if (instance->xft_data[0].xft_font) - XftFontClose (XtDisplay (instance->widget), - instance->xft_data[0].xft_font); - xfree (instance->xft_data); - } -#endif if (XtIsSubclass (instance->widget, dialogWidgetClass)) /* Need to destroy the Shell too. */ XtDestroyWidget (XtParent (instance->widget)); @@ -477,7 +481,7 @@ static XtActionsRec xaw_actions [] = { }; static Boolean actions_initted = False; -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT static XtActionsRec button_actions[] = { { "my_reset", command_reset }, @@ -510,7 +514,7 @@ make_dialog (char* name, Widget dialog; Widget button; XtTranslations override; -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT XftFont *xft_font = 0; XtTranslations button_override; #endif @@ -525,7 +529,7 @@ make_dialog (char* name, XtAppContext app = XtWidgetToApplicationContext (parent); XtAppAddActions (app, xaw_actions, sizeof (xaw_actions) / sizeof (xaw_actions[0])); -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT XtAppAddActions (app, button_actions, sizeof (button_actions) / sizeof (button_actions[0])); #endif @@ -550,7 +554,7 @@ make_dialog (char* name, override = XtParseTranslationTable (dialogOverride); XtOverrideTranslations (dialog, override); -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT { int num; Widget *ch = NULL; @@ -568,7 +572,6 @@ make_dialog (char* name, } } instance->xft_data = 0; - instance->nr_xft_data = 0; if (w) { XtResource rec[] = @@ -588,11 +591,13 @@ make_dialog (char* name, if (xft_font) { - instance->nr_xft_data = left_buttons + right_buttons + 1; - instance->xft_data = calloc (instance->nr_xft_data, + int nr_xft_data = left_buttons + right_buttons + 1; + instance->xft_data = calloc (nr_xft_data + 1, sizeof(*instance->xft_data)); fill_xft_data (&instance->xft_data[0], w, xft_font); + XtAddCallback (dialog, XtNdestroyCallback, destroy_xft_data, + instance->xft_data); } } @@ -621,7 +626,7 @@ make_dialog (char* name, sprintf (button_name, "button%d", ++bc); button = XtCreateManagedWidget (button_name, commandWidgetClass, dialog, av, ac); -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (xft_font) { fill_xft_data (&instance->xft_data[bc], button, xft_font); @@ -654,7 +659,7 @@ make_dialog (char* name, sprintf (button_name, "button%d", ++bc); button = XtCreateManagedWidget (button_name, commandWidgetClass, dialog, av, ac); -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (xft_font) { fill_xft_data (&instance->xft_data[bc], button, xft_font); diff --git a/lwlib/lwlib-int.h b/lwlib/lwlib-int.h index e21fa1f1714..9f788e7c0c2 100644 --- a/lwlib/lwlib-int.h +++ b/lwlib/lwlib-int.h @@ -30,9 +30,8 @@ typedef struct _widget_instance Widget widget; Widget parent; Boolean pop_up_p; -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT struct widget_xft_data *xft_data; - int nr_xft_data; #endif struct _widget_info* info; struct _widget_instance* next; 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) { return widget->core.being_destroyed; } + +#ifdef USE_CAIRO +/* Xft emulation on cairo. */ +#include <math.h> +#include <cairo-ft.h> +#include <cairo-xlib.h> + +XftFont * +crxft_font_open_name (Display *dpy, int screen, const char *name) +{ + XftFont *pub = NULL; + FcPattern *pattern = FcNameParse ((FcChar8 *) name); + if (pattern) + { + FcConfigSubstitute (NULL, pattern, FcMatchPattern); + double dpi; + if (FcPatternGetDouble (pattern, FC_DPI, 0, &dpi) == FcResultNoMatch) + { + char *v = XGetDefault (dpy, "Xft", FC_DPI); + if (v == NULL || sscanf (v, "%lf", &dpi) != 1) + dpi = ((DisplayHeight (dpy, screen) * 25.4) + / DisplayHeightMM (dpy, screen)); + FcPatternAddDouble (pattern, FC_DPI, dpi); + } + FcDefaultSubstitute (pattern); + cairo_font_face_t *font_face + = cairo_ft_font_face_create_for_pattern (pattern); + if (font_face) + { + double pixel_size; + if ((FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &pixel_size) + != FcResultMatch) + || pixel_size < 1) + pixel_size = 10; + + pub = xmalloc (sizeof (*pub)); + cairo_matrix_t font_matrix, ctm; + cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size); + cairo_matrix_init_identity (&ctm); + cairo_font_options_t *options = cairo_font_options_create (); + cairo_ft_font_options_substitute (options, pattern); + pub->scaled_font = cairo_scaled_font_create (font_face, &font_matrix, + &ctm, options); + cairo_font_face_destroy (font_face); + cairo_font_options_destroy (options); + + cairo_font_extents_t extents; + cairo_scaled_font_extents (pub->scaled_font, &extents); + pub->ascent = lround (extents.ascent); + pub->descent = lround (extents.descent); + pub->height = lround (extents.height); + pub->max_advance_width = lround (extents.max_x_advance); + } + FcPatternDestroy (pattern); + } + return pub; +} + +void +crxft_font_close (XftFont *pub) +{ + cairo_scaled_font_destroy (pub->scaled_font); + xfree (pub); +} + +cairo_t * +crxft_draw_create (Display *dpy, Drawable drawable, Visual *visual) +{ + cairo_t *cr = NULL; + Window root; + int x, y; + unsigned int width, height, border_width, depth; + + if (!XGetGeometry (dpy, drawable, &root, &x, &y, &width, &height, + &border_width, &depth)) + return NULL; + + cairo_surface_t *surface = cairo_xlib_surface_create (dpy, drawable, visual, + width, height); + if (surface) + { + cr = cairo_create (surface); + cairo_surface_destroy (surface); + } + + return cr; +} + +static void +crxft_set_source_color (cairo_t *cr, const XftColor *color) +{ + cairo_set_source_rgba (cr, color->color.red / 65535.0, + color->color.green / 65535.0, + color->color.blue / 65535.0, + color->color.alpha / 65535.0); +} + +void +crxft_draw_rect (cairo_t *cr, const XftColor *color, int x, int y, + unsigned int width, unsigned int height) +{ + crxft_set_source_color (cr, color); + cairo_rectangle (cr, x, y, width, height); + cairo_fill (cr); +} + +void +crxft_draw_string (cairo_t *cr, const XftColor *color, XftFont *pub, + int x, int y, const FcChar8 *string, int len) +{ + char *buf = xmalloc (len + 1); + memcpy (buf, string, len); + buf[len] = '\0'; + crxft_set_source_color (cr, color); + cairo_set_scaled_font (cr, pub->scaled_font); + cairo_move_to (cr, x, y); + cairo_show_text (cr, buf); + xfree (buf); +} + +void +crxft_text_extents (XftFont *pub, const FcChar8 *string, int len, + XGlyphInfo *extents) +{ + char *buf = xmalloc (len + 1); + memcpy (buf, string, len); + buf[len] = '\0'; + cairo_text_extents_t text_extents; + cairo_scaled_font_text_extents (pub->scaled_font, buf, &text_extents); + xfree (buf); + extents->x = ceil (- text_extents.x_bearing); + extents->y = ceil (- text_extents.y_bearing); + extents->width = (ceil (text_extents.x_bearing + text_extents.width) + + extents->x); + extents->height = (ceil (text_extents.y_bearing + text_extents.height) + + extents->y); + extents->xOff = lround (text_extents.x_advance); + extents->yOff = lround (text_extents.y_advance); +} +#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 *); Boolean XtWidgetBeingDestroyedP (Widget widget); +#ifdef USE_CAIRO + +#include <cairo.h> +#include <fontconfig/fontconfig.h> + +typedef struct { + cairo_scaled_font_t *scaled_font; + int ascent, descent, height, max_advance_width; +} XftFont; + +typedef cairo_t XftDraw; + +typedef struct { + unsigned long pixel; + struct {unsigned short red, green, blue, alpha;} color; +} XftColor; + +#ifdef HAVE_XRENDER +#include <X11/extensions/Xrender.h> +#else +typedef struct { + unsigned short width, height; + short x, y, xOff, yOff; +} XGlyphInfo; +#endif + +#define XftFontOpenName crxft_font_open_name +extern XftFont *crxft_font_open_name (Display *, int, const char *); +#define XftFontClose(dpy, pub) crxft_font_close (pub) +extern void crxft_font_close (XftFont *); +#define XftDrawCreate(dpy, drawable, visual, colormap) \ + crxft_draw_create (dpy, drawable, visual) +extern cairo_t *crxft_draw_create (Display *, Drawable, Visual *); +#define XftDrawDestroy cairo_destroy +#define XftDrawRect crxft_draw_rect +extern void crxft_draw_rect (cairo_t *, const XftColor *, int, int, + unsigned int, unsigned int); +#define XftDrawStringUtf8 crxft_draw_string +extern void crxft_draw_string (cairo_t *, const XftColor *, XftFont *, + int, int, const FcChar8 *, int); +#define XftTextExtentsUtf8(dpy, pub, string, len, extents) \ + crxft_text_extents (pub, string, len, extents) +extern void crxft_text_extents (XftFont *, const FcChar8 *, int, XGlyphInfo *); + +#endif /* USE_CAIRO */ #endif /* _LWLIB_UTILS_H_ */ diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c index 07ad29e1072..6292c840f5d 100644 --- a/lwlib/xlwmenu.c +++ b/lwlib/xlwmenu.c @@ -107,7 +107,7 @@ xlwMenuResources[] = {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet), offset(menu.fontSet), XtRFontSet, NULL}, #endif -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT #define DEFAULT_FONTNAME "Sans-10" #else #define DEFAULT_FONTNAME "XtDefaultFont" @@ -325,14 +325,14 @@ string_width (XlwMenuWidget mw, char *s) { XCharStruct xcs; int drop; -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (mw->menu.xft_font) { XGlyphInfo gi; XftTextExtentsUtf8 (XtDisplay (mw), mw->menu.xft_font, (FcChar8 *) s, strlen (s), &gi); - return gi.width; + return gi.xOff; } #endif #ifdef HAVE_X_I18N @@ -349,7 +349,7 @@ string_width (XlwMenuWidget mw, char *s) } -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT #define MENU_FONT_HEIGHT(mw) \ ((mw)->menu.xft_font != NULL \ ? (mw)->menu.xft_font->height \ @@ -965,7 +965,7 @@ display_menu_item (XlwMenuWidget mw, int width; enum menu_separator separator; int separator_p = lw_separator_p (val->name, &separator, 0); -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT XftColor *xftfg; #endif @@ -1005,7 +1005,7 @@ display_menu_item (XlwMenuWidget mw, else text_gc = mw->menu.disabled_gc; deco_gc = mw->menu.foreground_gc; -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT xftfg = val->enabled ? &mw->menu.xft_fg : &mw->menu.xft_disabled_fg; #endif @@ -1032,10 +1032,13 @@ display_menu_item (XlwMenuWidget mw, x_offset += ws->button_width; -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (ws->xft_draw) { int draw_y = y + v_spacing + shadow; +#ifdef USE_CAIRO + cairo_surface_mark_dirty (cairo_get_target (ws->xft_draw)); +#endif XftDrawStringUtf8 (ws->xft_draw, xftfg, mw->menu.xft_font, x_offset, draw_y + font_ascent, @@ -1078,7 +1081,7 @@ display_menu_item (XlwMenuWidget mw, } else if (val->key) { -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (ws->xft_draw) { int draw_x = ws->width - ws->max_rest_width @@ -1119,6 +1122,10 @@ display_menu_item (XlwMenuWidget mw, draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, True, False); } +#ifdef USE_CAIRO + if (ws->xft_draw) + cairo_surface_flush (cairo_get_target (ws->xft_draw)); +#endif if (highlighted_p) draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, False, @@ -1320,7 +1327,7 @@ make_windows_if_needed (XlwMenuWidget mw, int n) XtAddEventHandler (windows [i].w, ExposureMask, False, expose_cb, mw); windows [i].window = XtWindow (windows [i].w); windows [i].pixmap = None; -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT windows [i].xft_draw = 0; #endif set_window_type (windows [i].w, mw); @@ -1411,7 +1418,7 @@ create_pixmap_for_menu (window_state* ws, XlwMenuWidget mw) ws->pixmap = XCreatePixmap (XtDisplay (ws->w), ws->window, ws->width, ws->height, DefaultDepthOfScreen (XtScreen (ws->w))); -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (ws->xft_draw) XftDrawDestroy (ws->xft_draw); if (mw->menu.xft_font) @@ -1831,7 +1838,7 @@ release_shadow_gcs (XlwMenuWidget mw) XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc); } -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT static XftFont * getDefaultXftFont (XlwMenuWidget mw) { @@ -1887,7 +1894,7 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args) gray_width, gray_height, (unsigned long)1, (unsigned long)0, 1); -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (openXftFont (mw)) ; else @@ -1933,7 +1940,7 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args) mw->menu.windows [0].height = 0; mw->menu.windows [0].max_rest_width = 0; mw->menu.windows [0].pixmap = None; -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT mw->menu.windows [0].xft_draw = 0; #endif size_menu (mw, 0); @@ -1981,7 +1988,7 @@ XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes) set_window_type (mw->menu.windows [0].w, mw); create_pixmap_for_menu (&mw->menu.windows [0], mw); -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (mw->menu.xft_font) { XColor colors[3]; @@ -2078,7 +2085,7 @@ XlwMenuDestroy (Widget w) if (mw->menu.font) XFreeFont (XtDisplay (mw), mw->menu.font); -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (mw->menu.windows [0].xft_draw) XftDrawDestroy (mw->menu.windows [0].xft_draw); if (mw->menu.xft_font) @@ -2092,7 +2099,7 @@ XlwMenuDestroy (Widget w) { if (mw->menu.windows [i].pixmap != None) XFreePixmap (XtDisplay (mw), mw->menu.windows [i].pixmap); -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (mw->menu.windows [i].xft_draw) XftDrawDestroy (mw->menu.windows [i].xft_draw); #endif @@ -2102,7 +2109,7 @@ XlwMenuDestroy (Widget w) XtFree ((char *) mw->menu.windows); } -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT static int fontname_changed (XlwMenuWidget newmw, XlwMenuWidget oldmw) @@ -2134,7 +2141,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 +#if defined USE_CAIRO || defined HAVE_XFT || fontname_changed (newmw, oldmw) #endif #ifdef HAVE_X_I18N @@ -2170,7 +2177,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget new, } } -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT if (fontname_changed (newmw, oldmw)) { 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/>. */ #include "xlwmenu.h" #include <X11/CoreP.h> -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT +#ifdef USE_CAIRO +#include "lwlib-utils.h" +#else /* HAVE_XFT */ #include <X11/Xft/Xft.h> #endif +#endif /* Elements in the stack arrays. */ typedef struct _window_state @@ -42,7 +46,7 @@ typedef struct _window_state /* Width of toggle buttons or radio buttons. */ Dimension button_width; -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT XftDraw* xft_draw; #endif } window_state; @@ -56,7 +60,7 @@ typedef struct _XlwMenu_part XFontSet fontSet; XFontSetExtents *font_extents; #endif -#ifdef HAVE_XFT +#if defined USE_CAIRO || defined HAVE_XFT int default_face; XftFont* xft_font; XftColor xft_fg, xft_bg, xft_disabled_fg; |