diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-17 11:20:00 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-17 11:20:00 +0000 |
commit | e105c1880d4f033639529e9f47e275a71b585489 (patch) | |
tree | c507ef6652d3ee06c34277185344430dd22b1ef6 /chrome | |
parent | c7b4ebf17aec86cf07a61f807582b2ca79811dcf (diff) | |
download | chromium_src-e105c1880d4f033639529e9f47e275a71b585489.zip chromium_src-e105c1880d4f033639529e9f47e275a71b585489.tar.gz chromium_src-e105c1880d4f033639529e9f47e275a71b585489.tar.bz2 |
A quick fix for Issue 13711 (the second part)
Because of a hard-disk problem, I lost the original change. So, I would like to send another change for this fix.
This is the second part of the fix for Issue 13711.
On non-ASCII keyboards (e.g. Russian and Hebrew), |event->keyval| represents a non-ASCII value that BrowserWindowGtk::HandleAccelerator() cannot handle.
To fix this issue, this change uses |event->hardware_keycode| to retrieve its ASCII value before calling BrowserWindowGtk::HandleAccelerator().
BUG=13711 "Alt-D does not work when in editbox"
TEST=Type alt+d keys on a Russian keyboard and verify the input focus is moved to an onmibox.
Review URL: http://codereview.chromium.org/155555
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20944 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_gtk.cc | 89 |
1 files changed, 88 insertions, 1 deletions
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc index 3dd9dd5..a0f26fd 100644 --- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc @@ -5,6 +5,7 @@ #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" #include <gdk/gdk.h> +#include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> #include "base/mime_util.h" @@ -102,6 +103,91 @@ void SetSizeRequest(GtkWidget* widget, gpointer userdata) { } } +int GdkEventKeyToLayoutIndependentKeyval(const GdkEventKey* event) { + // This function is a copy of WebKit::gdkEventToWindowsKeyCode() but returns + // a GDK key value instead of a Windows virtual key code. + static const int kHardwareCodeToGdkKeyval[] = { + 0, // 0x00: + 0, // 0x01: + 0, // 0x02: + 0, // 0x03: + 0, // 0x04: + 0, // 0x05: + 0, // 0x06: + 0, // 0x07: + 0, // 0x08: + 0, // 0x09: GDK_Escape + GDK_1, // 0x0A: GDK_1 + GDK_2, // 0x0B: GDK_2 + GDK_3, // 0x0C: GDK_3 + GDK_4, // 0x0D: GDK_4 + GDK_5, // 0x0E: GDK_5 + GDK_6, // 0x0F: GDK_6 + GDK_7, // 0x10: GDK_7 + GDK_8, // 0x11: GDK_8 + GDK_9, // 0x12: GDK_9 + GDK_0, // 0x13: GDK_0 + GDK_minus, // 0x14: GDK_minus + GDK_equal, // 0x15: GDK_equal + 0, // 0x16: GDK_BackSpace + 0, // 0x17: GDK_Tab + GDK_q, // 0x18: GDK_q + GDK_w, // 0x19: GDK_w + GDK_e, // 0x1A: GDK_e + GDK_r, // 0x1B: GDK_r + GDK_t, // 0x1C: GDK_t + GDK_y, // 0x1D: GDK_y + GDK_u, // 0x1E: GDK_u + GDK_i, // 0x1F: GDK_i + GDK_o, // 0x20: GDK_o + GDK_p, // 0x21: GDK_p + GDK_bracketleft, // 0x22: GDK_bracketleft + GDK_bracketright, // 0x23: GDK_bracketright + 0, // 0x24: GDK_Return + 0, // 0x25: GDK_Control_L + GDK_a, // 0x26: GDK_a + GDK_s, // 0x27: GDK_s + GDK_d, // 0x28: GDK_d + GDK_f, // 0x29: GDK_f + GDK_g, // 0x2A: GDK_g + GDK_h, // 0x2B: GDK_h + GDK_j, // 0x2C: GDK_j + GDK_k, // 0x2D: GDK_k + GDK_l, // 0x2E: GDK_l + GDK_semicolon, // 0x2F: GDK_semicolon + GDK_apostrophe, // 0x30: GDK_apostrophe + GDK_grave, // 0x31: GDK_grave + 0, // 0x32: GDK_Shift_L + GDK_backslash, // 0x33: GDK_backslash + GDK_z, // 0x34: GDK_z + GDK_x, // 0x35: GDK_x + GDK_c, // 0x36: GDK_c + GDK_v, // 0x37: GDK_v + GDK_b, // 0x38: GDK_b + GDK_n, // 0x39: GDK_n + GDK_m, // 0x3A: GDK_m + GDK_comma, // 0x3B: GDK_comma + GDK_period, // 0x3C: GDK_period + GDK_slash, // 0x3D: GDK_slash + 0, // 0x3E: GDK_Shift_R + }; + + // If this |event->keyval| represents an ASCII character, we use it for + // accelerators. Otherwise, we look up a table from a hardware keycode to + // keyval and use its result. + wchar_t c = gdk_keyval_to_unicode(event->keyval); + if (c <= 0x7F) + return event->keyval; + + if (event->hardware_keycode < arraysize(kHardwareCodeToGdkKeyval)) { + int keyval = kHardwareCodeToGdkKeyval[event->hardware_keycode]; + if (keyval) + return keyval; + } + + return event->keyval; +} + } // namespace // A helper class that handles DnD for drops in the renderer. In GTK parlance, @@ -562,7 +648,8 @@ void TabContentsViewGtk::HandleKeyboardEvent( BrowserWindowGtk* browser_window = BrowserWindowGtk::GetBrowserWindowForNativeWindow(window); DCHECK(browser_window); - browser_window->HandleAccelerator(event.os_event->keyval, + browser_window->HandleAccelerator( + GdkEventKeyToLayoutIndependentKeyval(event.os_event), static_cast<GdkModifierType>(event.os_event->state)); } |