summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_input.c46
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_private.h3
2 files changed, 48 insertions, 1 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c
index 6ad915212f..510139006b 100644
--- a/src/lib/ecore_wl2/ecore_wl2_input.c
+++ b/src/lib/ecore_wl2/ecore_wl2_input.c
@@ -832,6 +832,7 @@ _keyboard_cb_keymap(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsign
832{ 832{
833 Ecore_Wl2_Input *input; 833 Ecore_Wl2_Input *input;
834 char *map = NULL; 834 char *map = NULL;
835 const char *locale;
835 836
836 input = data; 837 input = data;
837 if (!input) 838 if (!input)
@@ -881,6 +882,17 @@ _keyboard_cb_keymap(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsign
881 input->xkb.keymap = NULL; 882 input->xkb.keymap = NULL;
882 return; 883 return;
883 } 884 }
885
886 if (!(locale = getenv("LC_ALL")))
887 if (!(locale = getenv("LC_CTYPE")))
888 if (!(locale = getenv("LANG")))
889 locale = "C";
890 if (input->xkb.compose_table) xkb_compose_table_unref(input->xkb.compose_table);
891 input->xkb.compose_table = xkb_compose_table_new_from_locale(input->display->xkb_context,
892 locale, XKB_COMPOSE_COMPILE_NO_FLAGS);
893 if (input->xkb.compose_state) xkb_compose_state_unref(input->xkb.compose_state);
894 input->xkb.compose_state = xkb_compose_state_new(input->xkb.compose_table, XKB_COMPOSE_STATE_NO_FLAGS);
895
884 { 896 {
885 Ecore_Wl2_Event_Seat_Keymap_Changed *ev = malloc(sizeof(Ecore_Wl2_Event_Seat_Keymap_Changed)); 897 Ecore_Wl2_Event_Seat_Keymap_Changed *ev = malloc(sizeof(Ecore_Wl2_Event_Seat_Keymap_Changed));
886 if (ev) 898 if (ev)
@@ -992,6 +1004,32 @@ out:
992 return ECORE_CALLBACK_CANCEL; 1004 return ECORE_CALLBACK_CANCEL;
993} 1005}
994 1006
1007/* from weston/clients/window.c */
1008/* Translate symbols appropriately if a compose sequence is being entered */
1009static xkb_keysym_t
1010process_key_press(xkb_keysym_t sym, Ecore_Wl2_Input *input)
1011{
1012 if (!input->xkb.compose_state)
1013 return sym;
1014 if (sym == XKB_KEY_NoSymbol)
1015 return sym;
1016 if (xkb_compose_state_feed(input->xkb.compose_state, sym) != XKB_COMPOSE_FEED_ACCEPTED)
1017 return sym;
1018
1019 switch (xkb_compose_state_get_status(input->xkb.compose_state))
1020 {
1021 case XKB_COMPOSE_COMPOSING:
1022 return XKB_KEY_NoSymbol;
1023 case XKB_COMPOSE_COMPOSED:
1024 return xkb_compose_state_get_one_sym(input->xkb.compose_state);
1025 case XKB_COMPOSE_CANCELLED:
1026 return XKB_KEY_NoSymbol;
1027 case XKB_COMPOSE_NOTHING:
1028 default: break;
1029 }
1030 return sym;
1031}
1032
995static void 1033static void
996_keyboard_cb_key(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state) 1034_keyboard_cb_key(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state)
997{ 1035{
@@ -999,6 +1037,7 @@ _keyboard_cb_key(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned
999 Ecore_Wl2_Window *window; 1037 Ecore_Wl2_Window *window;
1000 unsigned int code; 1038 unsigned int code;
1001 xkb_keysym_t sym = XKB_KEY_NoSymbol, sym_name = XKB_KEY_NoSymbol; 1039 xkb_keysym_t sym = XKB_KEY_NoSymbol, sym_name = XKB_KEY_NoSymbol;
1040 const xkb_keysym_t *syms;
1002 1041
1003 input = data; 1042 input = data;
1004 if (!input) return; 1043 if (!input) return;
@@ -1012,7 +1051,10 @@ _keyboard_cb_key(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned
1012 /* xkb rules reflect X broken keycodes, so offset by 8 */ 1051 /* xkb rules reflect X broken keycodes, so offset by 8 */
1013 code = keycode + 8; 1052 code = keycode + 8;
1014 1053
1015 sym = xkb_state_key_get_one_sym(input->xkb.state, code); 1054 if (xkb_state_key_get_syms(input->xkb.state, code, &syms) == 1)
1055 sym = syms[0];
1056 if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
1057 sym = process_key_press(sym, input);
1016 sym_name = xkb_state_key_get_one_sym(input->xkb.maskless_state, code); 1058 sym_name = xkb_state_key_get_one_sym(input->xkb.maskless_state, code);
1017 1059
1018 _ecore_wl2_input_key_send(input, window, sym, sym_name, code, state, timestamp); 1060 _ecore_wl2_input_key_send(input, window, sym, sym_name, code, state, timestamp);
@@ -1620,6 +1662,8 @@ _ecore_wl2_input_del(Ecore_Wl2_Input *input)
1620 if (input->xkb.state) xkb_state_unref(input->xkb.state); 1662 if (input->xkb.state) xkb_state_unref(input->xkb.state);
1621 if (input->xkb.maskless_state) xkb_state_unref(input->xkb.maskless_state); 1663 if (input->xkb.maskless_state) xkb_state_unref(input->xkb.maskless_state);
1622 if (input->xkb.keymap) xkb_map_unref(input->xkb.keymap); 1664 if (input->xkb.keymap) xkb_map_unref(input->xkb.keymap);
1665 if (input->xkb.compose_table) xkb_compose_table_unref(input->xkb.compose_table);
1666 if (input->xkb.compose_state) xkb_compose_state_unref(input->xkb.compose_state);
1623 1667
1624 if (input->wl.seat) wl_seat_destroy(input->wl.seat); 1668 if (input->wl.seat) wl_seat_destroy(input->wl.seat);
1625 1669
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h
index f9aedf1823..c150a4b6ce 100644
--- a/src/lib/ecore_wl2/ecore_wl2_private.h
+++ b/src/lib/ecore_wl2/ecore_wl2_private.h
@@ -4,6 +4,7 @@
4# include <unistd.h> 4# include <unistd.h>
5# include "Ecore_Wl2.h" 5# include "Ecore_Wl2.h"
6# include "Ecore_Input.h" 6# include "Ecore_Input.h"
7#include <xkbcommon/xkbcommon-compose.h>
7# include "www-client-protocol.h" 8# include "www-client-protocol.h"
8 9
9#define EFL_TEAMWORK_VERSION 2 10#define EFL_TEAMWORK_VERSION 2
@@ -402,6 +403,8 @@ struct _Ecore_Wl2_Input
402 struct xkb_keymap *keymap; 403 struct xkb_keymap *keymap;
403 struct xkb_state *state; 404 struct xkb_state *state;
404 struct xkb_state *maskless_state; 405 struct xkb_state *maskless_state;
406 struct xkb_compose_table *compose_table;
407 struct xkb_compose_state *compose_state;
405 xkb_mod_mask_t control_mask; 408 xkb_mod_mask_t control_mask;
406 xkb_mod_mask_t alt_mask; 409 xkb_mod_mask_t alt_mask;
407 xkb_mod_mask_t shift_mask; 410 xkb_mod_mask_t shift_mask;