diff --git a/awesome.c b/awesome.c index 01bd9696..ce0582e1 100644 --- a/awesome.c +++ b/awesome.c @@ -33,9 +33,6 @@ #include #include -#include -#include - #include #include "awesome.h" @@ -86,6 +83,7 @@ awesome_atexit(bool restart) xcb_aux_sync(globalconf.connection); /* Disconnect *after* closing lua */ + xcb_cursor_context_free(globalconf.cursor_ctx); xcb_disconnect(globalconf.connection); } @@ -377,21 +375,11 @@ main(int argc, char **argv) sigemptyset(&sa.sa_mask); sigaction(SIGSEGV, &sa, 0); - /* XLib sucks */ - XkbIgnoreExtension(True); - - /* X stuff */ - globalconf.display = XOpenDisplay(NULL); - if (globalconf.display == NULL) { - fatal("cannot open display"); - } - XSetEventQueueOwner(globalconf.display, XCBOwnsEventQueue); - globalconf.default_screen = XDefaultScreen(globalconf.display); - globalconf.connection = XGetXCBConnection(globalconf.display); /* We have no clue where the input focus is right now */ globalconf.focus.need_update = true; - /* Double checking that connection is good and operatable with xcb */ + /* X stuff */ + globalconf.connection = xcb_connect(NULL, &globalconf.default_screen); if(xcb_connection_has_error(globalconf.connection)) fatal("cannot open display"); @@ -419,6 +407,9 @@ main(int argc, char **argv) xcb_prefetch_extension_data(globalconf.connection, &xcb_xinerama_id); xcb_prefetch_extension_data(globalconf.connection, &xcb_shape_id); + if (xcb_cursor_context_new(globalconf.connection, globalconf.screen, &globalconf.cursor_ctx) < 0) + fatal("Failed to initialize xcb-cursor"); + /* Setup the main context */ g_main_context_set_poll_func(g_main_context_default(), &a_glib_poll); diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake index 2dc73b20..3839e9a3 100644 --- a/awesomeConfig.cmake +++ b/awesomeConfig.cmake @@ -133,8 +133,7 @@ pkg_check_modules(AWESOME_REQUIRED REQUIRED gdk-pixbuf-2.0 cairo x11 - x11-xcb - xcursor + xcb-cursor xcb-randr xcb-xtest xcb-xinerama diff --git a/common/xcursor.c b/common/xcursor.c index 1e6e24e1..c4c691df 100644 --- a/common/xcursor.c +++ b/common/xcursor.c @@ -22,6 +22,8 @@ #include "common/xcursor.h" #include "common/util.h" +#include + static char const * const xcursor_font[] = { [XC_X_cursor] = "X_cursor", @@ -129,17 +131,17 @@ xcursor_font_tostr(uint16_t c) /** Equivalent to 'XCreateFontCursor()', error are handled by the * default current error handler. - * \param conn The connection to the X server. + * \param ctx The xcb-cursor context. * \param cursor_font Type of cursor to use. * \return Allocated cursor font. */ xcb_cursor_t -xcursor_new(Display *conn, uint16_t cursor_font) +xcursor_new(xcb_cursor_context_t *ctx, uint16_t cursor_font) { static xcb_cursor_t xcursor[countof(xcursor_font)]; if (!xcursor[cursor_font]) { - xcursor[cursor_font] = XcursorLibraryLoadCursor(conn, xcursor_font_tostr(cursor_font)); + xcursor[cursor_font] = xcb_cursor_load_cursor(ctx, xcursor_font_tostr(cursor_font)); } return xcursor[cursor_font]; diff --git a/common/xcursor.h b/common/xcursor.h index fa465682..ef56893b 100644 --- a/common/xcursor.h +++ b/common/xcursor.h @@ -22,14 +22,12 @@ #ifndef AWESOME_COMMON_XCURSORS_H #define AWESOME_COMMON_XCURSORS_H -#include #include - -#include +#include uint16_t xcursor_font_fromstr(const char *); const char * xcursor_font_tostr(uint16_t); -xcb_cursor_t xcursor_new(Display *, uint16_t); +xcb_cursor_t xcursor_new(xcb_cursor_context_t *, uint16_t); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/globalconf.h b/globalconf.h index 7c725a82..ca8c4a3f 100644 --- a/globalconf.h +++ b/globalconf.h @@ -29,6 +29,7 @@ #include #include +#include #include "objects/key.h" #include "color.h" @@ -64,12 +65,12 @@ ARRAY_TYPE(drawin_t *, drawin) /** Main configuration structure */ typedef struct { - /** Xlib Display */ - Display * display; /** Connection ref */ xcb_connection_t *connection; /** Default screen number */ int default_screen; + /** xcb-cursor context */ + xcb_cursor_context_t *cursor_ctx; /** Keys symbol table */ xcb_key_symbols_t *keysyms; /** Logical screens */ diff --git a/mousegrabber.c b/mousegrabber.c index 98f14ea3..35d87dda 100644 --- a/mousegrabber.c +++ b/mousegrabber.c @@ -94,7 +94,7 @@ luaA_mousegrabber_run(lua_State *L) if(cfont) { - xcb_cursor_t cursor = xcursor_new(globalconf.display, cfont); + xcb_cursor_t cursor = xcursor_new(globalconf.cursor_ctx, cfont); luaA_registerfct(L, 1, &globalconf.mousegrabber); diff --git a/objects/drawin.c b/objects/drawin.c index 54e1a333..b570211c 100644 --- a/objects/drawin.c +++ b/objects/drawin.c @@ -142,7 +142,7 @@ drawin_init(drawin_t *w) | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_PROPERTY_CHANGE, globalconf.default_cmap, - xcursor_new(globalconf.display, xcursor_font_fromstr(w->cursor)) + xcursor_new(globalconf.cursor_ctx, xcursor_font_fromstr(w->cursor)) }); /* Set the right properties */ @@ -502,7 +502,7 @@ luaA_drawin_set_cursor(lua_State *L, drawin_t *drawin) uint16_t cursor_font = xcursor_font_fromstr(buf); if(cursor_font) { - xcb_cursor_t cursor = xcursor_new(globalconf.display, cursor_font); + xcb_cursor_t cursor = xcursor_new(globalconf.cursor_ctx, cursor_font); p_delete(&drawin->cursor); drawin->cursor = a_strdup(buf); xwindow_set_cursor(drawin->window, cursor); diff --git a/root.c b/root.c index 64aac64a..7d94622a 100644 --- a/root.c +++ b/root.c @@ -303,7 +303,7 @@ luaA_root_cursor(lua_State *L) if(cursor_font) { - uint32_t change_win_vals[] = { xcursor_new(globalconf.display, cursor_font) }; + uint32_t change_win_vals[] = { xcursor_new(globalconf.cursor_ctx, cursor_font) }; xcb_change_window_attributes(globalconf.connection, globalconf.screen->root,