bu5hm4n pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=8400c9d3d2eecde87fab0e8cd5781a8b1acd54cb
commit 8400c9d3d2eecde87fab0e8cd5781a8b1acd54cb Author: Marcel Hollerbach <marcel-hollerb...@t-online.de> Date: Tue Apr 5 15:11:29 2016 +0200 ecore_x: fix emission of ECORE_X_EVENT_XKB_NEWKBD_NOTIFY Summary: the event XkbNewKeyboardNotify was never selected with XkbSelectEventDetails so the event type could never occur. The event is now each time emitted when a new event to the keyboard happens. To clarify a bit: A new keyboard is always detected in x when the set of keymaps changes. @fix Reviewers: raster, devilhorns, zmike Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D3867 --- src/lib/ecore_x/xlib/ecore_x.c | 4 +++- src/lib/ecore_x/xlib/ecore_x_events.c | 45 ++++++++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/lib/ecore_x/xlib/ecore_x.c b/src/lib/ecore_x/xlib/ecore_x.c index 7f2dc52..546257b 100644 --- a/src/lib/ecore_x/xlib/ecore_x.c +++ b/src/lib/ecore_x/xlib/ecore_x.c @@ -477,12 +477,14 @@ _ecore_x_init2(void) #ifdef ECORE_XKB { int dummy; - + if (XkbQueryExtension(_ecore_x_disp, &dummy, &xkb_base, &dummy, &dummy, &dummy)) _ecore_x_event_xkb_id = xkb_base; XkbSelectEventDetails(_ecore_x_disp, XkbUseCoreKbd, XkbStateNotify, XkbAllStateComponentsMask, XkbGroupStateMask); + XkbSelectEventDetails(_ecore_x_disp, XkbUseCoreKbd, XkbNewKeyboardNotify, + XkbNewKeyboardNotifyMask, XkbNewKeyboardNotifyMask); } ECORE_X_EVENT_HANDLERS_GROW(xkb_base, XkbNumberEvents); #endif diff --git a/src/lib/ecore_x/xlib/ecore_x_events.c b/src/lib/ecore_x/xlib/ecore_x_events.c index 4fe5eeb..cf5ec17 100644 --- a/src/lib/ecore_x/xlib/ecore_x_events.c +++ b/src/lib/ecore_x/xlib/ecore_x_events.c @@ -40,6 +40,10 @@ static int _ecore_x_last_event_mouse_move = 0; static Ecore_Event *_ecore_x_last_event_mouse_move_event = NULL; static Eina_Inlist *_ecore_x_mouse_down_info_list = NULL; +#ifdef ECORE_XKB +static Eina_Hash *emitted_events = NULL; +#endif + static void _ecore_x_mouse_down_info_clear(void) { @@ -58,12 +62,18 @@ void _ecore_x_events_init(void) { //Actually, Nothing to do. +#ifdef ECORE_XKB + emitted_events = eina_hash_int64_new(NULL); +#endif } void _ecore_x_events_shutdown(void) { _ecore_x_mouse_down_info_clear(); +#ifdef ECORE_XKB + eina_hash_free(emitted_events); +#endif } static Ecore_X_Mouse_Down_Info * @@ -2614,22 +2624,40 @@ _ecore_x_event_handle_gesture_notify_group(XEvent *xevent) #endif /* ifdef ECORE_XGESTURE */ #ifdef ECORE_XKB + +void +free_hash(void *userdata EINA_UNUSED, void *funcdata EINA_UNUSED) +{ + eina_hash_del_by_data(emitted_events, (void*) 1); +} + void _ecore_x_event_handle_xkb(XEvent *xevent) { XkbEvent *xkbev; - Ecore_X_Event_Xkb *e; - + xkbev = (XkbEvent *) xevent; - e = calloc(1, sizeof(Ecore_X_Event_Xkb)); - if (!e) - return; - e->group = xkbev->state.group; + + if (xkbev->any.xkb_type == XkbStateNotify) - ecore_event_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, e, NULL, NULL); + { + Ecore_X_Event_Xkb *e; + + if (eina_hash_find(emitted_events, &xkbev->state.serial)) return; + + e = calloc(1, sizeof(Ecore_X_Event_Xkb)); + if (!e) + return; + + e->group = xkbev->state.group; + ecore_event_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, e, free_hash, NULL); + eina_hash_add(emitted_events, &xkbev->state.serial, (void*) 1); + } else if ((xkbev->any.xkb_type == XkbNewKeyboardNotify) || (xkbev->any.xkb_type == XkbMapNotify)) { + if (eina_hash_find(emitted_events, &xkbev->state.serial)) return; + if (xkbev->any.xkb_type == XkbMapNotify) { XkbMapNotifyEvent *xkbmapping; @@ -2637,7 +2665,8 @@ _ecore_x_event_handle_xkb(XEvent *xevent) xkbmapping = (XkbMapNotifyEvent *)xkbev; XkbRefreshKeyboardMapping(xkbmapping); } - ecore_event_add(ECORE_X_EVENT_XKB_NEWKBD_NOTIFY, e, NULL, NULL); + ecore_event_add(ECORE_X_EVENT_XKB_NEWKBD_NOTIFY, NULL, free_hash, NULL); + eina_hash_add(emitted_events, &xkbev->new_kbd.serial, (void*) 1); } } #endif /* ifdef ECORE_XKB */ --