Well I tried...
static void testCookie (xcb_void_cookie_t cookie, xcb_connection_t *connection, char *errMessage )
{
xcb_generic_error_t *error = xcb_request_check (connection, cookie);
if (error) {
std::cout << std::string(errMessage) << std::endl;
xcb_disconnect (connection);
exit (-1);
}
}
void WindowImplX11::setMouseCursor(int cursorId)
{
xcb_font_t font = xcb_generate_id (m_connection);
xcb_void_cookie_t fontCookie = xcb_open_font_checked (m_connection,
font,
strlen ("cursor"),
"cursor" );
testCookie (fontCookie, m_connection, "can't open font");
xcb_cursor_t cursor = xcb_generate_id (m_connection);
xcb_create_glyph_cursor (m_connection,
cursor,
font,
font,
cursorId,
cursorId + 1,
0, 0, 0, 0, 0, 0 );
xcb_gcontext_t gc = xcb_generate_id (m_connection);
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
uint32_t values_list[3];
values_list[0] = m_screen->black_pixel;
values_list[1] = m_screen->white_pixel;
values_list[2] = font;
xcb_void_cookie_t gcCookie = xcb_create_gc_checked (m_connection, gc, m_window, mask, values_list);
testCookie (gcCookie, m_connection, "can't create gc");
mask = XCB_CW_CURSOR;
uint32_t value_list = cursor;
xcb_change_window_attributes (m_connection, m_window, mask, &value_list);
xcb_free_cursor (m_connection, cursor);
fontCookie = xcb_close_font_checked (m_connection, font);
testCookie (fontCookie, m_connection, "can't close font");
xcb_flush(m_connection);
}
I tried modifying
http://xcb.freedesktop.org/tutorial/mousecursors/ but I can't get it to work. I'm not getting any changes in my cursor or any errors. I'm stumped...