Commit 708e1a95 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Implement "fuzzy" key binding lookups; allow matches on key and level but

Wed Feb 20 14:26:47 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkkeyhash.[ch]: Implement "fuzzy" key binding lookups;
        allow matches on key and level but not group. Also, implement
        ignoring "consumed modifiers correctly."

        * gtk/gtkaccelgroup.c gtk/gtkbindings.c: Convert to using
        GtkKeyHash.

        * gtk/gtkdebug.h gtk/gtkmain.c: Support GTK_DEBUG=keybindings

        * gdk/x11/gdkevents-x11.c (gdk_event_translate): Fill in
        the group for key release events as well as key press events.

        * gdk/gdkkeys.h gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
        Rename unused_modifiers to consumed_modifiers, make the docs and
        non-Xkb implementation match the Xkb implementation.

        * gdk/linux-fb/gdkkeyboard-fb.c gdk/win32/gdkkeys-win32.c: Propagate
        doc and parameter name changes.

        * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
        XkbTranslateKeyCode doesn't handle LockMask, we need to handle
        it ourselves.

        * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Force
        <Shift>Tab to give GDK_ISO_Left_Tab, since we need consistency
        to allow dealing with ISO_Left_Tab.

        * gtk/gtkwindow.c gtk/gtktextview.c gtk/gtkscrolledwindow.c
        gtk/gtkpaned.c gtk/gtkcombo.c  gtk/gtknotebook.c:
        Remove inappropriate uses of GDK_ISO_Left_Tab. (GDK_ISO_Left_Tab
        or <Shift>Tab both are equivalent as a binding specifier.)

        * gtk/gtkbutton.c (gtk_button_class_init): Make ::activate
        GTK_RUN_ACTION, so you can bind an accelerator to it.

        * gtk/gtklabel.c (gtk_label_set_uline_text_internal): Call
        gdk_unicode_to_keyval on the mnemonic character.

        * tests/testgtk.c: Add a test for the new fuzzy key binding matching.
