Switch from libXcursor to libxcb-cursor
Thanks to Michael Stapelberg, there is now a xcb-only port of libXcursor which does everything we need. This patch switches awesome over to that new library. Since the only reason for using XOpenDisplay() instead of xcb_connect() was so that we can use libXcursor, we can get back to that older state again. This means that this effectively reverts the following commits:531f8b415c
"Added initial support for Xlib cursor themes"77243cd09a
"Add x11-xcb to the pkg-config checks"779d43fc46
"Don't let Xlib own the event queue"03759b4847
"Fix keyboard layouts" Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
d82342e386
commit
aaa771f887
21
awesome.c
21
awesome.c
|
@ -33,9 +33,6 @@
|
||||||
#include <xcb/xtest.h>
|
#include <xcb/xtest.h>
|
||||||
#include <xcb/shape.h>
|
#include <xcb/shape.h>
|
||||||
|
|
||||||
#include <X11/Xlib-xcb.h>
|
|
||||||
#include <X11/XKBlib.h>
|
|
||||||
|
|
||||||
#include <glib-unix.h>
|
#include <glib-unix.h>
|
||||||
|
|
||||||
#include "awesome.h"
|
#include "awesome.h"
|
||||||
|
@ -86,6 +83,7 @@ awesome_atexit(bool restart)
|
||||||
xcb_aux_sync(globalconf.connection);
|
xcb_aux_sync(globalconf.connection);
|
||||||
|
|
||||||
/* Disconnect *after* closing lua */
|
/* Disconnect *after* closing lua */
|
||||||
|
xcb_cursor_context_free(globalconf.cursor_ctx);
|
||||||
xcb_disconnect(globalconf.connection);
|
xcb_disconnect(globalconf.connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,21 +375,11 @@ main(int argc, char **argv)
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGSEGV, &sa, 0);
|
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 */
|
/* We have no clue where the input focus is right now */
|
||||||
globalconf.focus.need_update = true;
|
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))
|
if(xcb_connection_has_error(globalconf.connection))
|
||||||
fatal("cannot open display");
|
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_xinerama_id);
|
||||||
xcb_prefetch_extension_data(globalconf.connection, &xcb_shape_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 */
|
/* Setup the main context */
|
||||||
g_main_context_set_poll_func(g_main_context_default(), &a_glib_poll);
|
g_main_context_set_poll_func(g_main_context_default(), &a_glib_poll);
|
||||||
|
|
||||||
|
|
|
@ -133,8 +133,7 @@ pkg_check_modules(AWESOME_REQUIRED REQUIRED
|
||||||
gdk-pixbuf-2.0
|
gdk-pixbuf-2.0
|
||||||
cairo
|
cairo
|
||||||
x11
|
x11
|
||||||
x11-xcb
|
xcb-cursor
|
||||||
xcursor
|
|
||||||
xcb-randr
|
xcb-randr
|
||||||
xcb-xtest
|
xcb-xtest
|
||||||
xcb-xinerama
|
xcb-xinerama
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "common/xcursor.h"
|
#include "common/xcursor.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
|
||||||
|
#include <X11/cursorfont.h>
|
||||||
|
|
||||||
static char const * const xcursor_font[] =
|
static char const * const xcursor_font[] =
|
||||||
{
|
{
|
||||||
[XC_X_cursor] = "X_cursor",
|
[XC_X_cursor] = "X_cursor",
|
||||||
|
@ -129,17 +131,17 @@ xcursor_font_tostr(uint16_t c)
|
||||||
|
|
||||||
/** Equivalent to 'XCreateFontCursor()', error are handled by the
|
/** Equivalent to 'XCreateFontCursor()', error are handled by the
|
||||||
* default current error handler.
|
* 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.
|
* \param cursor_font Type of cursor to use.
|
||||||
* \return Allocated cursor font.
|
* \return Allocated cursor font.
|
||||||
*/
|
*/
|
||||||
xcb_cursor_t
|
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)];
|
static xcb_cursor_t xcursor[countof(xcursor_font)];
|
||||||
|
|
||||||
if (!xcursor[cursor_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];
|
return xcursor[cursor_font];
|
||||||
|
|
|
@ -22,14 +22,12 @@
|
||||||
#ifndef AWESOME_COMMON_XCURSORS_H
|
#ifndef AWESOME_COMMON_XCURSORS_H
|
||||||
#define AWESOME_COMMON_XCURSORS_H
|
#define AWESOME_COMMON_XCURSORS_H
|
||||||
|
|
||||||
#include <X11/cursorfont.h>
|
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
#include <xcb/xcb_cursor.h>
|
||||||
#include <X11/Xcursor/Xcursor.h>
|
|
||||||
|
|
||||||
uint16_t xcursor_font_fromstr(const char *);
|
uint16_t xcursor_font_fromstr(const char *);
|
||||||
const char * xcursor_font_tostr(uint16_t);
|
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
|
#endif
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <xcb/xcb_icccm.h>
|
#include <xcb/xcb_icccm.h>
|
||||||
#include <xcb/xcb_keysyms.h>
|
#include <xcb/xcb_keysyms.h>
|
||||||
|
#include <xcb/xcb_cursor.h>
|
||||||
|
|
||||||
#include "objects/key.h"
|
#include "objects/key.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
|
@ -64,12 +65,12 @@ ARRAY_TYPE(drawin_t *, drawin)
|
||||||
/** Main configuration structure */
|
/** Main configuration structure */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/** Xlib Display */
|
|
||||||
Display * display;
|
|
||||||
/** Connection ref */
|
/** Connection ref */
|
||||||
xcb_connection_t *connection;
|
xcb_connection_t *connection;
|
||||||
/** Default screen number */
|
/** Default screen number */
|
||||||
int default_screen;
|
int default_screen;
|
||||||
|
/** xcb-cursor context */
|
||||||
|
xcb_cursor_context_t *cursor_ctx;
|
||||||
/** Keys symbol table */
|
/** Keys symbol table */
|
||||||
xcb_key_symbols_t *keysyms;
|
xcb_key_symbols_t *keysyms;
|
||||||
/** Logical screens */
|
/** Logical screens */
|
||||||
|
|
|
@ -94,7 +94,7 @@ luaA_mousegrabber_run(lua_State *L)
|
||||||
|
|
||||||
if(cfont)
|
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);
|
luaA_registerfct(L, 1, &globalconf.mousegrabber);
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ drawin_init(drawin_t *w)
|
||||||
| XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE
|
| XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE
|
||||||
| XCB_EVENT_MASK_PROPERTY_CHANGE,
|
| XCB_EVENT_MASK_PROPERTY_CHANGE,
|
||||||
globalconf.default_cmap,
|
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 */
|
/* 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);
|
uint16_t cursor_font = xcursor_font_fromstr(buf);
|
||||||
if(cursor_font)
|
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);
|
p_delete(&drawin->cursor);
|
||||||
drawin->cursor = a_strdup(buf);
|
drawin->cursor = a_strdup(buf);
|
||||||
xwindow_set_cursor(drawin->window, cursor);
|
xwindow_set_cursor(drawin->window, cursor);
|
||||||
|
|
2
root.c
2
root.c
|
@ -303,7 +303,7 @@ luaA_root_cursor(lua_State *L)
|
||||||
|
|
||||||
if(cursor_font)
|
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,
|
xcb_change_window_attributes(globalconf.connection,
|
||||||
globalconf.screen->root,
|
globalconf.screen->root,
|
||||||
|
|
Loading…
Reference in New Issue