]> git.sur5r.net Git - i3/i3/blobdiff - src/xcursor.c
Revert "raise fullscreen windows on top of all other X11 windows"
[i3/i3] / src / xcursor.c
index ee77d0c1d48c8581550e7cd64952132f3d34fe4c..90fd69dd237a67cc7470f238af33a693e6175aad 100644 (file)
@@ -1,5 +1,13 @@
+#undef I3__FILE__
+#define I3__FILE__ "xcursor.c"
 /*
  * vim:ts=4:sw=4:expandtab
+ *
+ * i3 - an improved dynamic tiling window manager
+ * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
+ *
+ * xcursor.c: libXcursor support for themed cursors.
+ *
  */
 #include <assert.h>
 #include <X11/Xcursor/Xcursor.h>
@@ -14,7 +22,8 @@ static Cursor cursors[XCURSOR_CURSOR_MAX];
 static const int xcb_cursors[XCURSOR_CURSOR_MAX] = {
     XCB_CURSOR_LEFT_PTR,
     XCB_CURSOR_SB_H_DOUBLE_ARROW,
-    XCB_CURSOR_SB_V_DOUBLE_ARROW
+    XCB_CURSOR_SB_V_DOUBLE_ARROW,
+    XCB_CURSOR_WATCH
 };
 
 static Cursor load_cursor(const char *name) {
@@ -24,10 +33,34 @@ static Cursor load_cursor(const char *name) {
     return c;
 }
 
-void xcursor_load_cursors() {
-    cursors[XCURSOR_CURSOR_POINTER] = load_cursor("left_ptr");
-    cursors[XCURSOR_CURSOR_RESIZE_HORIZONTAL] = load_cursor("sb_h_double_arrow");
-    cursors[XCURSOR_CURSOR_RESIZE_VERTICAL] = load_cursor("sb_v_double_arrow");
+void xcursor_load_cursors(void) {
+    cursors[XCURSOR_CURSOR_POINTER]             = load_cursor("left_ptr");
+    cursors[XCURSOR_CURSOR_RESIZE_HORIZONTAL]   = load_cursor("sb_h_double_arrow");
+    cursors[XCURSOR_CURSOR_RESIZE_VERTICAL]     = load_cursor("sb_v_double_arrow");
+    cursors[XCURSOR_CURSOR_WATCH]               = load_cursor("watch");
+    cursors[XCURSOR_CURSOR_MOVE]                = load_cursor("fleur");
+    cursors[XCURSOR_CURSOR_TOP_LEFT_CORNER]     = load_cursor("top_left_corner");
+    cursors[XCURSOR_CURSOR_TOP_RIGHT_CORNER]    = load_cursor("top_right_corner");
+    cursors[XCURSOR_CURSOR_BOTTOM_LEFT_CORNER]  = load_cursor("bottom_left_corner");
+    cursors[XCURSOR_CURSOR_BOTTOM_RIGHT_CORNER] = load_cursor("bottom_right_corner");
+}
+
+/*
+ * Sets the cursor of the root window to the 'pointer' cursor.
+ *
+ * This function is called when i3 is initialized, because with some login
+ * managers, the root window will not have a cursor otherwise.
+ *
+ * We have a separate xcursor function to use the same X11 connection as the
+ * xcursor_load_cursors() function. If we mix the Xlib and the XCB connection,
+ * races might occur (even though we flush the Xlib connection).
+ *
+ */
+void xcursor_set_root_cursor(int cursor_id) {
+    XSetWindowAttributes attributes;
+    attributes.cursor = xcursor_get_cursor(cursor_id);
+    XChangeWindowAttributes(xlibdpy, DefaultRootWindow(xlibdpy), CWCursor, &attributes);
+    XFlush(xlibdpy);
 }
 
 Cursor xcursor_get_cursor(enum xcursor_cursor_t c) {