]> git.sur5r.net Git - i3/i3/commitdiff
libi3: Introduce get_visualtype
authorFernando Tarlá Cardoso Lemos <fernandotcl@gmail.com>
Mon, 14 Nov 2011 23:39:03 +0000 (21:39 -0200)
committerQuentin Glidic <sardemff7+git@sardemff7.net>
Mon, 13 Aug 2012 09:37:34 +0000 (11:37 +0200)
include/libi3.h
libi3/get_visualtype.c [new file with mode: 0644]

index 01b9992ba008ae194c693a008b750ce3679d44a1..eb573eb08c417c1b8ef376f976be7d57465494ee 100644 (file)
@@ -317,6 +317,12 @@ void draw_text_ascii(const char *text, xcb_drawable_t drawable,
  */
 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
  * release version), based on the git version number.
diff --git a/libi3/get_visualtype.c b/libi3/get_visualtype.c
new file mode 100644 (file)
index 0000000..d11722f
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * vim:ts=4:sw=4:expandtab
+ *
+ * i3 - an improved dynamic tiling window manager
+ * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
+ *
+ */
+#include "libi3.h"
+
+/*
+ * Returns the visual type associated with the given screen.
+ *
+ */
+xcb_visualtype_t *get_visualtype(xcb_screen_t *screen) {
+    xcb_depth_iterator_t depth_iter;
+    for (depth_iter = xcb_screen_allowed_depths_iterator(screen);
+         depth_iter.rem;
+         xcb_depth_next(&depth_iter)) {
+        xcb_visualtype_iterator_t visual_iter;
+        for (visual_iter = xcb_depth_visuals_iterator(depth_iter.data);
+             visual_iter.rem;
+             xcb_visualtype_next(&visual_iter)) {
+            if (screen->root_visual == visual_iter.data->visual_id)
+                return visual_iter.data;
+        }
+    }
+    return NULL;
+}