parent 3b94ae4b
Wed Feb 20 14:26:47 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkkeyhash.[ch]: Implement "fuzzy" key binding lookups;
allow matches on key and level but not group. Also, implement
ignoring "consumed modifiers correctly."
* gtk/gtkaccelgroup.c gtk/gtkbindings.c: Convert to using
GtkKeyHash.
* gtk/gtkdebug.h gtk/gtkmain.c: Support GTK_DEBUG=keybindings
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Fill in
the group for key release events as well as key press events.
* gdk/gdkkeys.h gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
Rename unused_modifiers to consumed_modifiers, make the docs and
non-Xkb implementation match the Xkb implementation.
* gdk/linux-fb/gdkkeyboard-fb.c gdk/win32/gdkkeys-win32.c: Propagate
doc and parameter name changes.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
XkbTranslateKeyCode doesn't handle LockMask, we need to handle
it ourselves.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Force
<Shift>Tab to give GDK_ISO_Left_Tab, since we need consistency
to allow dealing with ISO_Left_Tab.
* gtk/gtkwindow.c gtk/gtktextview.c gtk/gtkscrolledwindow.c
gtk/gtkpaned.c gtk/gtkcombo.c gtk/gtknotebook.c:
Remove inappropriate uses of GDK_ISO_Left_Tab. (GDK_ISO_Left_Tab
or <Shift>Tab both are equivalent as a binding specifier.)
* gtk/gtkbutton.c (gtk_button_class_init): Make ::activate
GTK_RUN_ACTION, so you can bind an accelerator to it.
* gtk/gtklabel.c (gtk_label_set_uline_text_internal): Call
gdk_unicode_to_keyval on the mnemonic character.
* tests/testgtk.c: Add a test for the new fuzzy key binding matching.
2002-02-21 jacob berkman <jacob@ximian.com>
* gtk/theme-bits/Makefile.am (EXTRA_DIST): inconsitent files are
......
Wed Feb 20 14:26:47 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkkeyhash.[ch]: Implement "fuzzy" key binding lookups;
allow matches on key and level but not group. Also, implement
ignoring "consumed modifiers correctly."
* gtk/gtkaccelgroup.c gtk/gtkbindings.c: Convert to using
GtkKeyHash.
* gtk/gtkdebug.h gtk/gtkmain.c: Support GTK_DEBUG=keybindings
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Fill in
the group for key release events as well as key press events.
* gdk/gdkkeys.h gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
Rename unused_modifiers to consumed_modifiers, make the docs and
non-Xkb implementation match the Xkb implementation.
* gdk/linux-fb/gdkkeyboard-fb.c gdk/win32/gdkkeys-win32.c: Propagate
doc and parameter name changes.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
XkbTranslateKeyCode doesn't handle LockMask, we need to handle
it ourselves.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Force
<Shift>Tab to give GDK_ISO_Left_Tab, since we need consistency
to allow dealing with ISO_Left_Tab.
* gtk/gtkwindow.c gtk/gtktextview.c gtk/gtkscrolledwindow.c
gtk/gtkpaned.c gtk/gtkcombo.c gtk/gtknotebook.c:
Remove inappropriate uses of GDK_ISO_Left_Tab. (GDK_ISO_Left_Tab
or <Shift>Tab both are equivalent as a binding specifier.)
* gtk/gtkbutton.c (gtk_button_class_init): Make ::activate
GTK_RUN_ACTION, so you can bind an accelerator to it.
* gtk/gtklabel.c (gtk_label_set_uline_text_internal): Call
gdk_unicode_to_keyval on the mnemonic character.
* tests/testgtk.c: Add a test for the new fuzzy key binding matching.
2002-02-21 jacob berkman <jacob@ximian.com>
* gtk/theme-bits/Makefile.am (EXTRA_DIST): inconsitent files are
......
Wed Feb 20 14:26:47 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkkeyhash.[ch]: Implement "fuzzy" key binding lookups;
allow matches on key and level but not group. Also, implement
ignoring "consumed modifiers correctly."
* gtk/gtkaccelgroup.c gtk/gtkbindings.c: Convert to using
GtkKeyHash.
* gtk/gtkdebug.h gtk/gtkmain.c: Support GTK_DEBUG=keybindings
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Fill in
the group for key release events as well as key press events.
* gdk/gdkkeys.h gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
Rename unused_modifiers to consumed_modifiers, make the docs and
non-Xkb implementation match the Xkb implementation.
* gdk/linux-fb/gdkkeyboard-fb.c gdk/win32/gdkkeys-win32.c: Propagate
doc and parameter name changes.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
XkbTranslateKeyCode doesn't handle LockMask, we need to handle
it ourselves.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Force
<Shift>Tab to give GDK_ISO_Left_Tab, since we need consistency
to allow dealing with ISO_Left_Tab.
* gtk/gtkwindow.c gtk/gtktextview.c gtk/gtkscrolledwindow.c
gtk/gtkpaned.c gtk/gtkcombo.c gtk/gtknotebook.c:
Remove inappropriate uses of GDK_ISO_Left_Tab. (GDK_ISO_Left_Tab
or <Shift>Tab both are equivalent as a binding specifier.)
* gtk/gtkbutton.c (gtk_button_class_init): Make ::activate
GTK_RUN_ACTION, so you can bind an accelerator to it.
* gtk/gtklabel.c (gtk_label_set_uline_text_internal): Call
gdk_unicode_to_keyval on the mnemonic character.
* tests/testgtk.c: Add a test for the new fuzzy key binding matching.
2002-02-21 jacob berkman <jacob@ximian.com>
* gtk/theme-bits/Makefile.am (EXTRA_DIST): inconsitent files are
......
Wed Feb 20 14:26:47 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkkeyhash.[ch]: Implement "fuzzy" key binding lookups;
allow matches on key and level but not group. Also, implement
ignoring "consumed modifiers correctly."
* gtk/gtkaccelgroup.c gtk/gtkbindings.c: Convert to using
GtkKeyHash.
* gtk/gtkdebug.h gtk/gtkmain.c: Support GTK_DEBUG=keybindings
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Fill in
the group for key release events as well as key press events.
* gdk/gdkkeys.h gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
Rename unused_modifiers to consumed_modifiers, make the docs and
non-Xkb implementation match the Xkb implementation.
* gdk/linux-fb/gdkkeyboard-fb.c gdk/win32/gdkkeys-win32.c: Propagate
doc and parameter name changes.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
XkbTranslateKeyCode doesn't handle LockMask, we need to handle
it ourselves.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Force
<Shift>Tab to give GDK_ISO_Left_Tab, since we need consistency
to allow dealing with ISO_Left_Tab.
* gtk/gtkwindow.c gtk/gtktextview.c gtk/gtkscrolledwindow.c
gtk/gtkpaned.c gtk/gtkcombo.c gtk/gtknotebook.c:
Remove inappropriate uses of GDK_ISO_Left_Tab. (GDK_ISO_Left_Tab
or <Shift>Tab both are equivalent as a binding specifier.)
* gtk/gtkbutton.c (gtk_button_class_init): Make ::activate
GTK_RUN_ACTION, so you can bind an accelerator to it.
* gtk/gtklabel.c (gtk_label_set_uline_text_internal): Call
gdk_unicode_to_keyval on the mnemonic character.
* tests/testgtk.c: Add a test for the new fuzzy key binding matching.
2002-02-21 jacob berkman <jacob@ximian.com>
* gtk/theme-bits/Makefile.am (EXTRA_DIST): inconsitent files are
......
Wed Feb 20 14:26:47 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkkeyhash.[ch]: Implement "fuzzy" key binding lookups;
allow matches on key and level but not group. Also, implement
ignoring "consumed modifiers correctly."
* gtk/gtkaccelgroup.c gtk/gtkbindings.c: Convert to using
GtkKeyHash.
* gtk/gtkdebug.h gtk/gtkmain.c: Support GTK_DEBUG=keybindings
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Fill in
the group for key release events as well as key press events.
* gdk/gdkkeys.h gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
Rename unused_modifiers to consumed_modifiers, make the docs and
non-Xkb implementation match the Xkb implementation.
* gdk/linux-fb/gdkkeyboard-fb.c gdk/win32/gdkkeys-win32.c: Propagate
doc and parameter name changes.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
XkbTranslateKeyCode doesn't handle LockMask, we need to handle
it ourselves.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Force
<Shift>Tab to give GDK_ISO_Left_Tab, since we need consistency
to allow dealing with ISO_Left_Tab.
* gtk/gtkwindow.c gtk/gtktextview.c gtk/gtkscrolledwindow.c
gtk/gtkpaned.c gtk/gtkcombo.c gtk/gtknotebook.c:
Remove inappropriate uses of GDK_ISO_Left_Tab. (GDK_ISO_Left_Tab
or <Shift>Tab both are equivalent as a binding specifier.)
* gtk/gtkbutton.c (gtk_button_class_init): Make ::activate
GTK_RUN_ACTION, so you can bind an accelerator to it.
* gtk/gtklabel.c (gtk_label_set_uline_text_internal): Call
gdk_unicode_to_keyval on the mnemonic character.
* tests/testgtk.c: Add a test for the new fuzzy key binding matching.
2002-02-21 jacob berkman <jacob@ximian.com>
* gtk/theme-bits/Makefile.am (EXTRA_DIST): inconsitent files are
......
Wed Feb 20 14:26:47 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkkeyhash.[ch]: Implement "fuzzy" key binding lookups;
allow matches on key and level but not group. Also, implement
ignoring "consumed modifiers correctly."
* gtk/gtkaccelgroup.c gtk/gtkbindings.c: Convert to using
GtkKeyHash.
* gtk/gtkdebug.h gtk/gtkmain.c: Support GTK_DEBUG=keybindings
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Fill in
the group for key release events as well as key press events.
* gdk/gdkkeys.h gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
Rename unused_modifiers to consumed_modifiers, make the docs and
non-Xkb implementation match the Xkb implementation.
* gdk/linux-fb/gdkkeyboard-fb.c gdk/win32/gdkkeys-win32.c: Propagate
doc and parameter name changes.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
XkbTranslateKeyCode doesn't handle LockMask, we need to handle
it ourselves.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Force
<Shift>Tab to give GDK_ISO_Left_Tab, since we need consistency
to allow dealing with ISO_Left_Tab.
* gtk/gtkwindow.c gtk/gtktextview.c gtk/gtkscrolledwindow.c
gtk/gtkpaned.c gtk/gtkcombo.c gtk/gtknotebook.c:
Remove inappropriate uses of GDK_ISO_Left_Tab. (GDK_ISO_Left_Tab
or <Shift>Tab both are equivalent as a binding specifier.)
* gtk/gtkbutton.c (gtk_button_class_init): Make ::activate
GTK_RUN_ACTION, so you can bind an accelerator to it.
* gtk/gtklabel.c (gtk_label_set_uline_text_internal): Call
gdk_unicode_to_keyval on the mnemonic character.
* tests/testgtk.c: Add a test for the new fuzzy key binding matching.
2002-02-21 jacob berkman <jacob@ximian.com>
* gtk/theme-bits/Makefile.am (EXTRA_DIST): inconsitent files are
......
Wed Feb 20 14:26:47 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkkeyhash.[ch]: Implement "fuzzy" key binding lookups;
allow matches on key and level but not group. Also, implement
ignoring "consumed modifiers correctly."
* gtk/gtkaccelgroup.c gtk/gtkbindings.c: Convert to using
GtkKeyHash.
* gtk/gtkdebug.h gtk/gtkmain.c: Support GTK_DEBUG=keybindings
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Fill in
the group for key release events as well as key press events.
* gdk/gdkkeys.h gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
Rename unused_modifiers to consumed_modifiers, make the docs and
non-Xkb implementation match the Xkb implementation.
* gdk/linux-fb/gdkkeyboard-fb.c gdk/win32/gdkkeys-win32.c: Propagate
doc and parameter name changes.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
XkbTranslateKeyCode doesn't handle LockMask, we need to handle
it ourselves.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Force
<Shift>Tab to give GDK_ISO_Left_Tab, since we need consistency
to allow dealing with ISO_Left_Tab.
* gtk/gtkwindow.c gtk/gtktextview.c gtk/gtkscrolledwindow.c
gtk/gtkpaned.c gtk/gtkcombo.c gtk/gtknotebook.c:
Remove inappropriate uses of GDK_ISO_Left_Tab. (GDK_ISO_Left_Tab
or <Shift>Tab both are equivalent as a binding specifier.)
* gtk/gtkbutton.c (gtk_button_class_init): Make ::activate
GTK_RUN_ACTION, so you can bind an accelerator to it.
* gtk/gtklabel.c (gtk_label_set_uline_text_internal): Call
gdk_unicode_to_keyval on the mnemonic character.
* tests/testgtk.c: Add a test for the new fuzzy key binding matching.
2002-02-21 jacob berkman <jacob@ximian.com>
* gtk/theme-bits/Makefile.am (EXTRA_DIST): inconsitent files are
......
Thu Feb 21 12:11:42 2002 Owen Taylor <otaylor@redhat.com>
* gtk/Makefile.am (IGNORE_HFILES): Add gtkkeyhash.h
2002-02-20 Sven Neumann <sven@gimp.org>
* gtk/gtk-sections.txt
......
......@@ -139,8 +139,10 @@ be mapped to a keyval.
@keyval:
@effective_group:
@level:
@unused_modifiers:
@consumed_modifiers:
@Returns:
<!-- # Unused Parameters # -->
@unused_modifiers:
<!-- ##### FUNCTION gdk_keymap_get_entries_for_keyval ##### -->
......
......@@ -33,6 +33,7 @@ IGNORE_HFILES= \
gtkhsv.h \
gtkimmodule.h \
gtkintl.h \
gtkkeyhash.h \
gtkmarshal.h \
gtkprivate.h \
gtktreeprivate.h \
......
......@@ -88,7 +88,7 @@ gboolean gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *unused_modifiers);
GdkModifierType *consumed_modifiers);
gboolean gdk_keymap_get_entries_for_keyval (GdkKeymap *keymap,
guint keyval,
GdkKeymapKey **keys,
......
......@@ -61,7 +61,7 @@ struct _GdkFBKeyboardDevice {
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *unused_modifiers);
GdkModifierType *consumed_modifiers);
gboolean (*get_entries_for_keyval) (GdkFBKeyboard *kb,
guint keyval,
GdkKeymapKey **keys,
......@@ -89,7 +89,7 @@ static gboolean xlate_translate (GdkFBKeyboard *kb,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *unused_modifiers);
GdkModifierType *consumed_modifiers);
static gboolean xlate_get_for_keyval (GdkFBKeyboard *kb,
guint keyval,
GdkKeymapKey **keys,
......@@ -111,7 +111,7 @@ static gboolean raw_translate (GdkFBKeyboard *kb,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *unused_modifiers);
GdkModifierType *consumed_modifiers);
static gboolean raw_get_for_keyval (GdkFBKeyboard *kb,
guint keyval,
GdkKeymapKey **keys,
......@@ -335,13 +335,13 @@ gdk_keymap_lookup_key (GdkKeymap *keymap,
* @keyval: return location for keyval
* @effective_group: return location for effective group
* @level: return location for level
* @unused_modifiers: return location for modifiers that didn't affect the group or level
* @consumed_modifiers: return location for modifiers that were used to determine the group or level
*
*
* Translates the contents of a #GdkEventKey into a keyval, effective
* group, and level. Modifiers that didn't affect the translation and
* are thus available for application use are returned in
* @unused_modifiers. See gdk_keyval_get_keys() for an explanation of
* group, and level. Modifiers that affected the translation and
* are thus unavailable for application use are returned in
* @consumed_modifiers. See gdk_keyval_get_keys() for an explanation of
* groups and levels. The @effective_group is the group that was
* actually used for the translation; some keys such as Enter are not
* affected by the active keyboard group. The @level is derived from
......@@ -358,7 +358,7 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *unused_modifiers)
GdkModifierType *consumed_modifiers)
{
g_return_val_if_fail (keymap == NULL || GDK_IS_KEYMAP (keymap), FALSE);
g_return_val_if_fail (group < 4, FALSE);
......@@ -370,7 +370,7 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
keyval,
effective_group,
level,
unused_modifiers);
consumed_modifiers);
}
static void
......@@ -934,7 +934,7 @@ xlate_translate (GdkFBKeyboard *kb,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *unused_modifiers)
GdkModifierType *consumed_modifiers)
{
g_warning ("xlate_translate() NIY");
return FALSE;
......@@ -1445,7 +1445,7 @@ raw_translate (GdkFBKeyboard *kb,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *unused_modifiers)
GdkModifierType *consumed_modifiers)
{
g_warning ("raw_translate() NIY");
return FALSE;
......
......@@ -261,13 +261,13 @@ gdk_keymap_lookup_key (GdkKeymap *keymap,
* @keyval: return location for keyval
* @effective_group: return location for effective group
* @level: return location for level
* @unused_modifiers: return location for modifiers that didn't affect the group or level
* @consumed_modifiers: return location for modifiers that were used to determine the group or level
*
*
* Translates the contents of a #GdkEventKey into a keyval, effective
* group, and level. Modifiers that didn't affect the translation and
* are thus available for application use are returned in
* @unused_modifiers. See gdk_keyval_get_keys() for an explanation of
* group, and level. Modifiers that affected the translation and
* are thus unavailable for application use are returned in
* @consumed_modifiers. See gdk_keyval_get_keys() for an explanation of
* groups and levels. The @effective_group is the group that was
* actually used for the translation; some keys such as Enter are not
* affected by the active keyboard group. The @level is derived from
......@@ -284,7 +284,7 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *unused_modifiers)
GdkModifierType *consumed_modifiers)
{
g_return_val_if_fail (keymap == NULL || GDK_IS_KEYMAP (keymap), FALSE);
g_return_val_if_fail (group < 4, FALSE);
......
......@@ -679,6 +679,8 @@ gdk_event_translate (GdkEvent *event,
event->key.length = 0;
event->key.string = NULL;
event->key.group = (xevent->xkey.state & KEYBOARD_GROUP_MASK) >> KEYBOARD_GROUP_SHIFT;
break;
case ButtonPress:
......
......@@ -735,13 +735,13 @@ MyEnhancedXkbTranslateKeyCode(register XkbDescPtr xkb,
* @keyval: return location for keyval
* @effective_group: return location for effective group
* @level: return location for level
* @unused_modifiers: return location for modifiers that didn't affect the group or level
* @consumed_modifiers: return location for modifiers that were used to determine the group or level
*
*
* Translates the contents of a #GdkEventKey into a keyval, effective
* group, and level. Modifiers that didn't affect the translation and
* are thus available for application use are returned in
* @unused_modifiers. See gdk_keyval_get_keys() for an explanation of
* group, and level. Modifiers that affected the translation and
* are thus unavailable for application use are returned in
* @consumed_modifiers. See gdk_keyval_get_keys() for an explanation of
* groups and levels. The @effective_group is the group that was
* actually used for the translation; some keys such as Enter are not
* affected by the active keyboard group. The @level is derived from
......@@ -758,9 +758,10 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *unused_modifiers)
GdkModifierType *consumed_modifiers)
{
KeySym tmp_keyval = NoSymbol;
guint tmp_modifiers;
g_return_val_if_fail (keymap == NULL || GDK_IS_KEYMAP (keymap), FALSE);
g_return_val_if_fail (group < 4, FALSE);
......@@ -771,8 +772,8 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
*effective_group = 0;
if (level)
*level = 0;
if (unused_modifiers)
*unused_modifiers = state;
if (consumed_modifiers)
*consumed_modifiers = 0;
update_keyrange ();
......@@ -792,13 +793,18 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
MyEnhancedXkbTranslateKeyCode (xkb,
hardware_keycode,
state,
unused_modifiers,
&tmp_modifiers,
&tmp_keyval,
effective_group,
level);
if (keyval)
*keyval = tmp_keyval;
if (state & ~tmp_modifiers & LockMask)
tmp_keyval = gdk_keyval_to_upper (tmp_keyval);
/* We need to augment the consumed modifiers with LockMask, since
* we handle that ourselves, and also with the group bits
*/
tmp_modifiers |= LockMask | 1 << 13 | 1 << 14;
}
else
#endif
......@@ -819,14 +825,7 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
tmp_keyval = XKeycodeToKeysym (gdk_display, hardware_keycode,
group * keysyms_per_keycode + shift_level);
if (keyval)
*keyval = tmp_keyval;
if (unused_modifiers)
{
*unused_modifiers = state;
*unused_modifiers &= ~(GDK_SHIFT_MASK | GDK_LOCK_MASK | group_switch_mask);
}
tmp_modifiers = GDK_SHIFT_MASK | GDK_LOCK_MASK | group_switch_mask;
if (effective_group)
*effective_group = (state & group_switch_mask) ? 1 : 0;
......@@ -835,6 +834,23 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
*level = shift_level;
}
/* GDK_ISO_Left_Tab, as usually configured through XKB, really messes
* up the whole idea of "consumed modifiers" because shift is consumed.
* However, <shift>Tab is not _consistently_ GDK_ISO_Left_Tab, so people
* can't bind to GDK_ISO_Left_Tab instead. So, we force consistency here.
*/
if (tmp_keyval == GDK_Tab && (tmp_modifiers & GDK_SHIFT_MASK == 0))
{
tmp_keyval = GDK_ISO_Left_Tab;
tmp_modifiers |= GDK_SHIFT_MASK;
}
if (consumed_modifiers)
*consumed_modifiers = tmp_modifiers;
if (keyval)
*keyval = tmp_keyval;
return tmp_keyval != NoSymbol;
}
......
......@@ -308,6 +308,8 @@ gtk_c_sources = @STRIP_BEGIN@ \
gtkinvisible.c \
gtkitem.c \
gtkitemfactory.c \
gtkkeyhash.c \
gtkkeyhash.h \
gtklabel.c \
gtklayout.c \
gtklist.c \
......
......@@ -714,7 +714,7 @@ gtk_accel_group_from_accel_closure (GClosure *closure)
g_return_val_if_fail (closure != NULL, NULL);
/* a few remarks on wat we do here. in general, we need a way to reverse lookup
/* a few remarks on what we do here. in general, we need a way to reverse lookup
* accel_groups from closures that are being used in accel groups. this could
* be done e.g via a hashtable. it is however cheaper (memory wise) to just
* use the invalidation notifier on the closure itself (which we need to install
......
......@@ -29,7 +29,9 @@
#include <string.h>
#include <stdarg.h>
#include <gdkkeysyms.h>
#include "gtkbindings.h"
#include "gtkkeyhash.h"
#include "gtksignal.h"
#include "gtkwidget.h"
#include "gtkrc.h"
......@@ -49,6 +51,7 @@ typedef struct {
/* --- variables --- */
static GHashTable *binding_entry_hash_table = NULL;
static GSList *binding_key_hashes = NULL;
static GSList *binding_set_list = NULL;
static const gchar *key_class_binding_set = "gtk-class-binding-set";
static GQuark key_id_class_binding_set = 0;
......@@ -107,11 +110,81 @@ binding_entries_compare (gconstpointer a,
return (ea->keyval == eb->keyval && ea->modifiers == eb->modifiers);
}
static void
binding_key_hash_insert_entry (GtkKeyHash *key_hash,
GtkBindingEntry *entry)
{
guint keyval = entry->keyval;
/* We store lowercased accelerators. To deal with this, if <Shift>
* was specified, uppercase.
*/
if (entry->modifiers & GDK_SHIFT_MASK)
{
if (keyval == GDK_Tab)
keyval = GDK_ISO_Left_Tab;
else
keyval = gdk_keyval_to_upper (keyval);
}
_gtk_key_hash_add_entry (key_hash, keyval, entry->modifiers & ~GDK_RELEASE_MASK, entry);
}
static void
binding_key_hash_destroy (gpointer data)
{
GtkKeyHash *key_hash = data;
binding_key_hashes = g_slist_remove (binding_key_hashes, key_hash);
_gtk_key_hash_free (key_hash);
}
static void
insert_entries_into_key_hash (gpointer key,
gpointer value,
gpointer data)
{
GtkKeyHash *key_hash = data;
GtkBindingEntry *entry = value;
for (; entry; entry = entry->hash_next)
binding_key_hash_insert_entry (key_hash, entry);
}
static GtkKeyHash *
binding_key_hash_for_keymap (GdkKeymap *keymap)
{
static GQuark key_hash_quark = 0;
GtkKeyHash *key_hash;
if (!key_hash_quark)
key_hash_quark = g_quark_from_static_string ("gtk-binding-key-hash");
key_hash = g_object_get_qdata (G_OBJECT (keymap), key_hash_quark);
if (!key_hash)
{
key_hash = _gtk_key_hash_new (keymap, NULL);
g_object_set_qdata_full (G_OBJECT (keymap), key_hash_quark, key_hash, binding_key_hash_destroy);
if (binding_entry_hash_table)
g_hash_table_foreach (binding_entry_hash_table,
insert_entries_into_key_hash,
key_hash);
binding_key_hashes = g_slist_prepend (binding_key_hashes, key_hash);
}
return key_hash;
}
static GtkBindingEntry*
binding_entry_new (GtkBindingSet *binding_set,
guint keyval,
GdkModifierType modifiers)
{
GSList *tmp_list;
GtkBindingEntry *entry;
if (!binding_entry_hash_table)
......@@ -132,6 +205,12 @@ binding_entry_new (GtkBindingSet *binding_set,
if (entry->hash_next)
g_hash_table_remove (binding_entry_hash_table, entry->hash_next);
g_hash_table_insert (binding_entry_hash_table, entry, entry);
for (tmp_list = binding_key_hashes; tmp_list; tmp_list = tmp_list->next)
{
GtkKeyHash *key_hash = tmp_list->data;
binding_key_hash_insert_entry (key_hash, entry);
}
return entry;
}
......@@ -167,6 +246,7 @@ binding_entry_destroy (GtkBindingEntry *entry)
register GtkBindingEntry *tmp;
GtkBindingEntry *begin;
register GtkBindingEntry *last;
GSList *tmp_list;
/* unlink from binding set
*/
......@@ -214,27 +294,18 @@ binding_entry_destroy (GtkBindingEntry *entry)
g_hash_table_insert (binding_entry_hash_table, begin, begin);
}
for (tmp_list = binding_key_hashes; tmp_list; tmp_list = tmp_list->next)
{
GtkKeyHash *key_hash = tmp_list->data;
_gtk_key_hash_remove_entry (key_hash, entry);
}
entry->destroyed = TRUE;
if (!entry->in_emission)
binding_entry_free (entry);
}
static GtkBindingEntry*
binding_ht_lookup_list (guint keyval,
GdkModifierType modifiers)
{
GtkBindingEntry lookup_entry = { 0 };