summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-04-05 15:11:29 +0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-06-20 15:11:26 +0200
commita7c11fd10512f4a75faf2b191f8efc469228b62a (patch)
treeb65318ba7b013aa1dfdb7e6c8effadbc8fee5920
parent339195cad6ecab0d5739148d52e6a1fc3debb753 (diff)
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
-rw-r--r--src/lib/ecore_x/xlib/ecore_x.c4
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_events.c45
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 01b626d2c8..e35859e412 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)
477#ifdef ECORE_XKB 477#ifdef ECORE_XKB
478 { 478 {
479 int dummy; 479 int dummy;
480 480
481 if (XkbQueryExtension(_ecore_x_disp, &dummy, &xkb_base, 481 if (XkbQueryExtension(_ecore_x_disp, &dummy, &xkb_base,
482 &dummy, &dummy, &dummy)) 482 &dummy, &dummy, &dummy))
483 _ecore_x_event_xkb_id = xkb_base; 483 _ecore_x_event_xkb_id = xkb_base;
484 XkbSelectEventDetails(_ecore_x_disp, XkbUseCoreKbd, XkbStateNotify, 484 XkbSelectEventDetails(_ecore_x_disp, XkbUseCoreKbd, XkbStateNotify,
485 XkbAllStateComponentsMask, XkbGroupStateMask); 485 XkbAllStateComponentsMask, XkbGroupStateMask);
486 XkbSelectEventDetails(_ecore_x_disp, XkbUseCoreKbd, XkbNewKeyboardNotify,
487 XkbNewKeyboardNotifyMask, XkbNewKeyboardNotifyMask);
486 } 488 }
487 ECORE_X_EVENT_HANDLERS_GROW(xkb_base, XkbNumberEvents); 489 ECORE_X_EVENT_HANDLERS_GROW(xkb_base, XkbNumberEvents);
488#endif 490#endif
diff --git a/src/lib/ecore_x/xlib/ecore_x_events.c b/src/lib/ecore_x/xlib/ecore_x_events.c
index 5b0e19fe1f..613fe5e08c 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;
40static Ecore_Event *_ecore_x_last_event_mouse_move_event = NULL; 40static Ecore_Event *_ecore_x_last_event_mouse_move_event = NULL;
41static Eina_Inlist *_ecore_x_mouse_down_info_list = NULL; 41static Eina_Inlist *_ecore_x_mouse_down_info_list = NULL;
42 42
43#ifdef ECORE_XKB
44static Eina_Hash *emitted_events = NULL;
45#endif
46
43static void 47static void
44_ecore_x_mouse_down_info_clear(void) 48_ecore_x_mouse_down_info_clear(void)
45{ 49{
@@ -58,12 +62,18 @@ void
58_ecore_x_events_init(void) 62_ecore_x_events_init(void)
59{ 63{
60 //Actually, Nothing to do. 64 //Actually, Nothing to do.
65#ifdef ECORE_XKB
66 emitted_events = eina_hash_int64_new(NULL);
67#endif
61} 68}
62 69
63void 70void
64_ecore_x_events_shutdown(void) 71_ecore_x_events_shutdown(void)
65{ 72{
66 _ecore_x_mouse_down_info_clear(); 73 _ecore_x_mouse_down_info_clear();
74#ifdef ECORE_XKB
75 eina_hash_free(emitted_events);
76#endif
67} 77}
68 78
69static Ecore_X_Mouse_Down_Info * 79static Ecore_X_Mouse_Down_Info *
@@ -2608,22 +2618,40 @@ _ecore_x_event_handle_gesture_notify_group(XEvent *xevent)
2608 2618
2609#endif /* ifdef ECORE_XGESTURE */ 2619#endif /* ifdef ECORE_XGESTURE */
2610#ifdef ECORE_XKB 2620#ifdef ECORE_XKB
2621
2622void
2623free_hash(void *userdata EINA_UNUSED, void *funcdata EINA_UNUSED)
2624{
2625 eina_hash_del_by_data(emitted_events, (void*) 1);
2626}
2627
2611void 2628void
2612_ecore_x_event_handle_xkb(XEvent *xevent) 2629_ecore_x_event_handle_xkb(XEvent *xevent)
2613{ 2630{
2614 XkbEvent *xkbev; 2631 XkbEvent *xkbev;
2615 Ecore_X_Event_Xkb *e; 2632
2616
2617 xkbev = (XkbEvent *) xevent; 2633 xkbev = (XkbEvent *) xevent;
2618 e = calloc(1, sizeof(Ecore_X_Event_Xkb)); 2634
2619 if (!e) 2635
2620 return;
2621 e->group = xkbev->state.group;
2622 if (xkbev->any.xkb_type == XkbStateNotify) 2636 if (xkbev->any.xkb_type == XkbStateNotify)
2623 ecore_event_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, e, NULL, NULL); 2637 {
2638 Ecore_X_Event_Xkb *e;
2639
2640 if (eina_hash_find(emitted_events, &xkbev->state.serial)) return;
2641
2642 e = calloc(1, sizeof(Ecore_X_Event_Xkb));
2643 if (!e)
2644 return;
2645
2646 e->group = xkbev->state.group;
2647 ecore_event_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, e, free_hash, NULL);
2648 eina_hash_add(emitted_events, &xkbev->state.serial, (void*) 1);
2649 }
2624 else if ((xkbev->any.xkb_type == XkbNewKeyboardNotify) || 2650 else if ((xkbev->any.xkb_type == XkbNewKeyboardNotify) ||
2625 (xkbev->any.xkb_type == XkbMapNotify)) 2651 (xkbev->any.xkb_type == XkbMapNotify))
2626 { 2652 {
2653 if (eina_hash_find(emitted_events, &xkbev->state.serial)) return;
2654
2627 if (xkbev->any.xkb_type == XkbMapNotify) 2655 if (xkbev->any.xkb_type == XkbMapNotify)
2628 { 2656 {
2629 XkbMapNotifyEvent *xkbmapping; 2657 XkbMapNotifyEvent *xkbmapping;
@@ -2631,7 +2659,8 @@ _ecore_x_event_handle_xkb(XEvent *xevent)
2631 xkbmapping = (XkbMapNotifyEvent *)xkbev; 2659 xkbmapping = (XkbMapNotifyEvent *)xkbev;
2632 XkbRefreshKeyboardMapping(xkbmapping); 2660 XkbRefreshKeyboardMapping(xkbmapping);
2633 } 2661 }
2634 ecore_event_add(ECORE_X_EVENT_XKB_NEWKBD_NOTIFY, e, NULL, NULL); 2662 ecore_event_add(ECORE_X_EVENT_XKB_NEWKBD_NOTIFY, NULL, free_hash, NULL);
2663 eina_hash_add(emitted_events, &xkbev->new_kbd.serial, (void*) 1);
2635 } 2664 }
2636} 2665}
2637#endif /* ifdef ECORE_XKB */ 2666#endif /* ifdef ECORE_XKB */