Partial fix for problem where keypad keys acted as shift-arrows in an
Fri Mar 22 11:29:11 2002 Owen Taylor <otaylor@redhat.com> Partial fix for problem where keypad keys acted as shift-arrows in an entry rather than arrows (#74327) * gtk/gtkkeyhash.c (_gtk_key_hash_lookup): Sort lookup results by number of modifiers in the entry. Fixes problem where if a key matched both modified and unmodified key bindings ... e.g., the distinguishing key binding was consumed, then it was random which was used. * gtk/gtkbindings.c (gtk_binding_entries_sort_patterns): Catch the case where there are multiple entries from the same bindingset (with different modifiers), and use only the first entry, which, with the change in _gtk_key_hash_lookup()
This commit is contained in:
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
|||||||
|
Fri Mar 22 11:29:11 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Partial fix for problem where keypad keys acted
|
||||||
|
as shift-arrows in an entry rather than arrows (#74327)
|
||||||
|
|
||||||
|
* gtk/gtkkeyhash.c (_gtk_key_hash_lookup): Sort lookup
|
||||||
|
results by number of modifiers in the entry. Fixes
|
||||||
|
problem where if a key matched both modified and unmodified
|
||||||
|
key bindings ... e.g., the distinguishing key binding
|
||||||
|
was consumed, then it was random which was used.
|
||||||
|
|
||||||
|
* gtk/gtkbindings.c (gtk_binding_entries_sort_patterns):
|
||||||
|
Catch the case where there are multiple entries from the
|
||||||
|
same bindingset (with different modifiers), and use only
|
||||||
|
the first entry, which, with the change in _gtk_key_hash_lookup()
|
||||||
|
will be the preferred value.
|
||||||
|
|
||||||
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
Fri Mar 22 11:29:11 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Partial fix for problem where keypad keys acted
|
||||||
|
as shift-arrows in an entry rather than arrows (#74327)
|
||||||
|
|
||||||
|
* gtk/gtkkeyhash.c (_gtk_key_hash_lookup): Sort lookup
|
||||||
|
results by number of modifiers in the entry. Fixes
|
||||||
|
problem where if a key matched both modified and unmodified
|
||||||
|
key bindings ... e.g., the distinguishing key binding
|
||||||
|
was consumed, then it was random which was used.
|
||||||
|
|
||||||
|
* gtk/gtkbindings.c (gtk_binding_entries_sort_patterns):
|
||||||
|
Catch the case where there are multiple entries from the
|
||||||
|
same bindingset (with different modifiers), and use only
|
||||||
|
the first entry, which, with the change in _gtk_key_hash_lookup()
|
||||||
|
will be the preferred value.
|
||||||
|
|
||||||
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
Fri Mar 22 11:29:11 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Partial fix for problem where keypad keys acted
|
||||||
|
as shift-arrows in an entry rather than arrows (#74327)
|
||||||
|
|
||||||
|
* gtk/gtkkeyhash.c (_gtk_key_hash_lookup): Sort lookup
|
||||||
|
results by number of modifiers in the entry. Fixes
|
||||||
|
problem where if a key matched both modified and unmodified
|
||||||
|
key bindings ... e.g., the distinguishing key binding
|
||||||
|
was consumed, then it was random which was used.
|
||||||
|
|
||||||
|
* gtk/gtkbindings.c (gtk_binding_entries_sort_patterns):
|
||||||
|
Catch the case where there are multiple entries from the
|
||||||
|
same bindingset (with different modifiers), and use only
|
||||||
|
the first entry, which, with the change in _gtk_key_hash_lookup()
|
||||||
|
will be the preferred value.
|
||||||
|
|
||||||
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
Fri Mar 22 11:29:11 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Partial fix for problem where keypad keys acted
|
||||||
|
as shift-arrows in an entry rather than arrows (#74327)
|
||||||
|
|
||||||
|
* gtk/gtkkeyhash.c (_gtk_key_hash_lookup): Sort lookup
|
||||||
|
results by number of modifiers in the entry. Fixes
|
||||||
|
problem where if a key matched both modified and unmodified
|
||||||
|
key bindings ... e.g., the distinguishing key binding
|
||||||
|
was consumed, then it was random which was used.
|
||||||
|
|
||||||
|
* gtk/gtkbindings.c (gtk_binding_entries_sort_patterns):
|
||||||
|
Catch the case where there are multiple entries from the
|
||||||
|
same bindingset (with different modifiers), and use only
|
||||||
|
the first entry, which, with the change in _gtk_key_hash_lookup()
|
||||||
|
will be the preferred value.
|
||||||
|
|
||||||
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
Fri Mar 22 11:29:11 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Partial fix for problem where keypad keys acted
|
||||||
|
as shift-arrows in an entry rather than arrows (#74327)
|
||||||
|
|
||||||
|
* gtk/gtkkeyhash.c (_gtk_key_hash_lookup): Sort lookup
|
||||||
|
results by number of modifiers in the entry. Fixes
|
||||||
|
problem where if a key matched both modified and unmodified
|
||||||
|
key bindings ... e.g., the distinguishing key binding
|
||||||
|
was consumed, then it was random which was used.
|
||||||
|
|
||||||
|
* gtk/gtkbindings.c (gtk_binding_entries_sort_patterns):
|
||||||
|
Catch the case where there are multiple entries from the
|
||||||
|
same bindingset (with different modifiers), and use only
|
||||||
|
the first entry, which, with the change in _gtk_key_hash_lookup()
|
||||||
|
will be the preferred value.
|
||||||
|
|
||||||
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
Fri Mar 22 11:29:11 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
Partial fix for problem where keypad keys acted
|
||||||
|
as shift-arrows in an entry rather than arrows (#74327)
|
||||||
|
|
||||||
|
* gtk/gtkkeyhash.c (_gtk_key_hash_lookup): Sort lookup
|
||||||
|
results by number of modifiers in the entry. Fixes
|
||||||
|
problem where if a key matched both modified and unmodified
|
||||||
|
key bindings ... e.g., the distinguishing key binding
|
||||||
|
was consumed, then it was random which was used.
|
||||||
|
|
||||||
|
* gtk/gtkbindings.c (gtk_binding_entries_sort_patterns):
|
||||||
|
Catch the case where there are multiple entries from the
|
||||||
|
same bindingset (with different modifiers), and use only
|
||||||
|
the first entry, which, with the change in _gtk_key_hash_lookup()
|
||||||
|
will be the preferred value.
|
||||||
|
|
||||||
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
Fri Mar 22 10:56:19 2002 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
* gtk/gtkaccelmap.c (gtk_accel_map_save_fd): Fix memory
|
||||||
|
|||||||
@ -954,8 +954,18 @@ gtk_binding_entries_sort_patterns (GSList *entries,
|
|||||||
gboolean is_release)
|
gboolean is_release)
|
||||||
{
|
{
|
||||||
GSList *patterns;
|
GSList *patterns;
|
||||||
|
GSList *tmp_list;
|
||||||
|
|
||||||
patterns = NULL;
|
patterns = NULL;
|
||||||
|
for (tmp_list = entries; tmp_list; tmp_list = tmp_list->next)
|
||||||
|
{
|
||||||
|
GtkBindingEntry *entry = tmp_list->data;
|
||||||
|
GtkBindingSet *binding_set;
|
||||||
|
|
||||||
|
binding_set = entry->binding_set;
|
||||||
|
binding_set->current = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (; entries; entries = entries->next)
|
for (; entries; entries = entries->next)
|
||||||
{
|
{
|
||||||
GtkBindingEntry *entry = entries->data;
|
GtkBindingEntry *entry = entries->data;
|
||||||
@ -966,6 +976,9 @@ gtk_binding_entries_sort_patterns (GSList *entries,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
binding_set = entry->binding_set;
|
binding_set = entry->binding_set;
|
||||||
|
|
||||||
|
if (binding_set->current)
|
||||||
|
continue;
|
||||||
binding_set->current = entry;
|
binding_set->current = entry;
|
||||||
|
|
||||||
switch (path_id)
|
switch (path_id)
|
||||||
|
|||||||
@ -242,6 +242,46 @@ _gtk_key_hash_remove_entry (GtkKeyHash *key_hash,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
lookup_result_compare (gconstpointer a,
|
||||||
|
gconstpointer b)
|
||||||
|
{
|
||||||
|
const GtkKeyHashEntry *entry_a = a;
|
||||||
|
const GtkKeyHashEntry *entry_b = b;
|
||||||
|
guint modifiers;
|
||||||
|
|
||||||
|
gint n_bits_a = 0;
|
||||||
|
gint n_bits_b = 0;
|
||||||
|
|
||||||
|
modifiers = entry_a->modifiers;
|
||||||
|
while (modifiers)
|
||||||
|
{
|
||||||
|
if (modifiers & 1)
|
||||||
|
n_bits_a++;
|
||||||
|
modifiers >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
modifiers = entry_b->modifiers;
|
||||||
|
while (modifiers)
|
||||||
|
{
|
||||||
|
if (modifiers & 1)
|
||||||
|
n_bits_b++;
|
||||||
|
modifiers >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return n_bits_a < n_bits_b ? -1 : (n_bits_a == n_bits_b ? 0 : 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sort a list of results so that matches with less modifiers come
|
||||||
|
* before matches with more modifiers
|
||||||
|
*/
|
||||||
|
static GSList *
|
||||||
|
sort_lookup_results (GSList *slist)
|
||||||
|
{
|
||||||
|
return g_slist_sort (slist, lookup_result_compare);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _gtk_key_hash_lookup:
|
* _gtk_key_hash_lookup:
|
||||||
* @key_hash: a #GtkKeyHash
|
* @key_hash: a #GtkKeyHash
|
||||||
@ -250,7 +290,8 @@ _gtk_key_hash_remove_entry (GtkKeyHash *key_hash,
|
|||||||
* @group: group field from a #GdkEventKey
|
* @group: group field from a #GdkEventKey
|
||||||
*
|
*
|
||||||
* Looks up the best matching entry or entries in the hash table for
|
* Looks up the best matching entry or entries in the hash table for
|
||||||
* a given event.
|
* a given event. The results are sorted so that entries with less
|
||||||
|
* modifiers come before entries with more modifiers.
|
||||||
*
|
*
|
||||||
* Return value: A #GSList of all matching entries. If there were exact
|
* Return value: A #GSList of all matching entries. If there were exact
|
||||||
* matches, they are returned, otherwise all fuzzy matches are
|
* matches, they are returned, otherwise all fuzzy matches are
|
||||||
@ -328,7 +369,7 @@ _gtk_key_hash_lookup (GtkKeyHash *key_hash,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return sort_lookup_results (results);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -339,7 +380,8 @@ _gtk_key_hash_lookup (GtkKeyHash *key_hash,
|
|||||||
* Looks up the best matching entry or entries in the hash table for a
|
* Looks up the best matching entry or entries in the hash table for a
|
||||||
* given keyval/modifiers pair. It's better to use
|
* given keyval/modifiers pair. It's better to use
|
||||||
* _gtk_key_hash_lookup() if you have the original #GdkEventKey
|
* _gtk_key_hash_lookup() if you have the original #GdkEventKey
|
||||||
* available.
|
* available. The results are sorted so that entries with less
|
||||||
|
* modifiers come before entries with more modifiers.
|
||||||
*
|
*
|
||||||
* Return value: A #GSList of all matching entries.
|
* Return value: A #GSList of all matching entries.
|
||||||
**/
|
**/
|
||||||
@ -377,5 +419,5 @@ _gtk_key_hash_lookup_keyval (GtkKeyHash *key_hash,
|
|||||||
|
|
||||||
g_free (keys);
|
g_free (keys);
|
||||||
|
|
||||||
return results;
|
return sort_lookup_results (results);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user