]> git.sur5r.net Git - i3/i3/blobdiff - src/xcursor.c
Bugfix: Set the cursor via the Xlib connection if XCursor is supported
[i3/i3] / src / xcursor.c
index 54ef34d219f397105eac758d412cfaa267db9f23..69518c3073621451bb65cb8ba0bef9f0c69620be 100644 (file)
@@ -28,7 +28,23 @@ 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");
+}
 
+/*
+ * 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() {
+    XSetWindowAttributes attributes;
+    attributes.cursor = xcursor_get_cursor(XCURSOR_CURSOR_POINTER);
+    XChangeWindowAttributes(xlibdpy, DefaultRootWindow(xlibdpy), CWCursor, &attributes);
     XFlush(xlibdpy);
 }