2010-11-28 07:02:29 -05:00
|
|
|
/*
|
|
|
|
* vim:ts=4:sw=4:expandtab
|
|
|
|
*/
|
2010-11-26 18:26:51 -05:00
|
|
|
#include <assert.h>
|
|
|
|
#include <X11/Xcursor/Xcursor.h>
|
|
|
|
#include <X11/cursorfont.h>
|
|
|
|
|
|
|
|
#include "i3.h"
|
|
|
|
#include "xcb.h"
|
|
|
|
#include "xcursor.h"
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2010-11-28 07:02:29 -05:00
|
|
|
static Cursor load_cursor(const char *name, int font) {
|
2010-11-26 18:26:51 -05:00
|
|
|
Cursor c = XcursorLibraryLoadCursor(xlibdpy, name);
|
|
|
|
if (c == None)
|
|
|
|
c = XCreateFontCursor(xlibdpy, font);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2010-11-28 07:02:29 -05:00
|
|
|
void xcursor_load_cursors() {
|
2010-11-26 18:26:51 -05:00
|
|
|
cursors[XCURSOR_CURSOR_POINTER] = load_cursor("left_ptr", XC_left_ptr);
|
|
|
|
cursors[XCURSOR_CURSOR_RESIZE_HORIZONTAL] = load_cursor("sb_h_double_arrow", XC_sb_h_double_arrow);
|
|
|
|
cursors[XCURSOR_CURSOR_RESIZE_VERTICAL] = load_cursor("sb_v_double_arrow", XC_sb_v_double_arrow);
|
|
|
|
}
|
|
|
|
|
2010-11-28 07:02:29 -05:00
|
|
|
Cursor xcursor_get_cursor(enum xcursor_cursor_t c) {
|
2010-11-26 18:26:51 -05:00
|
|
|
assert(c >= 0 && c < XCURSOR_CURSOR_MAX);
|
|
|
|
return cursors[c];
|
|
|
|
}
|
|
|
|
|
2010-11-28 07:02:29 -05:00
|
|
|
int xcursor_get_xcb_cursor(enum xcursor_cursor_t c) {
|
2010-11-26 18:26:51 -05:00
|
|
|
assert(c >= 0 && c < XCURSOR_CURSOR_MAX);
|
|
|
|
return xcb_cursors[c];
|
|
|
|
}
|