#if PANGO_SUPPORT
#include <pango/pango.h>
#endif
-#ifdef CAIRO_SUPPORT
+#if CAIRO_SUPPORT
#include <cairo/cairo-xcb.h>
#endif
#define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
+/**
+ * XCB connection and root screen
+ *
+ */
+extern xcb_connection_t *conn;
+extern xcb_screen_t *root_screen;
+
/**
* Opaque data structure for storing strings.
*
*/
xcb_char2b_t *convert_utf8_to_ucs2(char *input, size_t *real_strlen);
+/* Represents a color split by color channel. */
+typedef struct color_t {
+ double red;
+ double green;
+ double blue;
+ double alpha;
+
+ /* The colorpixel we use for direct XCB calls. */
+ uint32_t colorpixel;
+} color_t;
+
+#define COLOR_TRANSPARENT ((color_t){.red = 0.0, .green = 0.0, .blue = 0.0, .colorpixel = 0})
+
/**
* Defines the colors to be used for the forthcoming draw_text calls.
*
*/
-void set_font_colors(xcb_gcontext_t gc, uint32_t foreground, uint32_t background);
+void set_font_colors(xcb_gcontext_t gc, color_t foreground, color_t background);
/**
* Returns true if and only if the current font is a pango font.
int mkdirp(const char *path, mode_t mode);
#endif
-#ifdef CAIRO_SUPPORT
+/** Helper structure for usage in format_placeholders(). */
+typedef struct placeholder_t {
+ /* The placeholder to be replaced, e.g., "%title". */
+ char *name;
+ /* The value this placeholder should be replaced with. */
+ char *value;
+} placeholder_t;
+
+/**
+ * Replaces occurrences of the defined placeholders in the format string.
+ *
+ */
+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) \
} while (0)
#endif
-/* Represents a color split by color channel. */
-typedef struct color_t {
- double red;
- double green;
- double blue;
-
- /* The colorpixel we use for direct XCB calls. */
- uint32_t colorpixel;
-} color_t;
-
/* A wrapper grouping an XCB drawable and both a graphics context
* and the corresponding cairo objects representing it. */
typedef struct surface_t {
int width;
int height;
-#ifdef CAIRO_SUPPORT
+#if CAIRO_SUPPORT
/* A cairo surface representing the drawable. */
cairo_surface_t *surface;