From 48e5bcbe7b37711247c96691666523f3b1f7452d Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 24 Sep 2014 13:39:55 +0200 Subject: [PATCH] vaapisink: fix GstNavigation "key-press" / "key-release" events. Fix arguments to XkbKeycodeToKeysym() for converting an X11 keycode to a KeySym. In particular, there is no such Window argument. Also make sure to check for, and use, the correct header where that new function is defined. Otherwise, default to the older XKeycodeToKeysym() function. --- configure.ac | 10 ++++++++++ gst/vaapi/gstvaapisink.c | 17 +++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 36285dc458..4cbfffd38a 100644 --- a/configure.ac +++ b/configure.ac @@ -559,6 +559,16 @@ if test "$enable_x11" = "yes"; then fi fi +dnl Check for XKB library +HAVE_XKBLIB=0 +if test $USE_X11 -eq 1; then + AC_CHECK_HEADERS([X11/XKBlib.h], [HAVE_XKBLIB=1], [:]) +fi +if test $HAVE_XKBLIB -eq 1; then + AC_DEFINE_UNQUOTED([HAVE_XKBLIB], 1, + [Defined to 1 if the XKB extension exists.]) +fi + dnl Check for XRandR HAVE_XRANDR=0 if test $USE_X11 -eq 1; then diff --git a/gst/vaapi/gstvaapisink.c b/gst/vaapi/gstvaapisink.c index 4bac224ba2..99791c9e37 100644 --- a/gst/vaapi/gstvaapisink.c +++ b/gst/vaapi/gstvaapisink.c @@ -218,6 +218,20 @@ gst_vaapisink_backend_drm (void) #include #include +#if HAVE_XKBLIB +# include +#endif + +static inline KeySym +x11_keycode_to_keysym (Display * dpy, unsigned int kc) +{ +#if HAVE_XKBLIB + return XkbKeycodeToKeysym (dpy, kc, 0, 0); +#else + return XKeycodeToKeysym (dpy, kc, 0); +#endif +} + /* Checks whether a ConfigureNotify event is in the queue */ typedef struct _ConfigureNotifyEventPendingArgs ConfigureNotifyEventPendingArgs; struct _ConfigureNotifyEventPendingArgs @@ -387,8 +401,7 @@ gst_vaapisink_x11_handle_events (GstVaapiSink * sink) case KeyPress: case KeyRelease: gst_vaapi_display_lock (display); - keysym = XkbKeycodeToKeysym (x11_dpy, x11_win, - e.xkey.keycode, 0, 0); + keysym = x11_keycode_to_keysym (x11_dpy, e.xkey.keycode); if (keysym != NoSymbol) { key_str = XKeysymToString (keysym); } else {