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.
┌──────────────┬────────┬────────┬───────────────────────────────────────────────────────────┐
│ dependency │ min. │ lkgv │ URL │
├──────────────┼────────┼────────┼───────────────────────────────────────────────────────────┤
-│ pkg-config │ 0.25 │ 0.28 │ http://pkgconfig.freedesktop.org/ │
-│ libxcb │ 1.1.93 │ 1.11 │ http://xcb.freedesktop.org/dist/ │
+│ pkg-config │ 0.25 │ 0.29 │ http://pkgconfig.freedesktop.org/ │
+│ libxcb │ 1.1.93 │ 1.12 │ 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-x11│ 0.4.0 │ 0.5.0 │ http://xkbcommon.org/ │
-│ util-cursor³⁴│ 0.0.99 │ 0.1.2 │ http://xcb.freedesktop.org/dist/ │
+│ xkbcommon │ 0.4.0 │ 0.6.1 │ http://xkbcommon.org/ │
+│ xkbcommon-x11│ 0.4.0 │ 0.6.1 │ http://xkbcommon.org/ │
+│ 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-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 │
│ libev │ 4.0 │ 4.19 │ http://libev.schmorp.de/ │
│ 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/ │
│ 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/ │
-│ 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 │
-│ pango │ 1.30.0 | 1.36.8 │ http://www.pango.org/ │
-│ cairo │ 1.14.4 │ 1.14.4 │ http://cairographics.org/ │
+│ pango │ 1.30.0 | 1.40.1 │ http://www.pango.org/ │
+│ cairo │ 1.14.4 │ 1.14.6 │ http://cairographics.org/ │
└──────────────┴────────┴────────┴───────────────────────────────────────────────────────────┘
¹ libsn = libstartup-notification
² Pod::Simple is a Perl module required for converting the testsuite
# Pango
PANGO_CFLAGS := $(call cflags_for_lib, cairo)
PANGO_CFLAGS += $(call cflags_for_lib, pangocairo)
-I3_CPPFLAGS += -DPANGO_SUPPORT=1
-ifeq ($(shell $(PKG_CONFIG) --atleast-version=1.14.4 cairo 2>/dev/null && echo 1),1)
-I3_CPPFLAGS += -DCAIRO_SUPPORT=1
+ifneq ($(shell $(PKG_CONFIG) --atleast-version=1.14.4 cairo 2>/dev/null && echo 1),1)
+$(error "cairo >= 1.14.4 missing")
endif
PANGO_LIBS := $(call ldflags_for_lib, cairo)
PANGO_LIBS += $(call ldflags_for_lib, pangocairo)
libyajl-dev (>= 2.0.4),
libpcre3-dev (>= 1:8.10),
libstartup-notification0-dev (>= 0.10),
- libcairo2-dev,
+ libcairo2-dev (>= 1.14.4),
libpango1.0-dev,
libpod-simple-perl
Standards-Version: 3.9.7
#include <xcb/xproto.h>
#include <xcb/xcb_keysyms.h>
-#if PANGO_SUPPORT
#include <pango/pango.h>
-#endif
-#if CAIRO_SUPPORT
#include <cairo/cairo-xcb.h>
-#endif
#define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
xcb_charinfo_t *table;
} xcb;
-#if PANGO_SUPPORT
/** The pango font description */
PangoFontDescription *pango_desc;
-#endif
} specific;
};
*/
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
* and https://bugs.freedesktop.org/show_bug.cgi?id=92455. */
#define CAIRO_SURFACE_FLUSH(surface) \
cairo_surface_flush(surface); \
cairo_surface_flush(surface); \
} while (0)
-#endif
/* A wrapper grouping an XCB drawable and both a graphics context
* and the corresponding cairo objects representing it. */
int width;
int height;
-#if CAIRO_SUPPORT
/* A cairo surface representing the drawable. */
cairo_surface_t *surface;
/* The cairo object representing the drawable. In general,
* this is what one should use for any drawing operation. */
cairo_t *cr;
-#endif
} surface_t;
/**
#include <string.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
-#if CAIRO_SUPPORT
#include <cairo/cairo-xcb.h>
-#endif
#include "libi3.h"
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->cr = cairo_create(surface->surface);
-#endif
}
/*
*/
void draw_util_surface_free(xcb_connection_t *conn, surface_t *surface) {
xcb_free_gc(conn, surface->gc);
-#if CAIRO_SUPPORT
cairo_surface_destroy(surface->surface);
cairo_destroy(surface->cr);
* when setting the border of a window to none and then closing it. */
surface->surface = NULL;
surface->cr = NULL;
-#endif
}
/*
void draw_util_surface_set_size(surface_t *surface, int width, int height) {
surface->width = width;
surface->height = height;
-#if CAIRO_SUPPORT
cairo_xcb_surface_set_size(surface->surface, width, height);
-#endif
}
/*
static void draw_util_set_source_color(xcb_connection_t *conn, surface_t *surface, color_t color) {
RETURN_UNLESS_SURFACE_INITIALIZED(surface);
-#if CAIRO_SUPPORT
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
}
/**
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);
-#if CAIRO_SUPPORT
/* Flush any changes before we draw the text as this might use XCB directly. */
CAIRO_SURFACE_FLUSH(surface->surface);
-#endif
set_font_colors(surface->gc, fg_color, bg_color);
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. */
cairo_surface_mark_dirty(surface->surface);
-#endif
}
/**
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);
-#if CAIRO_SUPPORT
cairo_save(surface->cr);
/* Using the SOURCE operator will copy both color and alpha information directly
CAIRO_SURFACE_FLUSH(surface->surface);
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
}
/**
void draw_util_clear_surface(xcb_connection_t *conn, surface_t *surface, color_t color) {
RETURN_UNLESS_SURFACE_INITIALIZED(surface);
-#if CAIRO_SUPPORT
cairo_save(surface->cr);
/* Using the SOURCE operator will copy both color and alpha information directly
CAIRO_SURFACE_FLUSH(surface->surface);
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
}
/**
RETURN_UNLESS_SURFACE_INITIALIZED(src);
RETURN_UNLESS_SURFACE_INITIALIZED(dest);
-#if CAIRO_SUPPORT
cairo_save(dest->cr);
/* Using the SOURCE operator will copy both color and alpha information directly
CAIRO_SURFACE_FLUSH(dest->surface);
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
}
#include <err.h>
#include <cairo/cairo-xcb.h>
-#if PANGO_SUPPORT
#include <pango/pangocairo.h>
-#endif
#include "libi3.h"
static const i3Font *savedFont = NULL;
-#if PANGO_SUPPORT
static xcb_visualtype_t *root_visual_type;
static double pango_font_red;
static double pango_font_green;
return width;
}
-#endif
/*
* Loads a font for usage, also getting its metrics. If fallback is true,
return font;
}
-#if PANGO_SUPPORT
/* Try to load a pango font if specified */
if (strlen(pattern) > strlen("pango:") && !strncmp(pattern, "pango:", strlen("pango:"))) {
const char *font_pattern = pattern + strlen("pango:");
return font;
}
}
-#endif
/* Send all our requests first */
font.specific.xcb.id = xcb_generate_id(conn);
free(savedFont->specific.xcb.info);
break;
}
-#if PANGO_SUPPORT
case FONT_TYPE_PANGO:
/* Free the font description */
pango_font_description_free(savedFont->specific.pango_desc);
break;
-#endif
default:
assert(false);
break;
xcb_change_gc(conn, gc, mask, values);
break;
}
-#if PANGO_SUPPORT
case FONT_TYPE_PANGO:
/* Save the foreground font */
pango_font_red = foreground.red;
pango_font_green = foreground.green;
pango_font_blue = foreground.blue;
break;
-#endif
default:
assert(false);
break;
*
*/
bool font_is_pango(void) {
-#if PANGO_SUPPORT
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);
void draw_text(i3String *text, xcb_drawable_t drawable, xcb_gcontext_t gc,
xcb_visualtype_t *visual, int x, int y, int max_width) {
assert(savedFont != NULL);
-#if PANGO_SUPPORT
if (visual == NULL) {
visual = root_visual_type;
}
-#endif
switch (savedFont->type) {
case FONT_TYPE_NONE:
draw_text_xcb(i3string_as_ucs2(text), i3string_get_num_glyphs(text),
drawable, gc, x, y, max_width);
break;
-#if PANGO_SUPPORT
case FONT_TYPE_PANGO:
/* Render the text using Pango */
draw_text_pango(i3string_as_utf8(text), i3string_get_num_bytes(text),
drawable, visual, x, y, max_width, i3string_is_markup(text));
return;
-#endif
default:
assert(false);
}
}
break;
}
-#if PANGO_SUPPORT
case FONT_TYPE_PANGO:
/* Render the text using Pango */
draw_text_pango(text, strlen(text),
drawable, root_visual_type, x, y, max_width, false);
return;
-#endif
default:
assert(false);
}
return 0;
case FONT_TYPE_XCB:
return predict_text_width_xcb(i3string_as_ucs2(text), i3string_get_num_glyphs(text));
-#if PANGO_SUPPORT
case FONT_TYPE_PANGO:
/* Calculate extents using Pango */
return predict_text_width_pango(i3string_as_utf8(text), i3string_get_num_bytes(text),
i3string_is_markup(text));
-#endif
default:
assert(false);
return 0;
#include <stdlib.h>
#include <string.h>
-#if PANGO_SUPPORT
#include <glib.h>
-#endif
#include "libi3.h"
* Escape pango markup characters in the given string.
*/
i3String *i3string_escape_markup(i3String *str) {
-#if PANGO_SUPPORT
const char *text = i3string_as_utf8(str);
char *escaped = g_markup_escape_text(text, -1);
i3String *result = i3string_from_utf8(escaped);
free(escaped);
return result;
-#else
- return str;
-#endif
}
/*
if (!font_is_pango())
return input;
-#if PANGO_SUPPORT
char *escaped = g_markup_escape_text(input, -1);
FREE(input);
return escaped;
-#endif
}
/*