]> git.sur5r.net Git - i3/i3/commitdiff
Remove conditional compilation for cairo/pangocairo (#2480)
authorMichael Stapelberg <stapelberg@users.noreply.github.com>
Tue, 27 Sep 2016 19:57:00 +0000 (12:57 -0700)
committerGitHub <noreply@github.com>
Tue, 27 Sep 2016 19:57:00 +0000 (12:57 -0700)
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.

DEPENDS
common.mk
debian/control
include/libi3.h
libi3/draw_util.c
libi3/font.c
libi3/string.c
src/util.c

diff --git a/DEPENDS b/DEPENDS
index 227aaec373770f2c8c68c714a413773499bbee78..167827ff6a3db1110741289e3d99e36b658771d6 100644 (file)
--- a/DEPENDS
+++ b/DEPENDS
@@ -7,25 +7,25 @@
 ┌──────────────┬────────┬────────┬───────────────────────────────────────────────────────────┐
 │ 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
index 7df415eba09612195eb39d5d37fc8b0adceb9ce9..6032ce6ca913381f759789b13d393b53fafe9ce5 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -147,9 +147,8 @@ LIBSN_LIBS   := $(call ldflags_for_lib, libstartup-notification-1.0,startup-noti
 # 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)
index c1e655d8079aa1d2ef7268ec13c8c4e493cc06c6..5fa675c1baa89ed6983b15011898f42520c6ca53 100644 (file)
@@ -22,7 +22,7 @@ Build-Depends: debhelper (>= 9),
                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
index c1fe770b2f3d3cfb984a07528d6f98545aa3dd5f..5123ce01db6b151b86315fbc13a739e30293b206 100644 (file)
 #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)
 
@@ -73,10 +69,8 @@ struct Font {
             xcb_charinfo_t *table;
         } xcb;
 
-#if PANGO_SUPPORT
         /** The pango font description */
         PangoFontDescription *pango_desc;
-#endif
     } specific;
 };
 
@@ -525,7 +519,6 @@ typedef struct placeholder_t {
  */
 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)  \
@@ -533,7 +526,6 @@ char *format_placeholders(char *format, placeholder_t *placeholders, int num);
         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. */
@@ -549,14 +541,12 @@ typedef struct surface_t {
     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;
 
 /**
index b69d51b4018162050e74cc6383fa177bdfbc9adc..56b1bce8db882ee666a4c2e6fd069ef63d986c81 100644 (file)
@@ -11,9 +11,7 @@
 #include <string.h>
 #include <xcb/xcb.h>
 #include <xcb/xcb_aux.h>
-#if CAIRO_SUPPORT
 #include <cairo/cairo-xcb.h>
-#endif
 
 #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);
     }
 
-#if CAIRO_SUPPORT
     surface->surface = cairo_xcb_surface_create(conn, surface->id, surface->visual_type, width, height);
     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) {
     xcb_free_gc(conn, surface->gc);
-#if CAIRO_SUPPORT
     cairo_surface_destroy(surface->surface);
     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. */
     surface->surface = 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) {
     surface->width = width;
     surface->height = height;
-#if CAIRO_SUPPORT
     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) {
     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
 }
 
 /**
@@ -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) {
     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
 }
 
 /**
@@ -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) {
     RETURN_UNLESS_SURFACE_INITIALIZED(surface);
 
-#if CAIRO_SUPPORT
     cairo_save(surface->cr);
 
     /* 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_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) {
     RETURN_UNLESS_SURFACE_INITIALIZED(surface);
 
-#if CAIRO_SUPPORT
     cairo_save(surface->cr);
 
     /* 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_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(dest);
 
-#if CAIRO_SUPPORT
     cairo_save(dest->cr);
 
     /* 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_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
 }
index 00e7dfb30b4785f8ec6b0f8bc8a6a67d61c08aff..7c305e25b6f992afaf27441d39445319193c6a69 100644 (file)
 #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;
@@ -166,7 +163,6 @@ static int predict_text_width_pango(const char *text, size_t text_len, bool pang
 
     return width;
 }
-#endif
 
 /*
  * 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;
     }
 
-#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:");
@@ -202,7 +197,6 @@ i3Font load_font(const char *pattern, const bool fallback) {
             return font;
         }
     }
-#endif
 
     /* Send all our requests first */
     font.specific.xcb.id = xcb_generate_id(conn);
@@ -297,12 +291,10 @@ void free_font(void) {
                 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;
@@ -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);
             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;
@@ -348,11 +338,7 @@ void set_font_colors(xcb_gcontext_t gc, color_t foreground, color_t background)
  *
  */
 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);
@@ -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,
                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:
@@ -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),
                           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);
     }
@@ -450,13 +432,11 @@ void draw_text_ascii(const char *text, xcb_drawable_t drawable,
             }
             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);
     }
@@ -547,12 +527,10 @@ int predict_text_width(i3String *text) {
             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;
index 328b41c092c07b23b241f8455c023bba3ddd945d..19039a23564f4ac43948c3acba568900e3262f98 100644 (file)
@@ -13,9 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#if PANGO_SUPPORT
 #include <glib.h>
-#endif
 
 #include "libi3.h"
 
@@ -192,15 +190,11 @@ void i3string_set_markup(i3String *str, bool pango_markup) {
  * 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
 }
 
 /*
index d19f8c5ee07b0c216e1c4f980a47e4cdc80e667d..15796d887cb95edfd2595718835ed9aad72c4c9d 100644 (file)
@@ -327,12 +327,10 @@ char *pango_escape_markup(char *input) {
     if (!font_is_pango())
         return input;
 
-#if PANGO_SUPPORT
     char *escaped = g_markup_escape_text(input, -1);
     FREE(input);
 
     return escaped;
-#endif
 }
 
 /*