Commit 9c79f9f8 authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer

Turn the private #define for the group-shifting modifier into API

Add GDK_MODIFIER_INTENT_SHIFT_GROUP to enum GdkModifierIntent
and handle it in gdk_keymap_get_modifier_mask(). Add an X11
impl of the method and return keymap_x11->group_switch_mask.
Return 0 from the default impl because we don't know.
parent 1c8481a6
...@@ -634,6 +634,9 @@ gdk_keymap_real_get_modifier_mask (GdkKeymap *keymap, ...@@ -634,6 +634,9 @@ gdk_keymap_real_get_modifier_mask (GdkKeymap *keymap,
case GDK_MODIFIER_INTENT_NO_TEXT_INPUT: case GDK_MODIFIER_INTENT_NO_TEXT_INPUT:
return GDK_MOD1_MASK | GDK_CONTROL_MASK; return GDK_MOD1_MASK | GDK_CONTROL_MASK;
case GDK_MODIFIER_INTENT_SHIFT_GROUP:
return 0;
default: default:
g_return_val_if_reached (0); g_return_val_if_reached (0);
} }
......
...@@ -257,6 +257,8 @@ typedef enum ...@@ -257,6 +257,8 @@ typedef enum
* @GDK_MODIFIER_INTENT_NO_TEXT_INPUT: when any of these modifiers is pressed, the * @GDK_MODIFIER_INTENT_NO_TEXT_INPUT: when any of these modifiers is pressed, the
* key event cannot produce a symbol directly. This is meant to be used for * key event cannot produce a symbol directly. This is meant to be used for
* input methods, and for use cases like typeahead search. * input methods, and for use cases like typeahead search.
* @GDK_MODIFIER_INTENT_SHIFT_GROUP: the modifier that switches between keyboard
* groups (AltGr on X11/Windows and Option/Alt on OS X).
* *
* This enum is used with gdk_keymap_get_modifier_mask() and * This enum is used with gdk_keymap_get_modifier_mask() and
* gdk_get_modifier_mask() in order to determine what modifiers the * gdk_get_modifier_mask() in order to determine what modifiers the
...@@ -274,7 +276,8 @@ typedef enum ...@@ -274,7 +276,8 @@ typedef enum
GDK_MODIFIER_INTENT_CONTEXT_MENU, GDK_MODIFIER_INTENT_CONTEXT_MENU,
GDK_MODIFIER_INTENT_EXTEND_SELECTION, GDK_MODIFIER_INTENT_EXTEND_SELECTION,
GDK_MODIFIER_INTENT_MODIFY_SELECTION, GDK_MODIFIER_INTENT_MODIFY_SELECTION,
GDK_MODIFIER_INTENT_NO_TEXT_INPUT GDK_MODIFIER_INTENT_NO_TEXT_INPUT,
GDK_MODIFIER_INTENT_SHIFT_GROUP
} GdkModifierIntent; } GdkModifierIntent;
typedef enum typedef enum
......
...@@ -757,6 +757,9 @@ gdk_quartz_keymap_get_modifier_mask (GdkKeymap *keymap, ...@@ -757,6 +757,9 @@ gdk_quartz_keymap_get_modifier_mask (GdkKeymap *keymap,
case GDK_MODIFIER_INTENT_NO_TEXT_INPUT: case GDK_MODIFIER_INTENT_NO_TEXT_INPUT:
return GDK_MOD2_MASK | GDK_CONTROL_MASK; return GDK_MOD2_MASK | GDK_CONTROL_MASK;
case GDK_MODIFIER_INTENT_SHIFT_GROUP:
return GDK_MOD1_MASK;
default: default:
g_return_val_if_reached (0); g_return_val_if_reached (0);
} }
......
...@@ -1609,6 +1609,23 @@ gdk_x11_keymap_map_virtual_modifiers (GdkKeymap *keymap, ...@@ -1609,6 +1609,23 @@ gdk_x11_keymap_map_virtual_modifiers (GdkKeymap *keymap,
return retval; return retval;
} }
static GdkModifierType
gdk_x11_keymap_get_modifier_mask (GdkKeymap *keymap,
GdkModifierIntent intent)
{
GdkX11Keymap *keymap_x11 = GDK_X11_KEYMAP (keymap);
switch (intent)
{
case GDK_MODIFIER_INTENT_SHIFT_GROUP:
return keymap_x11->group_switch_mask;
default:
GDK_KEYMAP_CLASS (gdk_x11_keymap_parent_class)->get_modifier_mask (keymap,
intent);
}
}
static void static void
gdk_x11_keymap_class_init (GdkX11KeymapClass *klass) gdk_x11_keymap_class_init (GdkX11KeymapClass *klass)
{ {
...@@ -1627,4 +1644,5 @@ gdk_x11_keymap_class_init (GdkX11KeymapClass *klass) ...@@ -1627,4 +1644,5 @@ gdk_x11_keymap_class_init (GdkX11KeymapClass *klass)
keymap_class->translate_keyboard_state = gdk_x11_keymap_translate_keyboard_state; keymap_class->translate_keyboard_state = gdk_x11_keymap_translate_keyboard_state;
keymap_class->add_virtual_modifiers = gdk_x11_keymap_add_virtual_modifiers; keymap_class->add_virtual_modifiers = gdk_x11_keymap_add_virtual_modifiers;
keymap_class->map_virtual_modifiers = gdk_x11_keymap_map_virtual_modifiers; keymap_class->map_virtual_modifiers = gdk_x11_keymap_map_virtual_modifiers;
keymap_class->get_modifier_mask = gdk_x11_keymap_get_modifier_mask;
} }
...@@ -395,6 +395,7 @@ _gtk_key_hash_lookup (GtkKeyHash *key_hash, ...@@ -395,6 +395,7 @@ _gtk_key_hash_lookup (GtkKeyHash *key_hash,
gint level; gint level;
GdkModifierType modifiers; GdkModifierType modifiers;
GdkModifierType consumed_modifiers; GdkModifierType consumed_modifiers;
GdkModifierType shift_group_mask;
gboolean group_mod_is_accel_mod = FALSE; gboolean group_mod_is_accel_mod = FALSE;
const GdkModifierType xmods = GDK_MOD2_MASK|GDK_MOD3_MASK|GDK_MOD4_MASK|GDK_MOD5_MASK; const GdkModifierType xmods = GDK_MOD2_MASK|GDK_MOD3_MASK|GDK_MOD4_MASK|GDK_MOD5_MASK;
const GdkModifierType vmods = GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK; const GdkModifierType vmods = GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK;
...@@ -411,7 +412,9 @@ _gtk_key_hash_lookup (GtkKeyHash *key_hash, ...@@ -411,7 +412,9 @@ _gtk_key_hash_lookup (GtkKeyHash *key_hash,
/* if the group-toggling modifier is part of the default accel mod /* if the group-toggling modifier is part of the default accel mod
* mask, and it is active, disable it for matching * mask, and it is active, disable it for matching
*/ */
if (mask & GTK_TOGGLE_GROUP_MOD_MASK) shift_group_mask = gdk_keymap_get_modifier_mask (key_hash->keymap,
GDK_MODIFIER_INTENT_SHIFT_GROUP);
if (mask & shift_group_mask)
group_mod_is_accel_mod = TRUE; group_mod_is_accel_mod = TRUE;
gdk_keymap_map_virtual_modifiers (key_hash->keymap, &mask); gdk_keymap_map_virtual_modifiers (key_hash->keymap, &mask);
...@@ -449,8 +452,7 @@ _gtk_key_hash_lookup (GtkKeyHash *key_hash, ...@@ -449,8 +452,7 @@ _gtk_key_hash_lookup (GtkKeyHash *key_hash,
* otherwise we can get multiple exact matches, some being * otherwise we can get multiple exact matches, some being
* bogus */ * bogus */
(!group_mod_is_accel_mod || (!group_mod_is_accel_mod ||
(state & GTK_TOGGLE_GROUP_MOD_MASK) == (state & shift_group_mask) == (entry->modifiers & shift_group_mask)))
(entry->modifiers & GTK_TOGGLE_GROUP_MOD_MASK)))
{ {
GTK_NOTE (KEYBINDINGS, GTK_NOTE (KEYBINDINGS,
......
...@@ -216,15 +216,18 @@ _gtk_translate_keyboard_accel_state (GdkKeymap *keymap, ...@@ -216,15 +216,18 @@ _gtk_translate_keyboard_accel_state (GdkKeymap *keymap,
gint *level, gint *level,
GdkModifierType *consumed_modifiers) GdkModifierType *consumed_modifiers)
{ {
GdkModifierType shift_group_mask;
gboolean group_mask_disabled = FALSE; gboolean group_mask_disabled = FALSE;
gboolean retval; gboolean retval;
/* if the group-toggling modifier is part of the accel mod mask, and /* if the group-toggling modifier is part of the accel mod mask, and
* it is active, disable it for matching * it is active, disable it for matching
*/ */
if (accel_mask & state & GTK_TOGGLE_GROUP_MOD_MASK) shift_group_mask = gdk_keymap_get_modifier_mask (keymap,
GDK_MODIFIER_INTENT_SHIFT_GROUP);
if (accel_mask & state & shift_group_mask)
{ {
state &= ~GTK_TOGGLE_GROUP_MOD_MASK; state &= ~shift_group_mask;
group = 0; group = 0;
group_mask_disabled = TRUE; group_mask_disabled = TRUE;
} }
...@@ -244,7 +247,7 @@ _gtk_translate_keyboard_accel_state (GdkKeymap *keymap, ...@@ -244,7 +247,7 @@ _gtk_translate_keyboard_accel_state (GdkKeymap *keymap,
*effective_group = 1; *effective_group = 1;
if (consumed_modifiers) if (consumed_modifiers)
*consumed_modifiers &= ~GTK_TOGGLE_GROUP_MOD_MASK; *consumed_modifiers &= ~shift_group_mask;
} }
return retval; return retval;
......
...@@ -62,13 +62,6 @@ GdkModifierType _gtk_replace_virtual_modifiers (GdkKeymap *keymap, ...@@ -62,13 +62,6 @@ GdkModifierType _gtk_replace_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType modifiers); GdkModifierType modifiers);
GdkModifierType _gtk_get_primary_accel_mod (void); GdkModifierType _gtk_get_primary_accel_mod (void);
/* temp hack, will go away soon --mitch */
#ifndef GDK_WINDOWING_QUARTZ
#define GTK_TOGGLE_GROUP_MOD_MASK 0
#else
#define GTK_TOGGLE_GROUP_MOD_MASK GDK_MOD1_MASK
#endif
gboolean _gtk_translate_keyboard_accel_state (GdkKeymap *keymap, gboolean _gtk_translate_keyboard_accel_state (GdkKeymap *keymap,
guint hardware_keycode, guint hardware_keycode,
GdkModifierType state, GdkModifierType state,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment