From 84e54d532df6bf03034a801109dff61f7c9e708a Mon Sep 17 00:00:00 2001 From: Sebastian Dransfeld Date: Wed, 27 Jun 2012 10:47:57 +0000 Subject: [PATCH] ecore: Fix support for intl keyboards Map XK_Mode_switch to new modifier and use it to match AltGr key. In ecore_imf xim module this key should be reported as Mod5Mask, and windows key as Mod4Mask. Does none of the e developers use international keyboards? SVN revision: 72937 --- legacy/ecore/src/lib/ecore_imf/Ecore_IMF.h | 3 ++- legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c | 2 ++ legacy/ecore/src/lib/ecore_input/Ecore_Input.h | 2 ++ legacy/ecore/src/lib/ecore_input/ecore_input.c | 1 + .../src/lib/ecore_input_evas/ecore_input_evas.c | 5 +++++ legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_events.c | 2 ++ legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_keymap.c | 5 +++-- legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h | 1 + legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_window.c | 2 ++ legacy/ecore/src/lib/ecore_x/xlib/ecore_x.c | 12 ++++++++---- legacy/ecore/src/lib/ecore_x/xlib/ecore_x_events.c | 3 +++ legacy/ecore/src/lib/ecore_x/xlib/ecore_x_private.h | 1 + .../ecore/src/modules/immodules/xim/ecore_imf_xim.c | 6 +++++- 13 files changed, 37 insertions(+), 8 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_imf/Ecore_IMF.h b/legacy/ecore/src/lib/ecore_imf/Ecore_IMF.h index 4e723cd3d3..135d656de0 100644 --- a/legacy/ecore/src/lib/ecore_imf/Ecore_IMF.h +++ b/legacy/ecore/src/lib/ecore_imf/Ecore_IMF.h @@ -116,7 +116,8 @@ typedef enum ECORE_IMF_KEYBOARD_MODIFIER_CTRL = 1 << 0, /**< "Control" is pressed */ ECORE_IMF_KEYBOARD_MODIFIER_ALT = 1 << 1, /**< "Alt" is pressed */ ECORE_IMF_KEYBOARD_MODIFIER_SHIFT = 1 << 2, /**< "Shift" is pressed */ - ECORE_IMF_KEYBOARD_MODIFIER_WIN = 1 << 3 /**< "Win" (between "Ctrl" and "Alt") is pressed */ + ECORE_IMF_KEYBOARD_MODIFIER_WIN = 1 << 3, /**< "Win" (between "Ctrl" and "Alt") is pressed */ + ECORE_IMF_KEYBOARD_MODIFIER_MODE = 1 << 4 /**< "AltGr" is pressed @since 1.3 */ } Ecore_IMF_Keyboard_Modifiers; /** diff --git a/legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c b/legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c index 98dce885a5..549b38ae8d 100644 --- a/legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c +++ b/legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c @@ -33,6 +33,8 @@ _ecore_imf_evas_event_modifiers_wrap(Evas_Modifier *evas_modifiers, *imf_keyboard_modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; if (evas_key_modifier_is_set(evas_modifiers, "Super") || evas_key_modifier_is_set(evas_modifiers, "Hyper")) *imf_keyboard_modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_WIN; + if (evas_key_modifier_is_set(evas_modifiers, "Mode")) + *imf_keyboard_modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_MODE; } /* Converts the Evas locks to Ecore_IMF keyboard locks */ diff --git a/legacy/ecore/src/lib/ecore_input/Ecore_Input.h b/legacy/ecore/src/lib/ecore_input/Ecore_Input.h index a64bb2b892..c2923081ea 100644 --- a/legacy/ecore/src/lib/ecore_input/Ecore_Input.h +++ b/legacy/ecore/src/lib/ecore_input/Ecore_Input.h @@ -57,6 +57,7 @@ extern "C" { #define ECORE_EVENT_LOCK_NUM 0x0100 #define ECORE_EVENT_LOCK_CAPS 0x0200 #define ECORE_EVENT_LOCK_SHIFT 0x0300 +#define ECORE_EVENT_MODIFIER_MODE 0x0400 /**< @since 1.3 */ typedef uintptr_t Ecore_Window; typedef struct _Ecore_Event_Key Ecore_Event_Key; @@ -75,6 +76,7 @@ extern "C" { ECORE_WIN, ECORE_SCROLL, ECORE_CAPS, + ECORE_MODE, /**< @since 1.3 */ ECORE_LAST } Ecore_Event_Modifier; diff --git a/legacy/ecore/src/lib/ecore_input/ecore_input.c b/legacy/ecore/src/lib/ecore_input/ecore_input.c index ce4c275414..9d29d444ae 100644 --- a/legacy/ecore/src/lib/ecore_input/ecore_input.c +++ b/legacy/ecore/src/lib/ecore_input/ecore_input.c @@ -88,6 +88,7 @@ static const Ecore_Event_Modifier_Match matchs[] = { { "Caps_Lock", ECORE_CAPS, ECORE_EVENT_MODIFIER_CAPS }, { "Super_L", ECORE_WIN, ECORE_EVENT_MODIFIER_WIN }, { "Super_R", ECORE_WIN, ECORE_EVENT_MODIFIER_WIN }, + { "ISO_Level3_Shift", ECORE_MODE, ECORE_EVENT_MODIFIER_MODE }, { "Scroll_Lock", ECORE_SCROLL, ECORE_EVENT_MODIFIER_SCROLL } }; diff --git a/legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas.c b/legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas.c index 53d206ec28..8c149e503b 100644 --- a/legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas.c +++ b/legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas.c @@ -55,6 +55,10 @@ ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers) evas_key_modifier_off(e, "Hyper"); } + if (modifiers & ECORE_EVENT_MODIFIER_MODE) + evas_key_modifier_on(e, "Mode"); + else evas_key_modifier_off(e, "Mode"); + if (modifiers & ECORE_EVENT_LOCK_SCROLL) evas_key_lock_on(e, "Scroll_Lock"); else evas_key_lock_off(e, "Scroll_Lock"); @@ -100,6 +104,7 @@ ecore_event_window_register(Ecore_Window id, void *window, Evas *evas, evas_key_modifier_add(evas, "Meta"); evas_key_modifier_add(evas, "Hyper"); evas_key_modifier_add(evas, "Super"); + evas_key_modifier_add(evas, "Mode"); evas_key_lock_add(evas, "Caps_Lock"); evas_key_lock_add(evas, "Num_Lock"); evas_key_lock_add(evas, "Scroll_Lock"); diff --git a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_events.c b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_events.c index 8a181405ff..ce38fae143 100644 --- a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_events.c +++ b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_events.c @@ -550,6 +550,8 @@ _ecore_xcb_events_modifiers_get(unsigned int state) modifiers |= ECORE_EVENT_MODIFIER_ALT; if (state & ECORE_X_MODIFIER_WIN) modifiers |= ECORE_EVENT_MODIFIER_WIN; + if (state & ECORE_X_MODIFIER_MODE) + modifiers |= ECORE_EVENT_MODIFIER_MODE; if (state & ECORE_X_LOCK_SCROLL) modifiers |= ECORE_EVENT_LOCK_SCROLL; if (state & ECORE_X_LOCK_CAPS) diff --git a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_keymap.c b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_keymap.c index b1c752895c..d707f02c48 100644 --- a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_keymap.c +++ b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_keymap.c @@ -27,6 +27,7 @@ EAPI int ECORE_X_MODIFIER_SHIFT = 0; EAPI int ECORE_X_MODIFIER_CTRL = 0; EAPI int ECORE_X_MODIFIER_ALT = 0; EAPI int ECORE_X_MODIFIER_WIN = 0; +EAPI int ECORE_X_MODIFIER_MODE = 0; EAPI int ECORE_X_LOCK_SCROLL = 0; EAPI int ECORE_X_LOCK_NUM = 0; EAPI int ECORE_X_LOCK_CAPS = 0; @@ -69,11 +70,11 @@ _ecore_xcb_keymap_finalize(void) ECORE_X_MODIFIER_ALT = _ecore_xcb_keymap_mask_get(reply, XK_Super_L); ECORE_X_MODIFIER_WIN = _ecore_xcb_keymap_mask_get(reply, XK_Super_L); - if (!ECORE_X_MODIFIER_WIN) - ECORE_X_MODIFIER_WIN = _ecore_xcb_keymap_mask_get(reply, XK_Mode_switch); if (!ECORE_X_MODIFIER_WIN) ECORE_X_MODIFIER_WIN = _ecore_xcb_keymap_mask_get(reply, XK_Meta_L); + ECORE_X_MODIFIER_MODE = _ecore_xcb_keymap_mask_get(reply, XK_Mode_switch); + if (ECORE_X_MODIFIER_WIN == ECORE_X_MODIFIER_ALT) ECORE_X_MODIFIER_WIN = 0; if (ECORE_X_MODIFIER_ALT == ECORE_X_MODIFIER_CTRL) diff --git a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h index cf8f3e50c6..3db08f81d1 100644 --- a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h +++ b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h @@ -213,6 +213,7 @@ extern int ECORE_X_MODIFIER_SHIFT; extern int ECORE_X_MODIFIER_CTRL; extern int ECORE_X_MODIFIER_ALT; extern int ECORE_X_MODIFIER_WIN; +extern int ECORE_X_MODIFIER_MODE; extern int ECORE_X_LOCK_SCROLL; extern int ECORE_X_LOCK_NUM; extern int ECORE_X_LOCK_CAPS; diff --git a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_window.c b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_window.c index c1ea658dbe..065c296d2e 100644 --- a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_window.c +++ b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_window.c @@ -2186,6 +2186,8 @@ _ecore_xcb_window_modifiers_get(unsigned int state) xmodifiers |= ECORE_X_MODIFIER_ALT; if (state & ECORE_EVENT_MODIFIER_WIN) xmodifiers |= ECORE_X_MODIFIER_WIN; + if (state & ECORE_EVENT_MODIFIER_MODE) + xmodifiers |= ECORE_X_MODIFIER_MODE; if (state & ECORE_EVENT_LOCK_SCROLL) xmodifiers |= ECORE_X_LOCK_SCROLL; if (state & ECORE_EVENT_LOCK_NUM) diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x.c index 98c2526aa5..e40966fbdc 100644 --- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x.c +++ b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x.c @@ -130,6 +130,7 @@ int ECORE_X_MODIFIER_SHIFT = 0; int ECORE_X_MODIFIER_CTRL = 0; int ECORE_X_MODIFIER_ALT = 0; int ECORE_X_MODIFIER_WIN = 0; +int ECORE_X_MODIFIER_MODE = 0; EAPI int ECORE_X_LOCK_SCROLL = 0; EAPI int ECORE_X_LOCK_NUM = 0; @@ -217,8 +218,9 @@ _ecore_x_XKeycodeToKeysym(Display *display, KeyCode keycode, int idx) { #ifdef ECORE_XKB return XkbKeycodeToKeysym(display, keycode, 0, idx); -#endif +#else return XKeycodeToKeysym(display, keycode, idx); +#endif } void @@ -238,12 +240,11 @@ _ecore_x_modifiers_get(void) /* the windows key... a valid modifier :) */ ECORE_X_MODIFIER_WIN = _ecore_x_key_mask_get(XK_Super_L); - if (!ECORE_X_MODIFIER_WIN) - ECORE_X_MODIFIER_WIN = _ecore_x_key_mask_get(XK_Mode_switch); - if (!ECORE_X_MODIFIER_WIN) ECORE_X_MODIFIER_WIN = _ecore_x_key_mask_get(XK_Meta_L); + ECORE_X_MODIFIER_MODE = _ecore_x_key_mask_get(XK_Mode_switch); + if (ECORE_X_MODIFIER_WIN == ECORE_X_MODIFIER_ALT) ECORE_X_MODIFIER_WIN = 0; @@ -2155,6 +2156,9 @@ _ecore_x_event_modifier(unsigned int state) if (state & ECORE_EVENT_MODIFIER_WIN) xmodifiers |= ECORE_X_MODIFIER_WIN; + if (state & ECORE_EVENT_MODIFIER_MODE) + xmodifiers |= ECORE_X_MODIFIER_MODE; + if (state & ECORE_EVENT_LOCK_SCROLL) xmodifiers |= ECORE_X_LOCK_SCROLL; diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_events.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_events.c index acb64a944e..6125a4e889 100644 --- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_events.c +++ b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_events.c @@ -183,6 +183,9 @@ _ecore_x_event_modifiers(unsigned int state) if (state & ECORE_X_MODIFIER_WIN) modifiers |= ECORE_EVENT_MODIFIER_WIN; + if (state & ECORE_X_MODIFIER_MODE) + modifiers |= ECORE_EVENT_MODIFIER_MODE; + if (state & ECORE_X_LOCK_SCROLL) modifiers |= ECORE_EVENT_LOCK_SCROLL; diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_private.h b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_private.h index 8132e13589..c389f53906 100644 --- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_private.h +++ b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_private.h @@ -186,6 +186,7 @@ extern int ECORE_X_MODIFIER_SHIFT; extern int ECORE_X_MODIFIER_CTRL; extern int ECORE_X_MODIFIER_ALT; extern int ECORE_X_MODIFIER_WIN; +extern int ECORE_X_MODIFIER_MODE; extern int ECORE_X_LOCK_SCROLL; extern int ECORE_X_LOCK_NUM; diff --git a/legacy/ecore/src/modules/immodules/xim/ecore_imf_xim.c b/legacy/ecore/src/modules/immodules/xim/ecore_imf_xim.c index 00340689a2..19848a299d 100644 --- a/legacy/ecore/src/modules/immodules/xim/ecore_imf_xim.c +++ b/legacy/ecore/src/modules/immodules/xim/ecore_imf_xim.c @@ -575,8 +575,12 @@ _ecore_x_event_reverse_modifiers(unsigned int state) if (state & ECORE_IMF_KEYBOARD_MODIFIER_SHIFT) modifiers |= ShiftMask; - /**< "Win" (between "Ctrl" and "A */ + /**< "Win" (between "Ctrl" and "Alt") is pressed */ if (state & ECORE_IMF_KEYBOARD_MODIFIER_WIN) + modifiers |= Mod4Mask; + + /**< "AltGr" is pressed */ + if (state & ECORE_IMF_KEYBOARD_MODIFIER_MODE) modifiers |= Mod5Mask; return modifiers;