--- mozilla/widget/src/gtk2/nsWindow.cpp.orig 2007-04-19 22:46:03.000000000 +0400 +++ mozilla/widget/src/gtk2/nsWindow.cpp 2007-11-23 11:35:57.000000000 +0300 @@ -1809,6 +1809,14 @@ LOGFOCUS(("Done with container focus out [%p]\n", (void *)this)); } +inline PRBool +is_latin_shortcut_key(guint aKeyval) +{ + return ((GDK_0 <= aKeyval && aKeyval <= GDK_9) || + (GDK_A <= aKeyval && aKeyval <= GDK_Z) || + (GDK_a <= aKeyval && aKeyval <= GDK_z)); +} + gboolean nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent) { @@ -1883,6 +1891,62 @@ // clear isShift so the character can be inserted in the editor if (event.isControl || event.isAlt || event.isMeta) { + GdkEventKey tmpEvent = *aEvent; + + // Fix for bug 69230: + // if modifier key is pressed and key pressed is not latin character, + // we should try other keyboard layouts to find out correct latin + // character corresponding to pressed key; + // that way shortcuts like Ctrl+C will work no matter what + // keyboard layout is selected + // We don't try to fix up punctuation accelerators here, + // because their location differs between latin layouts + if (!is_latin_shortcut_key(event.charCode)) { + // We have a non-latin char, try other keyboard groups + GdkKeymapKey *keys; + guint *keyvals; + gint n_entries; + PRUint32 latinCharCode; + gint level; + + if (gdk_keymap_translate_keyboard_state(NULL, + tmpEvent.hardware_keycode, + (GdkModifierType)tmpEvent.state, + tmpEvent.group, + NULL, NULL, &level, NULL) + && gdk_keymap_get_entries_for_keycode(NULL, + tmpEvent.hardware_keycode, + &keys, &keyvals, + &n_entries)) { + gint n; + for (n=0; n GDK_9)) { - GdkKeymapKey k = { aEvent->hardware_keycode, aEvent->group, 0 }; - guint savedKeyval = aEvent->keyval; - aEvent->keyval = gdk_keymap_lookup_key(gdk_keymap_get_default(), &k); - PRUint32 unshiftedCharCode = nsConvertCharCodeToUnicode(aEvent); + GdkKeymapKey k = { tmpEvent.hardware_keycode, tmpEvent.group, 0 }; + tmpEvent.keyval = gdk_keymap_lookup_key(gdk_keymap_get_default(), &k); + PRUint32 unshiftedCharCode = nsConvertCharCodeToUnicode(&tmpEvent); if (unshiftedCharCode) event.charCode = unshiftedCharCode; - else - aEvent->keyval = savedKeyval; } } }