Some additional auto-mnemonic fixes

Previously, we would also show mnemonics if the user hits
Ctrl+Alt, even though Ctrl+Alt+<x> does not actually trigger.
This commit is contained in:
Matthias Clasen 2011-05-06 14:04:50 -04:00
parent 6889d5b008
commit 73bf1740e9
2 changed files with 4 additions and 2 deletions

View File

@ -1840,10 +1840,13 @@ gtk_main_do_event (GdkEvent *event)
if (gtk_invoke_key_snoopers (grab_widget, event)) if (gtk_invoke_key_snoopers (grab_widget, event))
break; break;
} }
/* Catch alt press to enable auto-mnemonics; /* Catch alt press to enable auto-mnemonics;
* menus are handled elsewhere * menus are handled elsewhere
* FIXME: this does not work with mnemonic modifiers other than Alt
*/ */
if ((event->key.keyval == GDK_KEY_Alt_L || event->key.keyval == GDK_KEY_Alt_R) && if ((event->key.keyval == GDK_KEY_Alt_L || event->key.keyval == GDK_KEY_Alt_R) &&
((event->key.state & (gtk_accelerator_get_default_mod_mask ()) & ~(GDK_RELEASE_MASK|GDK_MOD1_MASK)) == 0) &&
!GTK_IS_MENU_SHELL (grab_widget)) !GTK_IS_MENU_SHELL (grab_widget))
{ {
gboolean auto_mnemonics; gboolean auto_mnemonics;

View File

@ -5947,8 +5947,7 @@ maybe_set_mnemonics_visible (GtkWindow *window)
gdk_device_get_state (dev, gtk_widget_get_window (GTK_WIDGET (window)), gdk_device_get_state (dev, gtk_widget_get_window (GTK_WIDGET (window)),
NULL, &mask); NULL, &mask);
if (window->priv->mnemonic_modifier == (mask & gtk_accelerator_get_default_mod_mask ()))
if (window->priv->mnemonic_modifier & mask)
{ {
gtk_window_set_mnemonics_visible (window, TRUE); gtk_window_set_mnemonics_visible (window, TRUE);
break; break;