From 94c0900f7e5792621cb8f5082d68be661fc08781 Mon Sep 17 00:00:00 2001 From: "masayuki@d-toybox.com" Date: Mon, 5 May 2008 21:11:52 -0700 Subject: [PATCH] Bug 429510 Web apps cannot handle Ctrl+foo/Alt+foo key on keypress event, gtk2 part r=karl, sr=roc, a=beltzner --- widget/src/gtk2/nsWindow.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index df76c81241e..9e0d18739f3 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -2456,6 +2456,9 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent) g_free(keys); } if (minGroup >= 0) { + PRUint32 unmodifiedCh = + event.isShift ? altCharCodes.mShiftedCharCode : + altCharCodes.mUnshiftedCharCode; // unshifted charcode of found keyboard layout. PRUint32 ch = GetCharCodeFor(aEvent, baseState, minGroup); @@ -2470,6 +2473,17 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent) altCharCodes.mShiftedCharCode) { event.alternativeCharCodes.AppendElement(altCharCodes); } + // If the charCode is not Latin, and the level is 0 or 1, + // we should replace the charCode to Latin char if Alt and + // Meta keys are not pressed. (Alt should be sent the + // localized char for accesskey like handling of Web + // Applications.) + ch = event.isShift ? altCharCodes.mShiftedCharCode : + altCharCodes.mUnshiftedCharCode; + if (ch && !(event.isAlt || event.isMeta) && + event.charCode == unmodifiedCh) { + event.charCode = ch; + } } } }