]> git.sur5r.net Git - i3/i3/blobdiff - include/libi3.h
Merge pull request #2350 from madroach/OpenBSD
[i3/i3] / include / libi3.h
index 08b0140280b9d996a93c8bbb063b0f659ae8f749..da5ad891ee7e7da9b69bbb46804d5d6cbd32ed56 100644 (file)
 #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.
  *
@@ -385,11 +392,24 @@ char *convert_ucs2_to_utf8(xcb_char2b_t *text, size_t num_glyphs);
  */
 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.
@@ -484,7 +504,21 @@ char *get_config_path(const char *override_configpath, bool use_system_paths);
 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)  \
@@ -494,19 +528,6 @@ int mkdirp(const char *path, mode_t mode);
     } while (0)
 #endif
 
-/* 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})
-
 /* A wrapper grouping an XCB drawable and both a graphics context
  * and the corresponding cairo objects representing it. */
 typedef struct surface_t {
@@ -521,7 +542,7 @@ typedef struct surface_t {
     int width;
     int height;
 
-#ifdef CAIRO_SUPPORT
+#if CAIRO_SUPPORT
     /* A cairo surface representing the drawable. */
     cairo_surface_t *surface;