forked from AuroraMiddleware/gtk
Fix a compatibility problem
It turns out that my attempt at handling Super, Hyper and Meta better is causing problems, mostly because Alt and Meta are commonly colocated in the modmap, and apps do a check for the Alt modifier regularly. See e.g bug 607697.
This commit is contained in:
parent
966b619705
commit
29efd9a753
@ -1006,6 +1006,7 @@ gdk_keymap_get_entries_for_keycode
|
||||
gdk_keymap_get_direction
|
||||
gdk_keymap_have_bidi_layouts
|
||||
gdk_keymap_get_caps_lock_state
|
||||
gdk_keymap_add_virtual_modifiers
|
||||
gdk_keymap_map_virtual_modifiers
|
||||
|
||||
<SUBSECTION>
|
||||
|
@ -852,6 +852,7 @@ gdk_keymap_have_bidi_layouts
|
||||
gdk_keymap_get_caps_lock_state
|
||||
gdk_keymap_lookup_key
|
||||
gdk_keymap_translate_keyboard_state
|
||||
gdk_keymap_add_virtual_modifiers
|
||||
gdk_keymap_map_virtual_modifiers
|
||||
gdk_keyval_convert_case
|
||||
gdk_keyval_from_name
|
||||
|
@ -108,6 +108,8 @@ gboolean gdk_keymap_get_entries_for_keycode (GdkKeymap *keymap,
|
||||
PangoDirection gdk_keymap_get_direction (GdkKeymap *keymap);
|
||||
gboolean gdk_keymap_have_bidi_layouts (GdkKeymap *keymap);
|
||||
gboolean gdk_keymap_get_caps_lock_state (GdkKeymap *keymap);
|
||||
void gdk_keymap_add_virtual_modifiers (GdkKeymap *keymap,
|
||||
GdkModifierType *state);
|
||||
gboolean gdk_keymap_map_virtual_modifiers (GdkKeymap *keymap,
|
||||
GdkModifierType *state);
|
||||
|
||||
|
@ -652,6 +652,13 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_keymap_add_virtual_modifiers (GdkKeymap *keymap,
|
||||
GdkModifierType *state)
|
||||
{
|
||||
/* FIXME: For now, we've mimiced the Windows backend. */
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_keymap_map_virtual_modifiers (GdkKeymap *keymap,
|
||||
GdkModifierType *state)
|
||||
|
@ -872,6 +872,12 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
||||
return tmp_keyval != GDK_VoidSymbol;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_keymap_add_virtual_modifiers (GdkKeymap *keymap,
|
||||
GdkModifierType *state)
|
||||
{
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_keymap_map_virtual_modifiers (GdkKeymap *keymap,
|
||||
GdkModifierType *state)
|
||||
|
@ -636,7 +636,7 @@ translate_key_event (GdkDisplay *display,
|
||||
&event->key.keyval,
|
||||
NULL, NULL, &consumed);
|
||||
state = event->key.state & ~consumed;
|
||||
_gdk_keymap_add_virtual_modifiers (keymap, &state);
|
||||
_gdk_keymap_add_virtual_modifiers_compat (keymap, &state);
|
||||
event->key.state |= state;
|
||||
|
||||
event->key.is_modifier = _gdk_keymap_key_is_modifier (keymap, event->key.hardware_keycode);
|
||||
|
@ -1657,8 +1657,8 @@ _gdk_x11_get_group_for_state (GdkDisplay *display,
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_keymap_add_virtual_modifiers (GdkKeymap *keymap,
|
||||
GdkModifierType *modifiers)
|
||||
_gdk_keymap_add_virtual_modifiers_compat (GdkKeymap *keymap,
|
||||
GdkModifierType *modifiers)
|
||||
{
|
||||
GdkKeymapX11 *keymap_x11;
|
||||
int i;
|
||||
@ -1666,6 +1666,51 @@ _gdk_keymap_add_virtual_modifiers (GdkKeymap *keymap,
|
||||
keymap = GET_EFFECTIVE_KEYMAP (keymap);
|
||||
keymap_x11 = GDK_KEYMAP_X11 (keymap);
|
||||
|
||||
for (i = 3; i < 8; i++)
|
||||
{
|
||||
if ((1 << i) & *modifiers)
|
||||
{
|
||||
if (keymap_x11->modmap[i] & GDK_MOD1_MASK)
|
||||
*modifiers |= GDK_MOD1_MASK;
|
||||
else if (keymap_x11->modmap[i] & GDK_SUPER_MASK)
|
||||
*modifiers |= GDK_SUPER_MASK;
|
||||
else if (keymap_x11->modmap[i] & GDK_HYPER_MASK)
|
||||
*modifiers |= GDK_HYPER_MASK;
|
||||
else if (keymap_x11->modmap[i] & GDK_META_MASK)
|
||||
*modifiers |= GDK_META_MASK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_keymap_add_virtual_modifiers:
|
||||
* @keymap: a #GdkKeymap
|
||||
* @modifiers: pointer to the modifier mask to change
|
||||
*
|
||||
* Adds virtual modifiers (i.e. Super, Hyper and Meta) which correspond
|
||||
* to the real modifiers (i.e Mod2, Mod3, ...) in @modifiers.
|
||||
* are set in @state to their non-virtual counterparts (i.e. Mod2,
|
||||
* Mod3,...) and set the corresponding bits in @modifiers.
|
||||
*
|
||||
* GDK already does this before delivering key events, but for
|
||||
* compatibility reasons, it only sets the first virtual modifier
|
||||
* it finds, whereas this function sets all matching virtual modifiers.
|
||||
*
|
||||
* This function is useful when matching key events against
|
||||
* accelerators.
|
||||
*
|
||||
* Since: 2.20
|
||||
*/
|
||||
void
|
||||
gdk_keymap_add_virtual_modifiers (GdkKeymap *keymap,
|
||||
GdkModifierType *modifiers)
|
||||
{
|
||||
GdkKeymapX11 *keymap_x11;
|
||||
int i;
|
||||
|
||||
keymap = GET_EFFECTIVE_KEYMAP (keymap);
|
||||
keymap_x11 = GDK_KEYMAP_X11 (keymap);
|
||||
|
||||
for (i = 3; i < 8; i++)
|
||||
{
|
||||
if ((1 << i) & *modifiers)
|
||||
|
@ -404,6 +404,7 @@ _gtk_key_hash_lookup (GtkKeyHash *key_hash,
|
||||
gdk_keymap_translate_keyboard_state (key_hash->keymap,
|
||||
hardware_keycode, state, group,
|
||||
&keyval, &effective_group, &level, &consumed_modifiers);
|
||||
gdk_keymap_add_virtual_modifiers (key_hash->keymap, &state);
|
||||
|
||||
GTK_NOTE (KEYBINDINGS,
|
||||
g_message ("Looking up keycode = %u, modifiers = 0x%04x,\n"
|
||||
|
Loading…
Reference in New Issue
Block a user