compositor-x11: Add base XCB/XKB support

Try to find the XKB extension, to be used in later commits.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 13 years ago committed by Kristian Høgsberg
parent 22815f9115
commit 62b33b6964
  1. 20
      configure.ac
  2. 33
      src/compositor-x11.c

@ -65,8 +65,26 @@ if test x$enable_x11_compositor = xyes; then
LIBS=$xcb_save_LIBS LIBS=$xcb_save_LIBS
CFLAGS=$xcb_save_CFLAGS 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 <xcb/xkb.h>]])
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]) AC_DEFINE([BUILD_X11_COMPOSITOR], [1], [Build the X11 compositor])
PKG_CHECK_MODULES(X11_COMPOSITOR, [x11 x11-xcb])
fi fi

@ -35,6 +35,10 @@
#include <linux/input.h> #include <linux/input.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
#ifdef HAVE_XCB_XKB
#include <xcb/xkb.h>
#endif
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xlib-xcb.h> #include <X11/Xlib-xcb.h>
@ -59,6 +63,8 @@ struct x11_compositor {
struct wl_array keys; struct wl_array keys;
struct wl_event_source *xcb_source; struct wl_event_source *xcb_source;
struct xkb_keymap *xkb_keymap; struct xkb_keymap *xkb_keymap;
unsigned int has_xkb;
uint8_t xkb_event_base;
struct { struct {
xcb_atom_t wm_protocols; xcb_atom_t wm_protocols;
xcb_atom_t wm_normal_hints; xcb_atom_t wm_normal_hints;
@ -132,6 +138,31 @@ x11_compositor_get_keymap(struct x11_compositor *c)
return ret; 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 static int
x11_input_create(struct x11_compositor *c, int no_input) 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); weston_seat_init_pointer(&input->base);
x11_compositor_setup_xkb(c);
keymap = x11_compositor_get_keymap(c); keymap = x11_compositor_get_keymap(c);
weston_seat_init_keyboard(&input->base, keymap); weston_seat_init_keyboard(&input->base, keymap);
if (keymap) if (keymap)

Loading…
Cancel
Save