- 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");
+ if (xcb_cursor_context_new(conn, root_screen, &ctx) < 0) {
+ ELOG("xcursor support unavailable\n");
+ xcursor_supported = false;
+ return;
+ }
+#define LOAD_CURSOR(constant, name) \
+ do { \
+ cursors[constant] = xcb_cursor_load_cursor(ctx, name); \
+ } while (0)
+ LOAD_CURSOR(XCURSOR_CURSOR_POINTER, "left_ptr");
+ LOAD_CURSOR(XCURSOR_CURSOR_RESIZE_HORIZONTAL, "sb_h_double_arrow");
+ LOAD_CURSOR(XCURSOR_CURSOR_RESIZE_VERTICAL, "sb_v_double_arrow");
+ LOAD_CURSOR(XCURSOR_CURSOR_WATCH, "watch");
+ LOAD_CURSOR(XCURSOR_CURSOR_MOVE, "fleur");
+ LOAD_CURSOR(XCURSOR_CURSOR_TOP_LEFT_CORNER, "top_left_corner");
+ LOAD_CURSOR(XCURSOR_CURSOR_TOP_RIGHT_CORNER, "top_right_corner");
+ LOAD_CURSOR(XCURSOR_CURSOR_BOTTOM_LEFT_CORNER, "bottom_left_corner");
+ LOAD_CURSOR(XCURSOR_CURSOR_BOTTOM_RIGHT_CORNER, "bottom_right_corner");
+#undef LOAD_CURSOR