Remove conditional compilation for cairo/pangocairo (#2480)

We strive to avoid conditional compilation in i3 as much as possible.
cairo and pangocairo have been around long enough in the versions that
we need that it’s time to unconditionally depend on them.

Also update DEPENDS with the last-known-good-versions while at it.
This commit is contained in:
Michael Stapelberg 2016-09-27 12:57:00 -07:00 committed by GitHub
parent a15ce8cb8d
commit 0e73a6e9e7
8 changed files with 12 additions and 90 deletions

18
DEPENDS
View File

@ -7,25 +7,25 @@
┌──────────────┬────────┬────────┬───────────────────────────────────────────────────────────┐ ┌──────────────┬────────┬────────┬───────────────────────────────────────────────────────────┐
│ dependency │ min. │ lkgv │ URL │ │ dependency │ min. │ lkgv │ URL │
├──────────────┼────────┼────────┼───────────────────────────────────────────────────────────┤ ├──────────────┼────────┼────────┼───────────────────────────────────────────────────────────┤
│ pkg-config │ 0.25 │ 0.28 │ http://pkgconfig.freedesktop.org/ │ │ pkg-config │ 0.25 │ 0.29 │ http://pkgconfig.freedesktop.org/ │
│ libxcb │ 1.1.93 │ 1.11 │ http://xcb.freedesktop.org/dist/ │ │ libxcb │ 1.1.93 │ 1.12 │ http://xcb.freedesktop.org/dist/ │
│ xcb-util │ 0.3.3 │ 0.4.1 │ http://xcb.freedesktop.org/dist/ │ │ xcb-util │ 0.3.3 │ 0.4.1 │ http://xcb.freedesktop.org/dist/ │
│ xkbcommon │ 0.4.0 │ 0.5.0 │ http://xkbcommon.org/ │ │ xkbcommon │ 0.4.0 │ 0.6.1 │ http://xkbcommon.org/ │
│ xkbcommon-x11│ 0.4.0 │ 0.5.0 │ http://xkbcommon.org/ │ │ xkbcommon-x11│ 0.4.0 │ 0.6.1 │ http://xkbcommon.org/ │
│ util-cursor³⁴│ 0.0.99 │ 0.1.2 │ http://xcb.freedesktop.org/dist/ │ │ util-cursor³⁴│ 0.0.99 │ 0.1.3 │ http://xcb.freedesktop.org/dist/ │
│ util-wm⁴ │ 0.3.8 │ 0.3.8 │ http://xcb.freedesktop.org/dist/ │ │ util-wm⁴ │ 0.3.8 │ 0.3.8 │ http://xcb.freedesktop.org/dist/ │
│ util-keysyms⁴│ 0.3.8 │ 0.4.0 │ http://xcb.freedesktop.org/dist/ │ │ util-keysyms⁴│ 0.3.8 │ 0.4.0 │ http://xcb.freedesktop.org/dist/ │
│ util-xrm⁴ │ 1.0.0 │ 1.0.0 │ https://github.com/Airblader/xcb-util-xrm │ │ util-xrm⁴ │ 1.0.0 │ 1.0.0 │ https://github.com/Airblader/xcb-util-xrm │
│ libev │ 4.0 │ 4.19 │ http://libev.schmorp.de/ │ │ libev │ 4.0 │ 4.19 │ http://libev.schmorp.de/ │
│ yajl │ 2.0.1 │ 2.1.0 │ http://lloyd.github.com/yajl/ │ │ yajl │ 2.0.1 │ 2.1.0 │ http://lloyd.github.com/yajl/ │
│ asciidoc │ 8.3.0 │ 8.6.8 │ http://www.methods.co.nz/asciidoc/ │ │ asciidoc │ 8.3.0 │ 8.6.9 │ http://www.methods.co.nz/asciidoc/ │
│ xmlto │ 0.0.23 │ 0.0.23 │ http://www.methods.co.nz/asciidoc/ │ │ xmlto │ 0.0.23 │ 0.0.23 │ http://www.methods.co.nz/asciidoc/ │
│ Pod::Simple² │ 3.22 │ 3.22 │ http://search.cpan.org/~dwheeler/Pod-Simple-3.23/ │ │ Pod::Simple² │ 3.22 │ 3.22 │ http://search.cpan.org/~dwheeler/Pod-Simple-3.23/ │
│ docbook-xml │ 4.5 │ 4.5 │ http://www.methods.co.nz/asciidoc/ │ │ docbook-xml │ 4.5 │ 4.5 │ http://www.methods.co.nz/asciidoc/ │
│ PCRE │ 8.12 │ 8.35 │ http://www.pcre.org/ │ │ PCRE │ 8.12 │ 8.38 │ http://www.pcre.org/ │
│ libsn¹ │ 0.10 │ 0.12 │ http://freedesktop.org/wiki/Software/startup-notification │ │ libsn¹ │ 0.10 │ 0.12 │ http://freedesktop.org/wiki/Software/startup-notification │
│ pango │ 1.30.0 | 1.36.8 │ http://www.pango.org/ │ │ pango │ 1.30.0 | 1.40.1 │ http://www.pango.org/ │
│ cairo │ 1.14.4 │ 1.14.4 │ http://cairographics.org/ │ │ cairo │ 1.14.4 │ 1.14.6 │ http://cairographics.org/ │
└──────────────┴────────┴────────┴───────────────────────────────────────────────────────────┘ └──────────────┴────────┴────────┴───────────────────────────────────────────────────────────┘
¹ libsn = libstartup-notification ¹ libsn = libstartup-notification
² Pod::Simple is a Perl module required for converting the testsuite ² Pod::Simple is a Perl module required for converting the testsuite

View File

@ -147,9 +147,8 @@ LIBSN_LIBS := $(call ldflags_for_lib, libstartup-notification-1.0,startup-noti
# Pango # Pango
PANGO_CFLAGS := $(call cflags_for_lib, cairo) PANGO_CFLAGS := $(call cflags_for_lib, cairo)
PANGO_CFLAGS += $(call cflags_for_lib, pangocairo) PANGO_CFLAGS += $(call cflags_for_lib, pangocairo)
I3_CPPFLAGS += -DPANGO_SUPPORT=1 ifneq ($(shell $(PKG_CONFIG) --atleast-version=1.14.4 cairo 2>/dev/null && echo 1),1)
ifeq ($(shell $(PKG_CONFIG) --atleast-version=1.14.4 cairo 2>/dev/null && echo 1),1) $(error "cairo >= 1.14.4 missing")
I3_CPPFLAGS += -DCAIRO_SUPPORT=1
endif endif
PANGO_LIBS := $(call ldflags_for_lib, cairo) PANGO_LIBS := $(call ldflags_for_lib, cairo)
PANGO_LIBS += $(call ldflags_for_lib, pangocairo) PANGO_LIBS += $(call ldflags_for_lib, pangocairo)

2
debian/control vendored
View File

@ -22,7 +22,7 @@ Build-Depends: debhelper (>= 9),
libyajl-dev (>= 2.0.4), libyajl-dev (>= 2.0.4),
libpcre3-dev (>= 1:8.10), libpcre3-dev (>= 1:8.10),
libstartup-notification0-dev (>= 0.10), libstartup-notification0-dev (>= 0.10),
libcairo2-dev, libcairo2-dev (>= 1.14.4),
libpango1.0-dev, libpango1.0-dev,
libpod-simple-perl libpod-simple-perl
Standards-Version: 3.9.7 Standards-Version: 3.9.7

View File

@ -17,12 +17,8 @@
#include <xcb/xproto.h> #include <xcb/xproto.h>
#include <xcb/xcb_keysyms.h> #include <xcb/xcb_keysyms.h>
#if PANGO_SUPPORT
#include <pango/pango.h> #include <pango/pango.h>
#endif
#if CAIRO_SUPPORT
#include <cairo/cairo-xcb.h> #include <cairo/cairo-xcb.h>
#endif
#define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) #define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
@ -73,10 +69,8 @@ struct Font {
xcb_charinfo_t *table; xcb_charinfo_t *table;
} xcb; } xcb;
#if PANGO_SUPPORT
/** The pango font description */ /** The pango font description */
PangoFontDescription *pango_desc; PangoFontDescription *pango_desc;
#endif
} specific; } specific;
}; };
@ -525,7 +519,6 @@ typedef struct placeholder_t {
*/ */
char *format_placeholders(char *format, placeholder_t *placeholders, int num); char *format_placeholders(char *format, placeholder_t *placeholders, int num);
#if CAIRO_SUPPORT
/* We need to flush cairo surfaces twice to avoid an assertion bug. See #1989 /* We need to flush cairo surfaces twice to avoid an assertion bug. See #1989
* and https://bugs.freedesktop.org/show_bug.cgi?id=92455. */ * and https://bugs.freedesktop.org/show_bug.cgi?id=92455. */
#define CAIRO_SURFACE_FLUSH(surface) \ #define CAIRO_SURFACE_FLUSH(surface) \
@ -533,7 +526,6 @@ char *format_placeholders(char *format, placeholder_t *placeholders, int num);
cairo_surface_flush(surface); \ cairo_surface_flush(surface); \
cairo_surface_flush(surface); \ cairo_surface_flush(surface); \
} while (0) } while (0)
#endif
/* A wrapper grouping an XCB drawable and both a graphics context /* A wrapper grouping an XCB drawable and both a graphics context
* and the corresponding cairo objects representing it. */ * and the corresponding cairo objects representing it. */
@ -549,14 +541,12 @@ typedef struct surface_t {
int width; int width;
int height; int height;
#if CAIRO_SUPPORT
/* A cairo surface representing the drawable. */ /* A cairo surface representing the drawable. */
cairo_surface_t *surface; cairo_surface_t *surface;
/* The cairo object representing the drawable. In general, /* The cairo object representing the drawable. In general,
* this is what one should use for any drawing operation. */ * this is what one should use for any drawing operation. */
cairo_t *cr; cairo_t *cr;
#endif
} surface_t; } surface_t;
/** /**

View File

@ -11,9 +11,7 @@
#include <string.h> #include <string.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <xcb/xcb_aux.h> #include <xcb/xcb_aux.h>
#if CAIRO_SUPPORT
#include <cairo/cairo-xcb.h> #include <cairo/cairo-xcb.h>
#endif
#include "libi3.h" #include "libi3.h"
@ -50,10 +48,8 @@ void draw_util_surface_init(xcb_connection_t *conn, surface_t *surface, xcb_draw
ELOG("Could not create graphical context. Error code: %d. Please report this bug.\n", error->error_code); ELOG("Could not create graphical context. Error code: %d. Please report this bug.\n", error->error_code);
} }
#if CAIRO_SUPPORT
surface->surface = cairo_xcb_surface_create(conn, surface->id, surface->visual_type, width, height); surface->surface = cairo_xcb_surface_create(conn, surface->id, surface->visual_type, width, height);
surface->cr = cairo_create(surface->surface); surface->cr = cairo_create(surface->surface);
#endif
} }
/* /*
@ -62,7 +58,6 @@ void draw_util_surface_init(xcb_connection_t *conn, surface_t *surface, xcb_draw
*/ */
void draw_util_surface_free(xcb_connection_t *conn, surface_t *surface) { void draw_util_surface_free(xcb_connection_t *conn, surface_t *surface) {
xcb_free_gc(conn, surface->gc); xcb_free_gc(conn, surface->gc);
#if CAIRO_SUPPORT
cairo_surface_destroy(surface->surface); cairo_surface_destroy(surface->surface);
cairo_destroy(surface->cr); cairo_destroy(surface->cr);
@ -71,7 +66,6 @@ void draw_util_surface_free(xcb_connection_t *conn, surface_t *surface) {
* when setting the border of a window to none and then closing it. */ * when setting the border of a window to none and then closing it. */
surface->surface = NULL; surface->surface = NULL;
surface->cr = NULL; surface->cr = NULL;
#endif
} }
/* /*
@ -81,9 +75,7 @@ void draw_util_surface_free(xcb_connection_t *conn, surface_t *surface) {
void draw_util_surface_set_size(surface_t *surface, int width, int height) { void draw_util_surface_set_size(surface_t *surface, int width, int height) {
surface->width = width; surface->width = width;
surface->height = height; surface->height = height;
#if CAIRO_SUPPORT
cairo_xcb_surface_set_size(surface->surface, width, height); cairo_xcb_surface_set_size(surface->surface, width, height);
#endif
} }
/* /*
@ -121,13 +113,7 @@ color_t draw_util_hex_to_color(const char *color) {
static void draw_util_set_source_color(xcb_connection_t *conn, surface_t *surface, color_t color) { static void draw_util_set_source_color(xcb_connection_t *conn, surface_t *surface, color_t color) {
RETURN_UNLESS_SURFACE_INITIALIZED(surface); RETURN_UNLESS_SURFACE_INITIALIZED(surface);
#if CAIRO_SUPPORT
cairo_set_source_rgba(surface->cr, color.red, color.green, color.blue, color.alpha); cairo_set_source_rgba(surface->cr, color.red, color.green, color.blue, color.alpha);
#else
uint32_t colorpixel = color.colorpixel;
xcb_change_gc(conn, surface->gc, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND,
(uint32_t[]){colorpixel, colorpixel});
#endif
} }
/** /**
@ -139,18 +125,14 @@ static void draw_util_set_source_color(xcb_connection_t *conn, surface_t *surfac
void draw_util_text(i3String *text, surface_t *surface, color_t fg_color, color_t bg_color, int x, int y, int max_width) { void draw_util_text(i3String *text, surface_t *surface, color_t fg_color, color_t bg_color, int x, int y, int max_width) {
RETURN_UNLESS_SURFACE_INITIALIZED(surface); RETURN_UNLESS_SURFACE_INITIALIZED(surface);
#if CAIRO_SUPPORT
/* Flush any changes before we draw the text as this might use XCB directly. */ /* Flush any changes before we draw the text as this might use XCB directly. */
CAIRO_SURFACE_FLUSH(surface->surface); CAIRO_SURFACE_FLUSH(surface->surface);
#endif
set_font_colors(surface->gc, fg_color, bg_color); set_font_colors(surface->gc, fg_color, bg_color);
draw_text(text, surface->id, surface->gc, surface->visual_type, x, y, max_width); draw_text(text, surface->id, surface->gc, surface->visual_type, x, y, max_width);
#if CAIRO_SUPPORT
/* Notify cairo that we (possibly) used another way to draw on the surface. */ /* Notify cairo that we (possibly) used another way to draw on the surface. */
cairo_surface_mark_dirty(surface->surface); cairo_surface_mark_dirty(surface->surface);
#endif
} }
/** /**
@ -162,7 +144,6 @@ void draw_util_text(i3String *text, surface_t *surface, color_t fg_color, color_
void draw_util_rectangle(xcb_connection_t *conn, surface_t *surface, color_t color, double x, double y, double w, double h) { void draw_util_rectangle(xcb_connection_t *conn, surface_t *surface, color_t color, double x, double y, double w, double h) {
RETURN_UNLESS_SURFACE_INITIALIZED(surface); RETURN_UNLESS_SURFACE_INITIALIZED(surface);
#if CAIRO_SUPPORT
cairo_save(surface->cr); cairo_save(surface->cr);
/* Using the SOURCE operator will copy both color and alpha information directly /* Using the SOURCE operator will copy both color and alpha information directly
@ -179,12 +160,6 @@ void draw_util_rectangle(xcb_connection_t *conn, surface_t *surface, color_t col
CAIRO_SURFACE_FLUSH(surface->surface); CAIRO_SURFACE_FLUSH(surface->surface);
cairo_restore(surface->cr); cairo_restore(surface->cr);
#else
draw_util_set_source_color(conn, surface, color);
xcb_rectangle_t rect = {x, y, w, h};
xcb_poly_fill_rectangle(conn, surface->id, surface->gc, 1, &rect);
#endif
} }
/** /**
@ -194,7 +169,6 @@ void draw_util_rectangle(xcb_connection_t *conn, surface_t *surface, color_t col
void draw_util_clear_surface(xcb_connection_t *conn, surface_t *surface, color_t color) { void draw_util_clear_surface(xcb_connection_t *conn, surface_t *surface, color_t color) {
RETURN_UNLESS_SURFACE_INITIALIZED(surface); RETURN_UNLESS_SURFACE_INITIALIZED(surface);
#if CAIRO_SUPPORT
cairo_save(surface->cr); cairo_save(surface->cr);
/* Using the SOURCE operator will copy both color and alpha information directly /* Using the SOURCE operator will copy both color and alpha information directly
@ -210,12 +184,6 @@ void draw_util_clear_surface(xcb_connection_t *conn, surface_t *surface, color_t
CAIRO_SURFACE_FLUSH(surface->surface); CAIRO_SURFACE_FLUSH(surface->surface);
cairo_restore(surface->cr); cairo_restore(surface->cr);
#else
draw_util_set_source_color(conn, surface, color);
xcb_rectangle_t rect = {0, 0, surface->width, surface->height};
xcb_poly_fill_rectangle(conn, surface->id, surface->gc, 1, &rect);
#endif
} }
/** /**
@ -227,7 +195,6 @@ void draw_util_copy_surface(xcb_connection_t *conn, surface_t *src, surface_t *d
RETURN_UNLESS_SURFACE_INITIALIZED(src); RETURN_UNLESS_SURFACE_INITIALIZED(src);
RETURN_UNLESS_SURFACE_INITIALIZED(dest); RETURN_UNLESS_SURFACE_INITIALIZED(dest);
#if CAIRO_SUPPORT
cairo_save(dest->cr); cairo_save(dest->cr);
/* Using the SOURCE operator will copy both color and alpha information directly /* Using the SOURCE operator will copy both color and alpha information directly
@ -245,8 +212,4 @@ void draw_util_copy_surface(xcb_connection_t *conn, surface_t *src, surface_t *d
CAIRO_SURFACE_FLUSH(dest->surface); CAIRO_SURFACE_FLUSH(dest->surface);
cairo_restore(dest->cr); cairo_restore(dest->cr);
#else
xcb_copy_area(conn, src->id, dest->id, dest->gc, (int16_t)src_x, (int16_t)src_y,
(int16_t)dest_x, (int16_t)dest_y, (uint16_t)width, (uint16_t)height);
#endif
} }

View File

@ -13,15 +13,12 @@
#include <err.h> #include <err.h>
#include <cairo/cairo-xcb.h> #include <cairo/cairo-xcb.h>
#if PANGO_SUPPORT
#include <pango/pangocairo.h> #include <pango/pangocairo.h>
#endif
#include "libi3.h" #include "libi3.h"
static const i3Font *savedFont = NULL; static const i3Font *savedFont = NULL;
#if PANGO_SUPPORT
static xcb_visualtype_t *root_visual_type; static xcb_visualtype_t *root_visual_type;
static double pango_font_red; static double pango_font_red;
static double pango_font_green; static double pango_font_green;
@ -166,7 +163,6 @@ static int predict_text_width_pango(const char *text, size_t text_len, bool pang
return width; return width;
} }
#endif
/* /*
* Loads a font for usage, also getting its metrics. If fallback is true, * Loads a font for usage, also getting its metrics. If fallback is true,
@ -187,7 +183,6 @@ i3Font load_font(const char *pattern, const bool fallback) {
return font; return font;
} }
#if PANGO_SUPPORT
/* Try to load a pango font if specified */ /* Try to load a pango font if specified */
if (strlen(pattern) > strlen("pango:") && !strncmp(pattern, "pango:", strlen("pango:"))) { if (strlen(pattern) > strlen("pango:") && !strncmp(pattern, "pango:", strlen("pango:"))) {
const char *font_pattern = pattern + strlen("pango:"); const char *font_pattern = pattern + strlen("pango:");
@ -202,7 +197,6 @@ i3Font load_font(const char *pattern, const bool fallback) {
return font; return font;
} }
} }
#endif
/* Send all our requests first */ /* Send all our requests first */
font.specific.xcb.id = xcb_generate_id(conn); font.specific.xcb.id = xcb_generate_id(conn);
@ -297,12 +291,10 @@ void free_font(void) {
free(savedFont->specific.xcb.info); free(savedFont->specific.xcb.info);
break; break;
} }
#if PANGO_SUPPORT
case FONT_TYPE_PANGO: case FONT_TYPE_PANGO:
/* Free the font description */ /* Free the font description */
pango_font_description_free(savedFont->specific.pango_desc); pango_font_description_free(savedFont->specific.pango_desc);
break; break;
#endif
default: default:
assert(false); assert(false);
break; break;
@ -329,14 +321,12 @@ void set_font_colors(xcb_gcontext_t gc, color_t foreground, color_t background)
xcb_change_gc(conn, gc, mask, values); xcb_change_gc(conn, gc, mask, values);
break; break;
} }
#if PANGO_SUPPORT
case FONT_TYPE_PANGO: case FONT_TYPE_PANGO:
/* Save the foreground font */ /* Save the foreground font */
pango_font_red = foreground.red; pango_font_red = foreground.red;
pango_font_green = foreground.green; pango_font_green = foreground.green;
pango_font_blue = foreground.blue; pango_font_blue = foreground.blue;
break; break;
#endif
default: default:
assert(false); assert(false);
break; break;
@ -348,11 +338,7 @@ void set_font_colors(xcb_gcontext_t gc, color_t foreground, color_t background)
* *
*/ */
bool font_is_pango(void) { bool font_is_pango(void) {
#if PANGO_SUPPORT
return savedFont->type == FONT_TYPE_PANGO; return savedFont->type == FONT_TYPE_PANGO;
#else
return false;
#endif
} }
static int predict_text_width_xcb(const xcb_char2b_t *text, size_t text_len); static int predict_text_width_xcb(const xcb_char2b_t *text, size_t text_len);
@ -397,11 +383,9 @@ static void draw_text_xcb(const xcb_char2b_t *text, size_t text_len, xcb_drawabl
void draw_text(i3String *text, xcb_drawable_t drawable, xcb_gcontext_t gc, void draw_text(i3String *text, xcb_drawable_t drawable, xcb_gcontext_t gc,
xcb_visualtype_t *visual, int x, int y, int max_width) { xcb_visualtype_t *visual, int x, int y, int max_width) {
assert(savedFont != NULL); assert(savedFont != NULL);
#if PANGO_SUPPORT
if (visual == NULL) { if (visual == NULL) {
visual = root_visual_type; visual = root_visual_type;
} }
#endif
switch (savedFont->type) { switch (savedFont->type) {
case FONT_TYPE_NONE: case FONT_TYPE_NONE:
@ -411,13 +395,11 @@ void draw_text(i3String *text, xcb_drawable_t drawable, xcb_gcontext_t gc,
draw_text_xcb(i3string_as_ucs2(text), i3string_get_num_glyphs(text), draw_text_xcb(i3string_as_ucs2(text), i3string_get_num_glyphs(text),
drawable, gc, x, y, max_width); drawable, gc, x, y, max_width);
break; break;
#if PANGO_SUPPORT
case FONT_TYPE_PANGO: case FONT_TYPE_PANGO:
/* Render the text using Pango */ /* Render the text using Pango */
draw_text_pango(i3string_as_utf8(text), i3string_get_num_bytes(text), draw_text_pango(i3string_as_utf8(text), i3string_get_num_bytes(text),
drawable, visual, x, y, max_width, i3string_is_markup(text)); drawable, visual, x, y, max_width, i3string_is_markup(text));
return; return;
#endif
default: default:
assert(false); assert(false);
} }
@ -450,13 +432,11 @@ void draw_text_ascii(const char *text, xcb_drawable_t drawable,
} }
break; break;
} }
#if PANGO_SUPPORT
case FONT_TYPE_PANGO: case FONT_TYPE_PANGO:
/* Render the text using Pango */ /* Render the text using Pango */
draw_text_pango(text, strlen(text), draw_text_pango(text, strlen(text),
drawable, root_visual_type, x, y, max_width, false); drawable, root_visual_type, x, y, max_width, false);
return; return;
#endif
default: default:
assert(false); assert(false);
} }
@ -547,12 +527,10 @@ int predict_text_width(i3String *text) {
return 0; return 0;
case FONT_TYPE_XCB: case FONT_TYPE_XCB:
return predict_text_width_xcb(i3string_as_ucs2(text), i3string_get_num_glyphs(text)); return predict_text_width_xcb(i3string_as_ucs2(text), i3string_get_num_glyphs(text));
#if PANGO_SUPPORT
case FONT_TYPE_PANGO: case FONT_TYPE_PANGO:
/* Calculate extents using Pango */ /* Calculate extents using Pango */
return predict_text_width_pango(i3string_as_utf8(text), i3string_get_num_bytes(text), return predict_text_width_pango(i3string_as_utf8(text), i3string_get_num_bytes(text),
i3string_is_markup(text)); i3string_is_markup(text));
#endif
default: default:
assert(false); assert(false);
return 0; return 0;

View File

@ -13,9 +13,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if PANGO_SUPPORT
#include <glib.h> #include <glib.h>
#endif
#include "libi3.h" #include "libi3.h"
@ -192,15 +190,11 @@ void i3string_set_markup(i3String *str, bool pango_markup) {
* Escape pango markup characters in the given string. * Escape pango markup characters in the given string.
*/ */
i3String *i3string_escape_markup(i3String *str) { i3String *i3string_escape_markup(i3String *str) {
#if PANGO_SUPPORT
const char *text = i3string_as_utf8(str); const char *text = i3string_as_utf8(str);
char *escaped = g_markup_escape_text(text, -1); char *escaped = g_markup_escape_text(text, -1);
i3String *result = i3string_from_utf8(escaped); i3String *result = i3string_from_utf8(escaped);
free(escaped); free(escaped);
return result; return result;
#else
return str;
#endif
} }
/* /*

View File

@ -327,12 +327,10 @@ char *pango_escape_markup(char *input) {
if (!font_is_pango()) if (!font_is_pango())
return input; return input;
#if PANGO_SUPPORT
char *escaped = g_markup_escape_text(input, -1); char *escaped = g_markup_escape_text(input, -1);
FREE(input); FREE(input);
return escaped; return escaped;
#endif
} }
/* /*