]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/cairo_util.c
When drawing text, mark the surface as dirty.
[i3/i3] / i3bar / src / cairo_util.c
index 288969c965fd9d9957f86e1f6ea4cdc97244aaf8..75a99d2fa04fe8f043bf99d20a0110780e0ae8fb 100644 (file)
@@ -80,3 +80,16 @@ color_t cairo_hex_to_color(const char *color) {
 void cairo_set_source_color(surface_t *surface, color_t color) {
     cairo_set_source_rgba(surface->cr, color.red, color.green, color.blue, color.alpha);
 }
+
+/**
+ * Draw the given text using libi3.
+ * This function also marks the surface dirty which is needed if other means of
+ * drawing are used. This will be the case when using XCB to draw text.
+ *
+ */
+void cairo_draw_text(i3String *text, surface_t *surface, color_t fg_color, color_t bg_color, int x, int y, int max_width) {
+    set_font_colors(surface->gc, fg_color.colorpixel, bg_color.colorpixel);
+    draw_text(text, surface->id, surface->gc, visual_type, x, y, max_width);
+
+    cairo_surface_mark_dirty(surface->surface);
+}