summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wayland
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2013-11-07 14:29:49 +0000
committerChris Michael <cp.michael@samsung.com>2013-11-07 14:31:37 +0000
commit9240c2e91c93adacbeb1e6d1ea68d1eec3c5675d (patch)
tree70993e6ac7d49bf8228e5f376e590dca1e2aa494 /src/lib/ecore_wayland
parent5bde301efa087aeac9923184de88577cc1c92b84 (diff)
Add support for additional keyboard modifiers. Fix handling of Shift
key for capitals. Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_wayland')
-rw-r--r--src/lib/ecore_wayland/ecore_wl_input.c71
1 files changed, 42 insertions, 29 deletions
diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c
index b4f1a4d48f..1145554676 100644
--- a/src/lib/ecore_wayland/ecore_wl_input.c
+++ b/src/lib/ecore_wayland/ecore_wl_input.c
@@ -585,11 +585,21 @@ _ecore_wl_input_cb_keyboard_keymap(void *data, struct wl_keyboard *keyboard EINA
585 } 585 }
586 586
587 input->xkb.control_mask = 587 input->xkb.control_mask =
588 1 << xkb_map_mod_get_index(input->xkb.keymap, "Control"); 588 1 << xkb_map_mod_get_index(input->xkb.keymap, XKB_MOD_NAME_CTRL);
589 input->xkb.alt_mask = 589 input->xkb.alt_mask =
590 1 << xkb_map_mod_get_index(input->xkb.keymap, "Mod1"); 590 1 << xkb_map_mod_get_index(input->xkb.keymap, XKB_MOD_NAME_ALT);
591 input->xkb.shift_mask = 591 input->xkb.shift_mask =
592 1 << xkb_map_mod_get_index(input->xkb.keymap, "Shift"); 592 1 << xkb_map_mod_get_index(input->xkb.keymap, XKB_MOD_NAME_SHIFT);
593 input->xkb.win_mask =
594 1 << xkb_map_mod_get_index(input->xkb.keymap, XKB_MOD_NAME_LOGO);
595 input->xkb.scroll_mask =
596 1 << xkb_map_mod_get_index(input->xkb.keymap, XKB_LED_NAME_SCROLL);
597 input->xkb.num_mask =
598 1 << xkb_map_mod_get_index(input->xkb.keymap, XKB_LED_NAME_NUM);
599 input->xkb.caps_mask =
600 1 << xkb_map_mod_get_index(input->xkb.keymap, XKB_MOD_NAME_CAPS);
601 input->xkb.altgr_mask =
602 1 << xkb_map_mod_get_index(input->xkb.keymap, "ISO_Level3_Shift");
593} 603}
594 604
595static int 605static int
@@ -641,41 +651,35 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN
641{ 651{
642 Ecore_Wl_Input *input; 652 Ecore_Wl_Input *input;
643 Ecore_Wl_Window *win; 653 Ecore_Wl_Window *win;
644 unsigned int code; 654 unsigned int code, nsyms;
655 const xkb_keysym_t *syms;
645 xkb_keysym_t sym = XKB_KEY_NoSymbol; 656 xkb_keysym_t sym = XKB_KEY_NoSymbol;
646 char key[32], keyname[32], compose[32]; 657 char key[256], keyname[256], compose[256];
647 Ecore_Event_Key *e; 658 Ecore_Event_Key *e;
648 659
649 LOGFN(__FILE__, __LINE__, __FUNCTION__); 660 LOGFN(__FILE__, __LINE__, __FUNCTION__);
650 661
651 if (!(input = data)) return; 662 if (!(input = data)) return;
652 input->display->serial = serial;
653
654 /* xkb rules reflect X broken keycodes, so offset by 8 */
655 code = keycode + 8;
656 663
657 win = input->keyboard_focus; 664 win = input->keyboard_focus;
658 if ((!win) || (win->keyboard_device != input) || (!input->xkb.state)) 665 if ((!win) || (win->keyboard_device != input) || (!input->xkb.state))
659 return; 666 return;
660 667
661 sym = xkb_state_key_get_one_sym(input->xkb.state, code); 668 input->display->serial = serial;
669
670 /* xkb rules reflect X broken keycodes, so offset by 8 */
671 code = keycode + 8;
672
673 /* get the keysym for this key code */
674 nsyms = xkb_key_get_syms(input->xkb.state, code, &syms);
675 if (nsyms == 1) sym = syms[0];
662 676
677 /* get the name of this keysym */
663 memset(key, 0, sizeof(key)); 678 memset(key, 0, sizeof(key));
664 xkb_keysym_get_name(sym, key, sizeof(key)); 679 xkb_keysym_get_name(sym, key, sizeof(key));
665 680
666 xkb_state_mod_mask_remove_consumed(input->xkb.state,
667 code, input->xkb.shift_mask);
668
669 memset(keyname, 0, sizeof(keyname)); 681 memset(keyname, 0, sizeof(keyname));
670 xkb_keysym_get_name(sym, keyname, sizeof(keyname)); 682 memcpy(keyname, key, sizeof(keyname));
671 if (xkb_state_mod_index_is_active(input->xkb.state,
672 xkb_map_mod_get_index(input->xkb.keymap,
673 "Shift"),
674 XKB_STATE_MODS_EFFECTIVE))
675 {
676 if (keyname[0] != '\0')
677 keyname[0] = tolower(keyname[0]);
678 }
679 683
680 if (keyname[0] == '\0') 684 if (keyname[0] == '\0')
681 snprintf(keyname, sizeof(keyname), "Keycode-%u", code); 685 snprintf(keyname, sizeof(keyname), "Keycode-%u", code);
@@ -700,6 +704,7 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN
700 e->window = win->id; 704 e->window = win->id;
701 e->event_window = win->id; 705 e->event_window = win->id;
702 e->timestamp = timestamp; 706 e->timestamp = timestamp;
707
703 e->modifiers = input->modifiers; 708 e->modifiers = input->modifiers;
704 709
705 if (state) 710 if (state)
@@ -740,22 +745,30 @@ _ecore_wl_input_cb_keyboard_modifiers(void *data, struct wl_keyboard *keyboard E
740 LOGFN(__FILE__, __LINE__, __FUNCTION__); 745 LOGFN(__FILE__, __LINE__, __FUNCTION__);
741 746
742 if (!(input = data)) return; 747 if (!(input = data)) return;
743 if (!input->xkb.state) return;
744 748
745 xkb_state_update_mask(input->xkb.state, depressed, latched, 749 input->modifiers = 0;
746 locked, 0, 0, group); 750 if (!input->xkb.state) return;
747 751
752 xkb_state_update_mask(input->xkb.state,
753 depressed, latched, locked, 0, 0, group);
748 mask = xkb_state_serialize_mods(input->xkb.state, 754 mask = xkb_state_serialize_mods(input->xkb.state,
749 XKB_STATE_DEPRESSED | XKB_STATE_LATCHED); 755 (XKB_STATE_DEPRESSED | XKB_STATE_LATCHED));
750
751 input->modifiers = 0;
752 /* The Ecore_Event_Modifiers don't quite match the X mask bits */
753 if (mask & input->xkb.control_mask) 756 if (mask & input->xkb.control_mask)
754 input->modifiers |= ECORE_EVENT_MODIFIER_CTRL; 757 input->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
755 if (mask & input->xkb.alt_mask) 758 if (mask & input->xkb.alt_mask)
756 input->modifiers |= ECORE_EVENT_MODIFIER_ALT; 759 input->modifiers |= ECORE_EVENT_MODIFIER_ALT;
757 if (mask & input->xkb.shift_mask) 760 if (mask & input->xkb.shift_mask)
758 input->modifiers |= ECORE_EVENT_MODIFIER_SHIFT; 761 input->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
762 if (mask & input->xkb.win_mask)
763 input->modifiers |= ECORE_EVENT_MODIFIER_WIN;
764 if (mask & input->xkb.scroll_mask)
765 input->modifiers |= ECORE_EVENT_LOCK_SCROLL;
766 if (mask & input->xkb.num_mask)
767 input->modifiers |= ECORE_EVENT_LOCK_NUM;
768 if (mask & input->xkb.caps_mask)
769 input->modifiers |= ECORE_EVENT_LOCK_CAPS;
770 if (mask & input->xkb.altgr_mask)
771 input->modifiers |= ECORE_EVENT_MODIFIER_ALTGR;
759} 772}
760 773
761static Eina_Bool 774static Eina_Bool