[vlc-devel] [vlc-commits] xcb/window: inline key events handling

Zhao Zhili quinkblack at foxmail.com
Thu May 24 03:52:30 CEST 2018



On 2018年05月24日 03:24, Rémi Denis-Courmont wrote:
> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May 23 21:52:20 2018 +0300| [b0142d197c3d5b242c825a8751fb914b0574e28b] | committer: Rémi Denis-Courmont
>
> xcb/window: inline key events handling
>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b0142d197c3d5b242c825a8751fb914b0574e28b
> ---
>
>   modules/video_output/Makefile.am           |  2 +-
>   modules/video_output/xcb/events.h          |  7 ---
>   modules/video_output/xcb/window.c          | 49 +++++++++++++++--
>   modules/video_output/xcb/{keys.c => xkb.c} | 85 ++++--------------------------
>   4 files changed, 55 insertions(+), 88 deletions(-)
>
> diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
> index c44c1331c8..4a33e11fca 100644
> --- a/modules/video_output/Makefile.am
> +++ b/modules/video_output/Makefile.am
> @@ -168,7 +168,7 @@ vout_LTLIBRARIES += libxcb_x11_plugin.la libxcb_window_plugin.la
>   if HAVE_XCB_KEYSYMS
>   libxcb_window_plugin_la_SOURCES += \
>   	video_output/xcb/keysym.h video_output/xcb/xcb_keysym.h \
> -	video_output/xcb/keys.c
> +	video_output/xcb/vlc_xkb.h video_output/xcb/xkb.c

vlc_xkb.h is not added to git?

../../vlc/modules/video_output/xcb/window.c:36:22: fatal error: 
vlc_xkb.h: No such file or directory
compilation terminated.
Makefile:21981: recipe for target 
'video_output/xcb/libxcb_window_plugin_la-window.lo' failed
make[4]: *** [video_output/xcb/libxcb_window_plugin_la-window.lo] Error 1
make[4]: *** Waiting for unfinished jobs....
../../vlc/modules/video_output/xcb/xkb.c:33:38: fatal error: 
video_output/xcb/vlc_xkb.h: No such file or directory
compilation terminated.

>   libxcb_window_plugin_la_CFLAGS += -DHAVE_XCB_KEYSYMS
>   endif
>   if HAVE_XCB_XVIDEO
> diff --git a/modules/video_output/xcb/events.h b/modules/video_output/xcb/events.h
> index 868da8bbf4..91f4595061 100644
> --- a/modules/video_output/xcb/events.h
> +++ b/modules/video_output/xcb/events.h
> @@ -26,13 +26,6 @@
>   
>   #include <vlc_vout_display.h>
>   
> -#ifdef HAVE_XCB_KEYSYMS
> -# include <xcb/xcb_keysyms.h>
> -/* keys.c */
> -int XCB_keyHandler_Process(xcb_key_symbols_t *, xcb_generic_event_t *,
> -                           vout_window_t *);
> -#endif
> -
>   /* events.c */
>   
>   /**
> diff --git a/modules/video_output/xcb/window.c b/modules/video_output/xcb/window.c
> index 4648a24741..1e4eae8a06 100644
> --- a/modules/video_output/xcb/window.c
> +++ b/modules/video_output/xcb/window.c
> @@ -31,6 +31,10 @@
>   #include <limits.h> /* _POSIX_HOST_NAME_MAX */
>   
>   #include <xcb/xcb.h>
> +#ifdef HAVE_XCB_KEYSYMS
> +# include <xcb/xcb_keysyms.h>
> +# include "vlc_xkb.h"
> +#endif
>   typedef xcb_atom_t Atom;
>   #include <X11/Xatom.h> /* XA_WM_NAME */
>   
> @@ -72,13 +76,42 @@ static int ProcessEvent(vout_window_t *wnd, xcb_generic_event_t *ev)
>       vout_window_sys_t *sys = wnd->sys;
>       int ret = 0;
>   
> +    switch (ev->response_type & 0x7f)
> +    {
> +        case XCB_KEY_PRESS:
> +        {
>   #ifdef HAVE_XCB_KEYSYMS
> -    if (sys->keys != NULL && XCB_keyHandler_Process(sys->keys, ev, wnd) == 0)
> -        return 0;
> +            xcb_key_press_event_t *e = (xcb_key_press_event_t *)ev;
> +            xcb_keysym_t sym = xcb_key_press_lookup_keysym(sys->keys, e, 0);
> +            uint_fast32_t vk = vlc_xkb_convert_keysym(sym);
> +
> +            msg_Dbg(wnd, "key: 0x%08"PRIxFAST32" (X11: 0x%04"PRIx32")",
> +                    vk, sym);
> +            if (vk == KEY_UNSET)
> +                break;
> +            if (e->state & XCB_MOD_MASK_SHIFT) /* Shift */
> +                vk |= KEY_MODIFIER_SHIFT;
> +            /* XCB_MOD_MASK_LOCK */ /* Caps Lock */
> +            if (e->state & XCB_MOD_MASK_CONTROL) /* Control */
> +                vk |= KEY_MODIFIER_CTRL;
> +            if (e->state & XCB_MOD_MASK_1) /* Alternate */
> +                vk |= KEY_MODIFIER_ALT;
> +            /* XCB_MOD_MASK_2 */ /* Numeric Pad Lock */
> +            if (e->state & XCB_MOD_MASK_3) /* Super */
> +                vk |= KEY_MODIFIER_META;
> +            if (e->state & XCB_MOD_MASK_4) /* Meta */
> +                vk |= KEY_MODIFIER_META;
> +            if (e->state & XCB_MOD_MASK_5) /* Alternate Graphic */
> +                vk |= KEY_MODIFIER_ALT;
> +
> +            vout_window_ReportKeyPress(wnd, vk);
>   #endif
> +            break;
> +        }
> +
> +        case XCB_KEY_RELEASE:
> +            break;
>   
> -    switch (ev->response_type & 0x7f)
> -    {
>           /* Note a direct mapping of buttons from XCB to VLC is assumed. */
>           case XCB_BUTTON_PRESS:
>           {
> @@ -118,7 +151,15 @@ static int ProcessEvent(vout_window_t *wnd, xcb_generic_event_t *ev)
>               break;
>   
>           case XCB_MAPPING_NOTIFY:
> +        {
> +#ifdef HAVE_XCB_KEYSYMS
> +            xcb_mapping_notify_event_t *e = (xcb_mapping_notify_event_t *)ev;
> +
> +            msg_Dbg(wnd, "refreshing keyboard mapping");
> +            xcb_refresh_keyboard_mapping(sys->keys, e);
> +#endif
>               break;
> +        }
>   
>           default:
>               msg_Dbg (wnd, "unhandled event %"PRIu8, ev->response_type);
> diff --git a/modules/video_output/xcb/keys.c b/modules/video_output/xcb/xkb.c
> similarity index 51%
> rename from modules/video_output/xcb/keys.c
> rename to modules/video_output/xcb/xkb.c
> index 5b71e65c36..bbc8920283 100644
> --- a/modules/video_output/xcb/keys.c
> +++ b/modules/video_output/xcb/xkb.c
> @@ -1,6 +1,6 @@
>   /**
> - * @file keys.c
> - * @brief X C Bindings VLC keyboard event handling
> + * @file xkb.c
> + * @brief XKeyboard symbols mapping for VLC
>    */
>   /*****************************************************************************
>    * Copyright © 2009 Rémi Denis-Courmont
> @@ -25,31 +25,26 @@
>   #endif
>   
>   #include <stdlib.h>
> -#include <inttypes.h>
> -#include <assert.h>
> -
> -#include <xcb/xcb.h>
> -#include <vlc_common.h>
> -#include "events.h"
> -
> -#include <xcb/xcb_keysyms.h>
> +#include <stdint.h>
>   #include <X11/keysym.h>
>   #include <X11/XF86keysym.h>
> +#include <vlc_common.h>
>   #include <vlc_actions.h>
> +#include "video_output/xcb/vlc_xkb.h"
>   
>   static int keysymcmp (const void *pa, const void *pb)
>   {
> -    int a = *(const xcb_keysym_t *)pa;
> -    int b = *(const xcb_keysym_t *)pb;
> +    int a = *(const uint32_t *)pa;
> +    int b = *(const uint32_t *)pb;
>   
>       return a - b;
>   }
>   
> -static uint_fast32_t ConvertKeySym (xcb_keysym_t sym)
> +uint_fast32_t vlc_xkb_convert_keysym(uint_fast32_t sym)
>   {
>       static const struct
>       {
> -        xcb_keysym_t x11;
> +        uint32_t x11;
>           uint32_t vlc;
>       } *res, tab[] = {
>   #include "xcb_keysym.h"
> @@ -94,65 +89,3 @@ static uint_fast32_t ConvertKeySym (xcb_keysym_t sym)
>   
>       return KEY_UNSET;
>   }
> -
> -
> -/**
> - * Process an X11 event, convert into VLC hotkey event if applicable.
> - *
> - * @param syms XCB key symbols (created by xcb_key_symbols_alloc())
> - * @param ev XCB event to process
> - * @return 0 if the event was handled and free()'d, non-zero otherwise
> - */
> -int XCB_keyHandler_Process(xcb_key_symbols_t *syms, xcb_generic_event_t *ev,
> -                           vout_window_t *window)
> -{
> -    assert(syms != NULL);
> -
> -    switch (ev->response_type & 0x7f)
> -    {
> -        case XCB_KEY_PRESS:
> -        {
> -            xcb_key_press_event_t *e = (xcb_key_press_event_t *)ev;
> -            xcb_keysym_t sym = xcb_key_press_lookup_keysym(syms, e, 0);
> -            uint_fast32_t vk = ConvertKeySym (sym);
> -
> -            msg_Dbg(window, "key: 0x%08"PRIxFAST32" (X11: 0x%04"PRIx32")",
> -                    vk, sym);
> -            if (vk == KEY_UNSET)
> -                break;
> -            if (e->state & XCB_MOD_MASK_SHIFT) /* Shift */
> -                vk |= KEY_MODIFIER_SHIFT;
> -            /* XCB_MOD_MASK_LOCK */ /* Caps Lock */
> -            if (e->state & XCB_MOD_MASK_CONTROL) /* Control */
> -                vk |= KEY_MODIFIER_CTRL;
> -            if (e->state & XCB_MOD_MASK_1) /* Alternate */
> -                vk |= KEY_MODIFIER_ALT;
> -            /* XCB_MOD_MASK_2 */ /* Numeric Pad Lock */
> -            if (e->state & XCB_MOD_MASK_3) /* Super */
> -                vk |= KEY_MODIFIER_META;
> -            if (e->state & XCB_MOD_MASK_4) /* Meta */
> -                vk |= KEY_MODIFIER_META;
> -            if (e->state & XCB_MOD_MASK_5) /* Alternate Graphic */
> -                vk |= KEY_MODIFIER_ALT;
> -            vout_window_ReportKeyPress(window, vk);
> -            break;
> -        }
> -
> -        case XCB_KEY_RELEASE:
> -            break;
> -
> -        case XCB_MAPPING_NOTIFY:
> -        {
> -            xcb_mapping_notify_event_t *e = (xcb_mapping_notify_event_t *)ev;
> -            msg_Dbg(window, "refreshing keyboard mapping");
> -            xcb_refresh_keyboard_mapping(syms, e);
> -            break;
> -        }
> -
> -        default:
> -            return -1;
> -    }
> -
> -    free (ev);
> -    return 0;
> -}
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits





More information about the vlc-devel mailing list