summaryrefslogtreecommitdiffstats
path: root/webkit/api
diff options
context:
space:
mode:
authorhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-10 08:32:28 +0000
committerhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-10 08:32:28 +0000
commit2563275f12646864039ee45d0878c771aa58da15 (patch)
treefb79b89ea92beae6439dd3d9399c7209e96ea81c /webkit/api
parent4f18b677bf07e0d6e92bccc07e96854fa245ea17 (diff)
downloadchromium_src-2563275f12646864039ee45d0878c771aa58da15.zip
chromium_src-2563275f12646864039ee45d0878c771aa58da15.tar.gz
chromium_src-2563275f12646864039ee45d0878c771aa58da15.tar.bz2
A quick fix for Issue 15852.
After a discussion in <http://crbug.com/15852>, I noticed I wrongly understood the Dvorak and European keyboards. We should not use US layout for handling shortcut keys. To fix this problem, this change uses |event->hardware_keycode| only when WebKit::windowsKeyCodeForKeyEvent() returns 0. When we use the Hebrew (or Russian) layout, |event->keyval| becomes GDK_hebrew_* (or GDK_Cyrillic_*) and this function returns 0.) BUG=15852 "Incorrect keycode with dvorak keyboard layout on Linux" TEST=Open <http://www.asquare.net/javascript/tests/KeyCode.html>, press 'x' of a dvorak keyboard, and its keyDown.keyCode becomes 88. Review URL: http://codereview.chromium.org/149248 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20369 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/api')
-rw-r--r--webkit/api/src/gtk/WebInputEventFactory.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/webkit/api/src/gtk/WebInputEventFactory.cpp b/webkit/api/src/gtk/WebInputEventFactory.cpp
index 96ef4c8..9939523 100644
--- a/webkit/api/src/gtk/WebInputEventFactory.cpp
+++ b/webkit/api/src/gtk/WebInputEventFactory.cpp
@@ -139,21 +139,25 @@ static int gdkEventToWindowsKeyCode(const GdkEventKey* event)
0, // 0x3E: GDK_Shift_R
};
- // |windowKeyCode| shouldn't change even when we change the keyboard
- // layout, e.g. when we type an 'A' key of a US keyboard on the French
- // layout, |windowsKeyCode| should be VK_A. On the other hand,
- // |event->keyval| may change when we change the keyboard layout (the
- // GdkKeymap object attached to the GdkDisplay object), e.g. when we type
- // an 'A' key of a US keyboard on the French (or Hebrew) layout,
- // |event->keyval| becomes GDK_q (or GDK_hebrew_shin).
+ // |windowsKeyCode| has to include a valid virtual-key code even when we
+ // use non-US layouts, e.g. even when we type an 'A' key of a US keyboard
+ // on the Hebrew layout, |windowsKeyCode| should be VK_A.
+ // On the other hand, |event->keyval| value depends on the current
+ // GdkKeymap object, i.e. when we type an 'A' key of a US keyboard on
+ // the Hebrew layout, |event->keyval| becomes GDK_hebrew_shin and this
+ // WebCore::windowsKeyCodeForKeyEvent() call returns 0.
// To improve compatibilty with Windows, we use |event->hardware_keycode|
- // for retrieving its Windows key-code for the keys that can be changed by
- // GdkKeymap objects (keyboard-layout drivers).
+ // for retrieving its Windows key-code for the keys when the
+ // WebCore::windowsKeyCodeForEvent() call returns 0.
// We shouldn't use |event->hardware_keycode| for keys that GdkKeymap
// objects cannot change because |event->hardware_keycode| doesn't change
// even when we change the layout options, e.g. when we swap a control
// key and a caps-lock key, GTK doesn't swap their
// |event->hardware_keycode| values but swap their |event->keyval| values.
+ int windowsKeyCode = WebCore::windowsKeyCodeForKeyEvent(event->keyval);
+ if (windowsKeyCode)
+ return windowsKeyCode;
+
const int tableSize = sizeof(hardwareCodeToGDKKeyval) / sizeof(hardwareCodeToGDKKeyval[0]);
if (event->hardware_keycode < tableSize) {
int keyval = hardwareCodeToGDKKeyval[event->hardware_keycode];