From 62b33b6964d23470b53afda7b81e6bd8730e59d7 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 22 Jun 2012 13:21:35 +0100 Subject: [PATCH] compositor-x11: Add base XCB/XKB support Try to find the XKB extension, to be used in later commits. Signed-off-by: Daniel Stone --- configure.ac | 20 +++++++++++++++++++- src/compositor-x11.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ce97486..b616e77 100644 --- a/configure.ac +++ b/configure.ac @@ -65,8 +65,26 @@ if test x$enable_x11_compositor = xyes; then LIBS=$xcb_save_LIBS CFLAGS=$xcb_save_CFLAGS + X11_COMPOSITOR_MODULES="x11 x11-xcb" + + PKG_CHECK_MODULES(X11_COMPOSITOR_XKB, [xcb-xkb], + [have_xcb_xkb="yes"], [have_xcb_xkb="no"]) + if test "x$have_xcb_xkb" = xyes; then + # Most versions of XCB have totally broken XKB bindings, where the + # events don't work. Make sure we can actually use them. + xcb_xkb_save_CFLAGS=$CFLAGS + CFLAGS=$X11_COMPOSITOR_XKB_CFLAGS + AC_CHECK_MEMBER([struct xcb_xkb_state_notify_event_t.xkbType], + [], [have_xcb_xkb=no], [[#include ]]) + CFLAGS=$xcb_xkb_save_CFLAGS + fi + if test "x$have_xcb_xkb" = xyes; then + X11_COMPOSITOR_MODULES="$X11_COMPOSITOR_MODULES xcb-xkb" + AC_DEFINE([HAVE_XCB_XKB], [1], [libxcb supports XKB protocol]) + fi + + PKG_CHECK_MODULES(X11_COMPOSITOR, [$X11_COMPOSITOR_MODULES]) AC_DEFINE([BUILD_X11_COMPOSITOR], [1], [Build the X11 compositor]) - PKG_CHECK_MODULES(X11_COMPOSITOR, [x11 x11-xcb]) fi diff --git a/src/compositor-x11.c b/src/compositor-x11.c index d8dbacb..7f0e6bd 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -35,6 +35,10 @@ #include #include +#ifdef HAVE_XCB_XKB +#include +#endif + #include #include @@ -59,6 +63,8 @@ struct x11_compositor { struct wl_array keys; struct wl_event_source *xcb_source; struct xkb_keymap *xkb_keymap; + unsigned int has_xkb; + uint8_t xkb_event_base; struct { xcb_atom_t wm_protocols; xcb_atom_t wm_normal_hints; @@ -132,6 +138,31 @@ x11_compositor_get_keymap(struct x11_compositor *c) return ret; } +static void +x11_compositor_setup_xkb(struct x11_compositor *c) +{ +#ifndef HAVE_XCB_XKB + weston_log("XCB-XKB not available during build\n"); + c->has_xkb = 0; + c->xkb_event_base = 0; + return; +#else + const xcb_query_extension_reply_t *ext; + + c->has_xkb = 0; + c->xkb_event_base = 0; + + ext = xcb_get_extension_data(c->conn, &xcb_xkb_id); + if (!ext) { + weston_log("XKB extension not available on host X11 server\n"); + return; + } + c->xkb_event_base = ext->first_event; + + c->has_xkb = 1; +#endif +} + static int x11_input_create(struct x11_compositor *c, int no_input) { @@ -151,6 +182,8 @@ x11_input_create(struct x11_compositor *c, int no_input) weston_seat_init_pointer(&input->base); + x11_compositor_setup_xkb(c); + keymap = x11_compositor_get_keymap(c); weston_seat_init_keyboard(&input->base, keymap); if (keymap) -- 2.7.4