]> git.sur5r.net Git - i3/i3/blobdiff - include/libi3.h
Merge branch 'master' into next
[i3/i3] / include / libi3.h
index 97383ba301ab010a5959a8b5d3aaabe5a4318b1c..54fa0cc730a6e4e83e174f6c2762aa4b20edae1d 100644 (file)
@@ -8,8 +8,8 @@
  * as i3-msg, i3-config-wizard, …
  *
  */
-#ifndef _LIBI3_H
-#define _LIBI3_H
+#ifndef I3_LIBI3_H
+#define I3_LIBI3_H
 
 #include <stdbool.h>
 #include <stdarg.h>
 #include <xcb/xproto.h>
 #include <xcb/xcb_keysyms.h>
 
+#if PANGO_SUPPORT
+#include <pango/pango.h>
+#endif
+
 /**
  * Opaque data structure for storing strings.
  *
@@ -33,23 +37,44 @@ typedef struct Font i3Font;
  *
  */
 struct Font {
-    /** The xcb-id for the font */
-    xcb_font_t id;
-
-    /** Font information gathered from the server */
-    xcb_query_font_reply_t *info;
-
-    /** Font table for this font (may be NULL) */
-    xcb_charinfo_t *table;
+    /** The type of font */
+    enum {
+        FONT_TYPE_NONE = 0,
+        FONT_TYPE_XCB,
+        FONT_TYPE_PANGO
+    } type;
 
     /** The height of the font, built from font_ascent + font_descent */
     int height;
+
+    union {
+        struct {
+            /** The xcb-id for the font */
+            xcb_font_t id;
+
+            /** Font information gathered from the server */
+            xcb_query_font_reply_t *info;
+
+            /** Font table for this font (may be NULL) */
+            xcb_charinfo_t *table;
+        } xcb;
+
+#if PANGO_SUPPORT
+        /** The pango font description */
+        PangoFontDescription *pango_desc;
+#endif
+    } specific;
 };
 
 /* Since this file also gets included by utilities which don’t use the i3 log
  * infrastructure, we define a fallback. */
+#if !defined(LOG)
+void verboselog(char *fmt, ...);
+#define LOG(fmt, ...) verboselog("[libi3] " __FILE__ " " fmt, ##__VA_ARGS__)
+#endif
 #if !defined(ELOG)
-#define ELOG(fmt, ...) fprintf(stderr, "ERROR: " fmt, ##__VA_ARGS__)
+void errorlog(char *fmt, ...);
+#define ELOG(fmt, ...) errorlog("[libi3] ERROR: " fmt, ##__VA_ARGS__)
 #endif
 
 /**
@@ -297,21 +322,31 @@ void set_font_colors(xcb_gcontext_t gc, uint32_t foreground, uint32_t background
  * specified coordinates (from the top left corner of the leftmost, uppermost
  * glyph) and using the provided gc.
  *
- * Text can be specified as UCS-2 or UTF-8. If it's specified as UCS-2, then
- * text_len must be the number of glyphs in the string. If it's specified as
- * UTF-8, then text_len must be the number of bytes in the string (not counting
- * the null terminator).
+ * Text must be specified as an i3String.
  *
  */
-void draw_text(char *text, size_t text_len, bool is_ucs2, xcb_drawable_t drawable,
+void draw_text(i3String *text, xcb_drawable_t drawable,
         xcb_gcontext_t gc, int x, int y, int max_width);
 
 /**
- * Predict the text width in pixels for the given text. Text can be specified
- * as UCS-2 or UTF-8.
+ * ASCII version of draw_text to print static strings.
  *
  */
-int predict_text_width(char *text, size_t text_len, bool is_ucs2);
+void draw_text_ascii(const char *text, xcb_drawable_t drawable,
+        xcb_gcontext_t gc, int x, int y, int max_width);
+
+/**
+ * Predict the text width in pixels for the given text. Text must be
+ * specified as an i3String.
+ *
+ */
+int predict_text_width(i3String *text);
+
+/**
+ * Returns the visual type associated with the given screen.
+ *
+ */
+xcb_visualtype_t *get_visualtype(xcb_screen_t *screen);
 
 /**
  * Returns true if this version of i3 is a debug build (anything which is not a
@@ -320,4 +355,10 @@ int predict_text_width(char *text, size_t text_len, bool is_ucs2);
  */
 bool is_debug_build() __attribute__((const));
 
+/**
+ * Returns the name of a temporary file with the specified prefix.
+ *
+ */
+char *get_process_filename(const char *prefix);
+
 #endif