diff options
-rw-r--r-- | base/base.gyp | 7 | ||||
-rwxr-xr-x | base/keyboard_code_conversion_gtk.cc | 642 | ||||
-rwxr-xr-x | base/keyboard_code_conversion_gtk.h | 49 | ||||
-rw-r--r-- | base/keyboard_codes.h | 6 | ||||
-rw-r--r-- | base/keyboard_codes_linux.h | 214 | ||||
-rw-r--r-- | base/keyboard_codes_posix.h (renamed from base/keyboard_codes_mac.h) | 6 | ||||
-rw-r--r-- | chrome/browser/automation/ui_controls.h | 1 | ||||
-rw-r--r-- | chrome/browser/automation/ui_controls_linux.cc | 7 | ||||
-rw-r--r-- | chrome/browser/views/accelerator_table_gtk.cc | 208 | ||||
-rw-r--r-- | chrome/browser/views/accelerator_table_gtk.h | 12 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 15 | ||||
-rw-r--r-- | chrome/browser/views/tab_contents/tab_contents_view_gtk.cc | 2 | ||||
-rw-r--r-- | views/controls/button/custom_button.cc | 2 | ||||
-rw-r--r-- | views/event.h | 6 | ||||
-rw-r--r-- | views/event_gtk.cc | 7 | ||||
-rw-r--r-- | views/focus/accelerator_handler_gtk.cc | 2 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 4 |
17 files changed, 825 insertions, 365 deletions
diff --git a/base/base.gyp b/base/base.gyp index 0619789..bca5794 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -157,8 +157,11 @@ 'json_reader.h', 'json_writer.cc', 'json_writer.h', + 'keyboard_code_conversion_gtk.cc', + 'keyboard_code_conversion_gtk.h', 'keyboard_codes.h', 'keyboard_codes_win.h', + 'keyboard_codes_posix.h', 'lazy_instance.cc', 'lazy_instance.h', 'leak_tracker.h', @@ -459,7 +462,7 @@ }, ], [ 'OS == "mac"', { - 'sources/': [ ['exclude', '_(linux|win|chromeos)\\.cc$'] ], + 'sources/': [ ['exclude', '_(linux|gtk|win|chromeos)\\.cc$'] ], 'sources!': [ ], 'link_settings': { @@ -483,7 +486,7 @@ 'include_dirs': [ '../chrome/third_party/wtl/include', ], - 'sources/': [ ['exclude', '_(linux|mac|posix|chromeos)\\.cc$'], + 'sources/': [ ['exclude', '_(linux|gtk|mac|posix|chromeos)\\.cc$'], ['exclude', '\\.mm?$' ] ], 'sources': [ 'window_impl.cc', diff --git a/base/keyboard_code_conversion_gtk.cc b/base/keyboard_code_conversion_gtk.cc new file mode 100755 index 0000000..b280d40 --- /dev/null +++ b/base/keyboard_code_conversion_gtk.cc @@ -0,0 +1,642 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com + * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2008 Collabora, Ltd. All rights reserved. + * Copyright (C) 2008, 2009 Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// WindowsKeyCodeForGdkKeyCode is copied from platform/gtk/KeyEventGtk.cpp + +#ifndef BASE_KEYBOARD_CODE_CONVERSION_GTK_H_ +#define BASE_KEYBOARD_CODE_CONVERSION_GTK_H_ + +#include "base/keyboard_code_conversion_gtk.h" + +#include <gdk/gdkkeysyms.h> + +#include "base/keyboard_codes_posix.h" + +namespace base { + +int WindowsKeyCodeForGdkKeyCode(int keycode) { + switch (keycode) { + case GDK_KP_0: + return VKEY_NUMPAD0; // (60) Numeric keypad 0 key + case GDK_KP_1: + return VKEY_NUMPAD1; // (61) Numeric keypad 1 key + case GDK_KP_2: + return VKEY_NUMPAD2; // (62) Numeric keypad 2 key + case GDK_KP_3: + return VKEY_NUMPAD3; // (63) Numeric keypad 3 key + case GDK_KP_4: + return VKEY_NUMPAD4; // (64) Numeric keypad 4 key + case GDK_KP_5: + return VKEY_NUMPAD5; //(65) Numeric keypad 5 key + case GDK_KP_6: + return VKEY_NUMPAD6; // (66) Numeric keypad 6 key + case GDK_KP_7: + return VKEY_NUMPAD7; // (67) Numeric keypad 7 key + case GDK_KP_8: + return VKEY_NUMPAD8; // (68) Numeric keypad 8 key + case GDK_KP_9: + return VKEY_NUMPAD9; // (69) Numeric keypad 9 key + case GDK_KP_Multiply: + return VKEY_MULTIPLY; // (6A) Multiply key + case GDK_KP_Add: + return VKEY_ADD; // (6B) Add key + case GDK_KP_Subtract: + return VKEY_SUBTRACT; // (6D) Subtract key + case GDK_KP_Decimal: + return VKEY_DECIMAL; // (6E) Decimal key + case GDK_KP_Divide: + return VKEY_DIVIDE; // (6F) Divide key + + case GDK_BackSpace: + return VKEY_BACK; // (08) BACKSPACE key + case GDK_ISO_Left_Tab: + case GDK_3270_BackTab: + case GDK_Tab: + return VKEY_TAB; // (09) TAB key + case GDK_Clear: + return VKEY_CLEAR; // (0C) CLEAR key + case GDK_ISO_Enter: + case GDK_KP_Enter: + case GDK_Return: + return VKEY_RETURN; //(0D) Return key + case GDK_Shift_L: + case GDK_Shift_R: + return VKEY_SHIFT; // (10) SHIFT key + case GDK_Control_L: + case GDK_Control_R: + return VKEY_CONTROL; // (11) CTRL key + case GDK_Menu: + case GDK_Alt_L: + case GDK_Alt_R: + return VKEY_MENU; // (12) ALT key + + case GDK_Pause: + return VKEY_PAUSE; // (13) PAUSE key + case GDK_Caps_Lock: + return VKEY_CAPITAL; // (14) CAPS LOCK key + case GDK_Kana_Lock: + case GDK_Kana_Shift: + return VKEY_KANA; // (15) Input Method Editor (IME) Kana mode + case GDK_Hangul: + return VKEY_HANGUL; // VKEY_HANGUL (15) IME Hangul mode + // VKEY_JUNJA (17) IME Junja mode + // VKEY_FINAL (18) IME final mode + case GDK_Hangul_Hanja: + return VKEY_HANJA; // (19) IME Hanja mode + case GDK_Kanji: + return VKEY_KANJI; // (19) IME Kanji mode + case GDK_Escape: + return VKEY_ESCAPE; // (1B) ESC key + // VKEY_CONVERT (1C) IME convert + // VKEY_NONCONVERT (1D) IME nonconvert + // VKEY_ACCEPT (1E) IME accept + // VKEY_MODECHANGE (1F) IME mode change request + case GDK_space: + return VKEY_SPACE; // (20) SPACEBAR + case GDK_Page_Up: + return VKEY_PRIOR; // (21) PAGE UP key + case GDK_Page_Down: + return VKEY_NEXT; // (22) PAGE DOWN key + case GDK_End: + return VKEY_END; // (23) END key + case GDK_Home: + return VKEY_HOME; // (24) HOME key + case GDK_Left: + return VKEY_LEFT; // (25) LEFT ARROW key + case GDK_Up: + return VKEY_UP; // (26) UP ARROW key + case GDK_Right: + return VKEY_RIGHT; // (27) RIGHT ARROW key + case GDK_Down: + return VKEY_DOWN; // (28) DOWN ARROW key + case GDK_Select: + return VKEY_SELECT; // (29) SELECT key + case GDK_Print: + return VKEY_PRINT; // (2A) PRINT key + case GDK_Execute: + return VKEY_EXECUTE;// (2B) EXECUTE key + //dunno on this + //case GDK_PrintScreen: + // return VKEY_SNAPSHOT; // (2C) PRINT SCREEN key + case GDK_Insert: + return VKEY_INSERT; // (2D) INS key + case GDK_Delete: + return VKEY_DELETE; // (2E) DEL key + case GDK_Help: + return VKEY_HELP; // (2F) HELP key + case GDK_0: + case GDK_parenright: + return VKEY_0; // (30) 0) key + case GDK_1: + case GDK_exclam: + return VKEY_1; // (31) 1 ! key + case GDK_2: + case GDK_at: + return VKEY_2; // (32) 2 & key + case GDK_3: + case GDK_numbersign: + return VKEY_3; //case '3': case '#'; + case GDK_4: + case GDK_dollar: // (34) 4 key '$'; + return VKEY_4; + case GDK_5: + case GDK_percent: + return VKEY_5; // (35) 5 key '%' + case GDK_6: + case GDK_asciicircum: + return VKEY_6; // (36) 6 key '^' + case GDK_7: + case GDK_ampersand: + return VKEY_7; // (37) 7 key case '&' + case GDK_8: + case GDK_asterisk: + return VKEY_8; // (38) 8 key '*' + case GDK_9: + case GDK_parenleft: + return VKEY_9; // (39) 9 key '(' + case GDK_a: + case GDK_A: + return VKEY_A; // (41) A key case 'a': case 'A': return 0x41; + case GDK_b: + case GDK_B: + return VKEY_B; // (42) B key case 'b': case 'B': return 0x42; + case GDK_c: + case GDK_C: + return VKEY_C; // (43) C key case 'c': case 'C': return 0x43; + case GDK_d: + case GDK_D: + return VKEY_D; // (44) D key case 'd': case 'D': return 0x44; + case GDK_e: + case GDK_E: + return VKEY_E; // (45) E key case 'e': case 'E': return 0x45; + case GDK_f: + case GDK_F: + return VKEY_F; // (46) F key case 'f': case 'F': return 0x46; + case GDK_g: + case GDK_G: + return VKEY_G; // (47) G key case 'g': case 'G': return 0x47; + case GDK_h: + case GDK_H: + return VKEY_H; // (48) H key case 'h': case 'H': return 0x48; + case GDK_i: + case GDK_I: + return VKEY_I; // (49) I key case 'i': case 'I': return 0x49; + case GDK_j: + case GDK_J: + return VKEY_J; // (4A) J key case 'j': case 'J': return 0x4A; + case GDK_k: + case GDK_K: + return VKEY_K; // (4B) K key case 'k': case 'K': return 0x4B; + case GDK_l: + case GDK_L: + return VKEY_L; // (4C) L key case 'l': case 'L': return 0x4C; + case GDK_m: + case GDK_M: + return VKEY_M; // (4D) M key case 'm': case 'M': return 0x4D; + case GDK_n: + case GDK_N: + return VKEY_N; // (4E) N key case 'n': case 'N': return 0x4E; + case GDK_o: + case GDK_O: + return VKEY_O; // (4F) O key case 'o': case 'O': return 0x4F; + case GDK_p: + case GDK_P: + return VKEY_P; // (50) P key case 'p': case 'P': return 0x50; + case GDK_q: + case GDK_Q: + return VKEY_Q; // (51) Q key case 'q': case 'Q': return 0x51; + case GDK_r: + case GDK_R: + return VKEY_R; // (52) R key case 'r': case 'R': return 0x52; + case GDK_s: + case GDK_S: + return VKEY_S; // (53) S key case 's': case 'S': return 0x53; + case GDK_t: + case GDK_T: + return VKEY_T; // (54) T key case 't': case 'T': return 0x54; + case GDK_u: + case GDK_U: + return VKEY_U; // (55) U key case 'u': case 'U': return 0x55; + case GDK_v: + case GDK_V: + return VKEY_V; // (56) V key case 'v': case 'V': return 0x56; + case GDK_w: + case GDK_W: + return VKEY_W; // (57) W key case 'w': case 'W': return 0x57; + case GDK_x: + case GDK_X: + return VKEY_X; // (58) X key case 'x': case 'X': return 0x58; + case GDK_y: + case GDK_Y: + return VKEY_Y; // (59) Y key case 'y': case 'Y': return 0x59; + case GDK_z: + case GDK_Z: + return VKEY_Z; // (5A) Z key case 'z': case 'Z': return 0x5A; + case GDK_Meta_L: + return VKEY_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard) + case GDK_Meta_R: + return VKEY_RWIN; // (5C) Right Windows key (Natural keyboard) + // VKEY_APPS (5D) Applications key (Natural keyboard) + // VKEY_SLEEP (5F) Computer Sleep key + // VKEY_SEPARATOR (6C) Separator key + // VKEY_SUBTRACT (6D) Subtract key + // VKEY_DECIMAL (6E) Decimal key + // VKEY_DIVIDE (6F) Divide key + // handled by key code above + + case GDK_Num_Lock: + return VKEY_NUMLOCK; // (90) NUM LOCK key + + case GDK_Scroll_Lock: + return VKEY_SCROLL; // (91) SCROLL LOCK key + + // VKEY_LSHIFT (A0) Left SHIFT key + // VKEY_RSHIFT (A1) Right SHIFT key + // VKEY_LCONTROL (A2) Left CONTROL key + // VKEY_RCONTROL (A3) Right CONTROL key + // VKEY_LMENU (A4) Left MENU key + // VKEY_RMENU (A5) Right MENU key + // VKEY_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key + // VKEY_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key + // VKEY_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key + // VKEY_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key + // VKEY_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key + // VKEY_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key + // VKEY_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key + // VKEY_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key + // VKEY_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key + // VKEY_VOLUME_UP (AF) Windows 2000/XP: Volume Up key + // VKEY_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key + // VKEY_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key + // VKEY_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key + // VKEY_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key + // VKEY_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key + // VKEY_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key + // VKEY_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key + // VKEY_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key + + // VKEY_OEM_1 (BA) Used for miscellaneous characters; it can vary by + // keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key + case GDK_semicolon: + case GDK_colon: + return VKEY_OEM_1; //case ';': case ':': return 0xBA; + // VKEY_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key + case GDK_plus: + case GDK_equal: + return VKEY_OEM_PLUS; //case '=': case '+': return 0xBB; + // VKEY_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' + // key + case GDK_comma: + case GDK_less: + return VKEY_OEM_COMMA; //case ',': case '<': return 0xBC; + // VKEY_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' + // key + case GDK_minus: + case GDK_underscore: + return VKEY_OEM_MINUS; //case '-': case '_': return 0xBD; + // VKEY_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' + // key + case GDK_period: + case GDK_greater: + return VKEY_OEM_PERIOD; //case '.': case '>': return 0xBE; + // VKEY_OEM_2 (BF) Used for miscellaneous characters; it can vary by + // keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key + case GDK_slash: + case GDK_question: + return VKEY_OEM_2; //case '/': case '?': return 0xBF; + // VKEY_OEM_3 (C0) Used for miscellaneous characters; it can vary by + // keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key + case GDK_asciitilde: + case GDK_quoteleft: + return VKEY_OEM_3; //case '`': case '~': return 0xC0; + // VKEY_OEM_4 (DB) Used for miscellaneous characters; it can vary by + // keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key + case GDK_bracketleft: + case GDK_braceleft: + return VKEY_OEM_4; //case '[': case '{': return 0xDB; + // VKEY_OEM_5 (DC) Used for miscellaneous characters; it can vary by + // keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key + case GDK_backslash: + case GDK_bar: + return VKEY_OEM_5; //case '\\': case '|': return 0xDC; + // VKEY_OEM_6 (DD) Used for miscellaneous characters; it can vary by + // keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key + case GDK_bracketright: + case GDK_braceright: + return VKEY_OEM_6; // case ']': case '}': return 0xDD; + // VKEY_OEM_7 (DE) Used for miscellaneous characters; it can vary by + // keyboard. Windows 2000/XP: For the US standard keyboard, the + // 'single-quote/double-quote' key + case GDK_quoteright: + case GDK_quotedbl: + return VKEY_OEM_7; // case '\'': case '"': return 0xDE; + // VKEY_OEM_8 (DF) Used for miscellaneous characters; it can vary by + // keyboard. + // VKEY_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the + // backslash key on the RT 102-key keyboard + // VKEY_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: + // IME PROCESS key + // VKEY_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if + // they were keystrokes. The VKEY_PACKET key is the low word of a 32-bit + // Virtual Key value used for non-keyboard input methods. For more + // information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and + // WM_KEYUP + // VKEY_ATTN (F6) Attn key + // VKEY_CRSEL (F7) CrSel key + // VKEY_EXSEL (F8) ExSel key + // VKEY_EREOF (F9) Erase EOF key + // VKEY_PLAY (FA) Play key + // VKEY_ZOOM (FB) Zoom key + // VKEY_NONAME (FC) Reserved for future use + // VKEY_PA1 (FD) PA1 key + // VKEY_OEM_CLEAR (FE) Clear key + case GDK_F1: + case GDK_F2: + case GDK_F3: + case GDK_F4: + case GDK_F5: + case GDK_F6: + case GDK_F7: + case GDK_F8: + case GDK_F9: + case GDK_F10: + case GDK_F11: + case GDK_F12: + case GDK_F13: + case GDK_F14: + case GDK_F15: + case GDK_F16: + case GDK_F17: + case GDK_F18: + case GDK_F19: + case GDK_F20: + case GDK_F21: + case GDK_F22: + case GDK_F23: + case GDK_F24: + return VKEY_F1 + (keycode - GDK_F1); + default: + return 0; + } +} + +// TODO(jcampan): this method might be incomplete. +int GdkKeyCodeForWindowsKeyCode(int keycode) { + switch (keycode) { + case VKEY_NUMPAD0: + return GDK_KP_0; + case VKEY_NUMPAD1: + return GDK_KP_1; + case VKEY_NUMPAD2: + return GDK_KP_2; + case VKEY_NUMPAD3: + return GDK_KP_3; + case VKEY_NUMPAD4: + return GDK_KP_4; + case VKEY_NUMPAD5: + return GDK_KP_5; + case VKEY_NUMPAD6: + return GDK_KP_6; + case VKEY_NUMPAD7: + return GDK_KP_7; + case VKEY_NUMPAD8: + return GDK_KP_8; + case VKEY_NUMPAD9: + return GDK_KP_9; + case VKEY_MULTIPLY: + return GDK_KP_Multiply; + case VKEY_ADD: + return GDK_KP_Add; + case VKEY_SUBTRACT: + return GDK_KP_Subtract; + case VKEY_DECIMAL: + return GDK_KP_Decimal; + case VKEY_DIVIDE: + return GDK_KP_Divide; + + case VKEY_BACK: + return GDK_BackSpace; + case VKEY_TAB: + return GDK_Tab; + case VKEY_CLEAR: + return GDK_Clear; + case VKEY_RETURN: + return GDK_Return; + case VKEY_SHIFT: + return GDK_Shift_L; + case VKEY_CONTROL: + return GDK_Control_L; + case VKEY_MENU: + return GDK_Menu; + + case VKEY_PAUSE: + return GDK_Pause; + case VKEY_CAPITAL: + return GDK_Caps_Lock; + case VKEY_KANA: + return GDK_Kana_Lock; + case VKEY_HANJA: + return GDK_Hangul_Hanja; + case VKEY_ESCAPE: + return GDK_Escape; + case VKEY_SPACE: + return GDK_space; + case VKEY_PRIOR: + return GDK_Page_Up; + case VKEY_NEXT: + return GDK_Page_Down; + case VKEY_END: + return GDK_End; + case VKEY_HOME: + return GDK_Home; + case VKEY_LEFT: + return GDK_Left; + case VKEY_UP: + return GDK_Up; + case VKEY_RIGHT: + return GDK_Right; + case VKEY_DOWN: + return GDK_Down; + case VKEY_SELECT: + return GDK_Select; + case VKEY_PRINT: + return GDK_Print; + case VKEY_EXECUTE: + return GDK_Execute; + case VKEY_INSERT: + return GDK_Insert; + case VKEY_DELETE: + return GDK_Delete; + case VKEY_HELP: + return GDK_Help; + case VKEY_0: + return GDK_0; + case VKEY_1: + return GDK_1; + case VKEY_2: + return GDK_2; + case VKEY_3: + return GDK_3; + case VKEY_4: + return GDK_4; + case VKEY_5: + return GDK_5; + case VKEY_6: + return GDK_6; + case VKEY_7: + return GDK_7; + case VKEY_8: + return GDK_8; + case VKEY_9: + return GDK_9; + + case VKEY_A: + return GDK_a; + case VKEY_B: + return GDK_b; + case VKEY_C: + return GDK_c; + case VKEY_D: + return GDK_d; + case VKEY_E: + return GDK_e; + case VKEY_F: + return GDK_f; + case VKEY_G: + return GDK_g; + case VKEY_H: + return GDK_h; + case VKEY_I: + return GDK_i; + case VKEY_J: + return GDK_j; + case VKEY_K: + return GDK_k; + case VKEY_L: + return GDK_l; + case VKEY_M: + return GDK_m; + case VKEY_N: + return GDK_n; + case VKEY_O: + return GDK_o; + case VKEY_P: + return GDK_p; + case VKEY_Q: + return GDK_q; + case VKEY_R: + return GDK_r; + case VKEY_S: + return GDK_s; + case VKEY_T: + return GDK_t; + case VKEY_U: + return GDK_u; + case VKEY_V: + return GDK_v; + case VKEY_W: + return GDK_w; + case VKEY_X: + return GDK_x; + case VKEY_Y: + return GDK_y; + case VKEY_Z: + return GDK_z; + case VKEY_LWIN: + return GDK_Meta_L; + case VKEY_RWIN: + return GDK_Meta_R; + + case VKEY_NUMLOCK: + return GDK_Num_Lock; + + case VKEY_SCROLL: + return GDK_Scroll_Lock; + + case VKEY_OEM_1: + return GDK_semicolon; + case VKEY_OEM_PLUS: + return GDK_plus; + case VKEY_OEM_COMMA: + return GDK_comma; + case VKEY_OEM_MINUS: + return GDK_minus; + case VKEY_OEM_PERIOD: + return GDK_period; + case VKEY_OEM_2: + return GDK_slash; + case VKEY_OEM_3: + return GDK_asciitilde; + case VKEY_OEM_4: + return GDK_bracketleft; + case VKEY_OEM_5: + return GDK_backslash; + case VKEY_OEM_6: + return GDK_bracketright; + case VKEY_OEM_7: + return GDK_quoteright; + + case VKEY_F1: + case VKEY_F2: + case VKEY_F3: + case VKEY_F4: + case VKEY_F5: + case VKEY_F6: + case VKEY_F7: + case VKEY_F8: + case VKEY_F9: + case VKEY_F10: + case VKEY_F11: + case VKEY_F12: + case VKEY_F13: + case VKEY_F14: + case VKEY_F15: + case VKEY_F16: + case VKEY_F17: + case VKEY_F18: + case VKEY_F19: + case VKEY_F20: + case VKEY_F21: + case VKEY_F22: + case VKEY_F23: + case VKEY_F24: + return GDK_F1 + (keycode - VKEY_F1); + + default: + return 0; + } +} + +} // namespace + +#endif // BASE_KEYBOARD_CODE_CONVERSION_GTK_H_ diff --git a/base/keyboard_code_conversion_gtk.h b/base/keyboard_code_conversion_gtk.h new file mode 100755 index 0000000..9fd3b11 --- /dev/null +++ b/base/keyboard_code_conversion_gtk.h @@ -0,0 +1,49 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com + * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2008 Collabora, Ltd. All rights reserved. + * Copyright (C) 2008, 2009 Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// WindowsKeyCodeForGdkKeyCode is copied from platform/gtk/KeyEventGtk.cpp + +#ifndef BASE_KEYBOARD_CODE_CONVERSION_GTK_H_ +#define BASE_KEYBOARD_CODE_CONVERSION_GTK_H_ + +#include "base/keyboard_codes_posix.h" + +namespace base { + +int WindowsKeyCodeForGdkKeyCode(int keycode); + +int GdkKeyCodeForWindowsKeyCode(int keycode); + +} // namespace + +#endif // BASE_KEYBOARD_CODE_CONVERSION_GTK_H_ diff --git a/base/keyboard_codes.h b/base/keyboard_codes.h index 49add77..9a7f968 100644 --- a/base/keyboard_codes.h +++ b/base/keyboard_codes.h @@ -9,10 +9,8 @@ #if defined(OS_WIN) #include "base/keyboard_codes_win.h" -#elif defined(USE_X11) -#include "base/keyboard_codes_linux.h" -#elif defined(OS_MACOSX) -#include "base/keyboard_codes_mac.h" +#elif defined(USE_X11) || defined(OS_MACOSX) +#include "base/keyboard_codes_posix.h" #endif #endif // BASE_KEYBOARD_CODES_H_ diff --git a/base/keyboard_codes_linux.h b/base/keyboard_codes_linux.h deleted file mode 100644 index a56f48f..0000000 --- a/base/keyboard_codes_linux.h +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/* - * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com. All rights reserved. - * Copyright (C) 2008, 2009 Google Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR - * PROFITS, OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BASE_KEYBOARD_CODES_LINUX_H_ -#define BASE_KEYBOARD_CODES_LINUX_H_ - -#include <gdk/gdkkeysyms.h> -#include <X11/XF86keysym.h> - -namespace base { - -typedef enum { - VKEY_BACK = GDK_BackSpace, - VKEY_TAB = GDK_Tab, - VKEY_CLEAR = GDK_Clear, - VKEY_RETURN = GDK_Return, - VKEY_SHIFT = GDK_Shift_L, // TODO(jcampan): what about GDK_Shift_R? - VKEY_CONTROL = GDK_Control_L, // TODO(jcampan): what about GDK_Control_R? - VKEY_MENU = GDK_Menu, - VKEY_PAUSE = GDK_Pause, - VKEY_CAPITAL = GDK_Shift_Lock, - VKEY_KANA = GDK_Kana_Shift, - VKEY_HANGUL = GDK_Hangul, - // TODO(jcampan): not sure what the next 2 are. - VKEY_JUNJA = GDK_Hangul, - VKEY_FINAL = GDK_Hangul, - VKEY_HANJA = GDK_Hangul_Hanja, - VKEY_KANJI = GDK_Kanji, - VKEY_ESCAPE = GDK_Escape, - // TODO(jcampan): not sure what the next 4 are. - VKEY_CONVERT = 0x1C, - VKEY_NONCONVERT = 0x1D, - VKEY_ACCEPT = 0x1E, - VKEY_MODECHANGE = 0x1F, - VKEY_SPACE = GDK_space, - VKEY_PRIOR = GDK_Prior, - VKEY_NEXT = GDK_Next, - VKEY_END = GDK_End, - VKEY_HOME = GDK_Home, - VKEY_LEFT = GDK_Left, - VKEY_UP = GDK_Up, - VKEY_RIGHT = GDK_Right, - VKEY_DOWN = GDK_Down, - VKEY_SELECT = GDK_Select, - VKEY_PRINT = GDK_Print, - VKEY_EXECUTE = GDK_Execute, - VKEY_SNAPSHOT = 0x2C, // TODO(jcampan): not sure what this one is. - VKEY_INSERT = GDK_Insert, - VKEY_DELETE = GDK_Delete, - VKEY_HELP = GDK_Help, - VKEY_0 = GDK_0, - VKEY_1 = GDK_1, - VKEY_2 = GDK_2, - VKEY_3 = GDK_3, - VKEY_4 = GDK_4, - VKEY_5 = GDK_5, - VKEY_6 = GDK_6, - VKEY_7 = GDK_7, - VKEY_8 = GDK_8, - VKEY_9 = GDK_9, - VKEY_A = GDK_a, - VKEY_B = GDK_b, - VKEY_C = GDK_c, - VKEY_D = GDK_d, - VKEY_E = GDK_e, - VKEY_F = GDK_f, - VKEY_G = GDK_g, - VKEY_H = GDK_h, - VKEY_I = GDK_u, - VKEY_J = GDK_j, - VKEY_K = GDK_k, - VKEY_L = GDK_l, - VKEY_M = GDK_m, - VKEY_N = GDK_n, - VKEY_O = GDK_o, - VKEY_P = GDK_p, - VKEY_Q = GDK_q, - VKEY_R = GDK_r, - VKEY_S = GDK_s, - VKEY_T = GDK_t, - VKEY_U = GDK_u, - VKEY_V = GDK_v, - VKEY_W = GDK_w, - VKEY_X = GDK_x, - VKEY_Y = GDK_y, - VKEY_Z = GDK_z, - VKEY_LWIN = GDK_Meta_L, - VKEY_RWIN = GDK_Meta_R, - VKEY_APPS = 0x5D, // TODO(jcampan): not sure what this one is. - VKEY_SLEEP = XF86XK_Sleep, - VKEY_NUMPAD0 = GDK_KP_0, - VKEY_NUMPAD1 = GDK_KP_1, - VKEY_NUMPAD2 = GDK_KP_2, - VKEY_NUMPAD3 = GDK_KP_3, - VKEY_NUMPAD4 = GDK_KP_4, - VKEY_NUMPAD5 = GDK_KP_5, - VKEY_NUMPAD6 = GDK_KP_6, - VKEY_NUMPAD7 = GDK_KP_7, - VKEY_NUMPAD8 = GDK_KP_8, - VKEY_NUMPAD9 = GDK_KP_9, - VKEY_MULTIPLY = GDK_KP_Multiply, - VKEY_ADD = GDK_KP_Add, - VKEY_SEPARATOR = GDK_KP_Separator, - VKEY_SUBTRACT = GDK_KP_Subtract, - VKEY_DECIMAL = GDK_KP_Decimal, - VKEY_DIVIDE = GDK_KP_Divide, - VKEY_F1 = GDK_F1, - VKEY_F2 = GDK_F2, - VKEY_F3 = GDK_F3, - VKEY_F4 = GDK_F4, - VKEY_F5 = GDK_F5, - VKEY_F6 = GDK_F6, - VKEY_F7 = GDK_F7, - VKEY_F8 = GDK_F8, - VKEY_F9 = GDK_F9, - VKEY_F10 = GDK_F10, - VKEY_F11 = GDK_F11, - VKEY_F12 = GDK_F12, - VKEY_F13 = GDK_F13, - VKEY_F14 = GDK_F14, - VKEY_F15 = GDK_F15, - VKEY_F16 = GDK_F16, - VKEY_F17 = GDK_F17, - VKEY_F18 = GDK_F18, - VKEY_F19 = GDK_F19, - VKEY_F20 = GDK_F20, - VKEY_F21 = GDK_F21, - VKEY_F22 = GDK_F22, - VKEY_F23 = GDK_F23, - VKEY_F24 = GDK_F24, - VKEY_NUMLOCK = GDK_Num_Lock, - VKEY_SCROLL = GDK_Scroll_Lock, - VKEY_LSHIFT = GDK_Shift_L, - VKEY_RSHIFT = GDK_Shift_R, - VKEY_LCONTROL = GDK_Control_L, - VKEY_RCONTROL = GDK_Control_R, - VKEY_LMENU = GDK_Alt_L, - VKEY_RMENU = GDK_Alt_R, - VKEY_BROWSER_BACK = XF86XK_Back, - VKEY_BROWSER_FORWARD = XF86XK_Forward, - VKEY_BROWSER_REFRESH = XF86XK_Refresh, - VKEY_BROWSER_STOP = XF86XK_Stop, - VKEY_BROWSER_SEARCH = XF86XK_Search, - VKEY_BROWSER_FAVORITES = XF86XK_Favorites, - VKEY_BROWSER_HOME = XF86XK_HomePage, - VKEY_VOLUME_MUTE = XF86XK_AudioMute, - VKEY_VOLUME_DOWN = XF86XK_AudioLowerVolume, - VKEY_VOLUME_UP = XF86XK_AudioRaiseVolume, - VKEY_MEDIA_NEXT_TRACK = XF86XK_AudioNext, - VKEY_MEDIA_PREV_TRACK = XF86XK_AudioPrev, - VKEY_MEDIA_STOP = XF86XK_AudioStop, - VKEY_MEDIA_PLAY_PAUSE = XF86XK_AudioPause, - VKEY_MEDIA_LAUNCH_MAIL = XF86XK_Mail, - VKEY_MEDIA_LAUNCH_MEDIA_SELECT = XF86XK_AudioMedia, - VKEY_MEDIA_LAUNCH_APP1 = XF86XK_Launch1, - VKEY_MEDIA_LAUNCH_APP2 = XF86XK_Launch2, - // TODO(jcampan): Figure-out values below. - VKEY_OEM_1 = 0xBA, - VKEY_OEM_PLUS = 0xBB, - VKEY_OEM_COMMA = 0xBC, - VKEY_OEM_MINUS = 0xBD, - VKEY_OEM_PERIOD = 0xBE, - VKEY_OEM_2 = 0xBF, - VKEY_OEM_3 = 0xC0, - VKEY_OEM_4 = 0xDB, - VKEY_OEM_5 = 0xDC, - VKEY_OEM_6 = 0xDD, - VKEY_OEM_7 = 0xDE, - VKEY_OEM_8 = 0xDF, - VKEY_OEM_102 = 0xE2, - VKEY_PROCESSKEY = 0xE5, - VKEY_PACKET = 0xE7, - VKEY_ATTN = 0xF6, - VKEY_CRSEL = 0xF7, - VKEY_EXSEL = 0xF8, - VKEY_EREOF = 0xF9, - VKEY_PLAY = 0xFA, - VKEY_ZOOM = XF86XK_ZoomIn, - VKEY_NONAME = 0xFC, - VKEY_PA1 = 0xFD, - VKEY_OEM_CLEAR = 0xFE, - VKEY_UNKNOWN = 0 -} KeyboardCode; - -} // namespace views - -#endif // BASE_KEYBOARD_CODES_LINUX_H_ diff --git a/base/keyboard_codes_mac.h b/base/keyboard_codes_posix.h index 4c3ce79..78cd047 100644 --- a/base/keyboard_codes_mac.h +++ b/base/keyboard_codes_posix.h @@ -28,8 +28,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BASE_KEYBOARD_CODES_MAC_H_ -#define BASE_KEYBOARD_CODES_MAC_H_ +#ifndef BASE_KEYBOARD_CODES_POSIX_H_ +#define BASE_KEYBOARD_CODES_POSIX_H_ namespace base { @@ -205,4 +205,4 @@ typedef enum { } // namespace views -#endif // BASE_KEYBOARD_CODES_MAC_H_ +#endif // BASE_KEYBOARD_CODES_POSIX_H_ diff --git a/chrome/browser/automation/ui_controls.h b/chrome/browser/automation/ui_controls.h index 113e012..7a7a6d6 100644 --- a/chrome/browser/automation/ui_controls.h +++ b/chrome/browser/automation/ui_controls.h @@ -42,6 +42,7 @@ namespace ui_controls { // these functions, so passing NULL is ok. // Send a key press with/without modifier keys. +// |key| should be a VKEY code as defined in base/keyboard_codes.h bool SendKeyPress(gfx::NativeWindow window, wchar_t key, bool control, bool shift, bool alt); bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, wchar_t key, diff --git a/chrome/browser/automation/ui_controls_linux.cc b/chrome/browser/automation/ui_controls_linux.cc index 16e6483..738f566 100644 --- a/chrome/browser/automation/ui_controls_linux.cc +++ b/chrome/browser/automation/ui_controls_linux.cc @@ -8,6 +8,7 @@ #include <gdk/gdkkeysyms.h> #include "base/gfx/rect.h" +#include "base/keyboard_code_conversion_gtk.h" #include "base/logging.h" #include "base/message_loop.h" #include "chrome/common/gtk_util.h" @@ -87,7 +88,7 @@ class ClickTask : public Task { Task* followup_; }; -bool SendKeyEvent(GdkWindow* window, bool press, guint key, guint state) { +bool SendKeyEvent(GdkWindow* window, bool press, guint gdk_key, guint state) { GdkEvent* event = gdk_event_new(press ? GDK_KEY_PRESS : GDK_KEY_RELEASE); event->key.type = press ? GDK_KEY_PRESS : GDK_KEY_RELEASE; @@ -97,7 +98,7 @@ bool SendKeyEvent(GdkWindow* window, bool press, guint key, guint state) { event->key.time = EventTimeNow(); event->key.state = state; - event->key.keyval = key; + event->key.keyval = gdk_key; GdkKeymapKey* keys; gint n_keys; @@ -195,6 +196,8 @@ bool SendKeyPress(gfx::NativeWindow window, guint state = (control ? GDK_CONTROL_MASK : 0) | (shift ? GDK_SHIFT_MASK : 0) | (alt ? GDK_MOD1_MASK : 0); + + key = base::GdkKeyCodeForWindowsKeyCode(key); rv = rv && SendKeyEvent(event_window, true, key, state); rv = rv && SendKeyEvent(event_window, false, key, state); diff --git a/chrome/browser/views/accelerator_table_gtk.cc b/chrome/browser/views/accelerator_table_gtk.cc index 7579769..4a24493 100644 --- a/chrome/browser/views/accelerator_table_gtk.cc +++ b/chrome/browser/views/accelerator_table_gtk.cc @@ -2,140 +2,118 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <gdk/gdkkeysyms.h> -#include <X11/XF86keysym.h> - #include "chrome/browser/views/accelerator_table_gtk.h" #include "base/basictypes.h" +#include "base/keyboard_codes.h" #include "chrome/app/chrome_dll_resource.h" namespace browser { const AcceleratorMapping kAcceleratorMap[] = { // Focus. - { GDK_k, IDC_FOCUS_SEARCH, GDK_CONTROL_MASK }, - { GDK_e, IDC_FOCUS_SEARCH, GDK_CONTROL_MASK }, - { XF86XK_Search, IDC_FOCUS_SEARCH, GdkModifierType(0) }, - { GDK_l, IDC_FOCUS_LOCATION, GDK_CONTROL_MASK }, - { GDK_d, IDC_FOCUS_LOCATION, GDK_MOD1_MASK }, - { GDK_F6, IDC_FOCUS_LOCATION, GdkModifierType(0) }, - { XF86XK_OpenURL, IDC_FOCUS_LOCATION, GdkModifierType(0) }, - { XF86XK_Go, IDC_FOCUS_LOCATION, GdkModifierType(0) }, + { base::VKEY_K, false, true, false, IDC_FOCUS_SEARCH }, + { base::VKEY_E, false, true, false, IDC_FOCUS_SEARCH }, + { base::VKEY_BROWSER_SEARCH, false, false, false, IDC_FOCUS_SEARCH }, + { base::VKEY_L, false, true, false, IDC_FOCUS_LOCATION }, + { base::VKEY_D, false, false, true, IDC_FOCUS_LOCATION }, + { base::VKEY_F6, false, false, false, IDC_FOCUS_LOCATION }, // Tab/window controls. - { GDK_t, IDC_NEW_TAB, GDK_CONTROL_MASK }, - { GDK_n, IDC_NEW_WINDOW, GDK_CONTROL_MASK }, - { GDK_n, IDC_NEW_INCOGNITO_WINDOW, - GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK) }, - { GDK_Page_Down, IDC_SELECT_NEXT_TAB, GDK_CONTROL_MASK }, - { GDK_Page_Up, IDC_SELECT_PREVIOUS_TAB, GDK_CONTROL_MASK }, - { GDK_w, IDC_CLOSE_TAB, GDK_CONTROL_MASK }, - { GDK_t, IDC_RESTORE_TAB, - GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK) }, - - { GDK_1, IDC_SELECT_TAB_0, GDK_CONTROL_MASK }, - { GDK_2, IDC_SELECT_TAB_1, GDK_CONTROL_MASK }, - { GDK_3, IDC_SELECT_TAB_2, GDK_CONTROL_MASK }, - { GDK_4, IDC_SELECT_TAB_3, GDK_CONTROL_MASK }, - { GDK_5, IDC_SELECT_TAB_4, GDK_CONTROL_MASK }, - { GDK_6, IDC_SELECT_TAB_5, GDK_CONTROL_MASK }, - { GDK_7, IDC_SELECT_TAB_6, GDK_CONTROL_MASK }, - { GDK_8, IDC_SELECT_TAB_7, GDK_CONTROL_MASK }, - { GDK_9, IDC_SELECT_LAST_TAB, GDK_CONTROL_MASK }, - - { GDK_1, IDC_SELECT_TAB_0, GDK_MOD1_MASK }, - { GDK_2, IDC_SELECT_TAB_1, GDK_MOD1_MASK }, - { GDK_3, IDC_SELECT_TAB_2, GDK_MOD1_MASK }, - { GDK_4, IDC_SELECT_TAB_3, GDK_MOD1_MASK }, - { GDK_5, IDC_SELECT_TAB_4, GDK_MOD1_MASK }, - { GDK_6, IDC_SELECT_TAB_5, GDK_MOD1_MASK }, - { GDK_7, IDC_SELECT_TAB_6, GDK_MOD1_MASK }, - { GDK_8, IDC_SELECT_TAB_7, GDK_MOD1_MASK }, - { GDK_9, IDC_SELECT_LAST_TAB, GDK_MOD1_MASK }, - - { GDK_KP_1, IDC_SELECT_TAB_0, GDK_CONTROL_MASK }, - { GDK_KP_2, IDC_SELECT_TAB_1, GDK_CONTROL_MASK }, - { GDK_KP_3, IDC_SELECT_TAB_2, GDK_CONTROL_MASK }, - { GDK_KP_4, IDC_SELECT_TAB_3, GDK_CONTROL_MASK }, - { GDK_KP_5, IDC_SELECT_TAB_4, GDK_CONTROL_MASK }, - { GDK_KP_6, IDC_SELECT_TAB_5, GDK_CONTROL_MASK }, - { GDK_KP_7, IDC_SELECT_TAB_6, GDK_CONTROL_MASK }, - { GDK_KP_8, IDC_SELECT_TAB_7, GDK_CONTROL_MASK }, - { GDK_KP_9, IDC_SELECT_LAST_TAB, GDK_CONTROL_MASK }, - - { GDK_KP_1, IDC_SELECT_TAB_0, GDK_MOD1_MASK }, - { GDK_KP_2, IDC_SELECT_TAB_1, GDK_MOD1_MASK }, - { GDK_KP_3, IDC_SELECT_TAB_2, GDK_MOD1_MASK }, - { GDK_KP_4, IDC_SELECT_TAB_3, GDK_MOD1_MASK }, - { GDK_KP_5, IDC_SELECT_TAB_4, GDK_MOD1_MASK }, - { GDK_KP_6, IDC_SELECT_TAB_5, GDK_MOD1_MASK }, - { GDK_KP_7, IDC_SELECT_TAB_6, GDK_MOD1_MASK }, - { GDK_KP_8, IDC_SELECT_TAB_7, GDK_MOD1_MASK }, - { GDK_KP_9, IDC_SELECT_LAST_TAB, GDK_MOD1_MASK }, - - { GDK_F4, IDC_CLOSE_TAB, GDK_CONTROL_MASK }, - { GDK_F4, IDC_CLOSE_WINDOW, GDK_MOD1_MASK }, + { base::VKEY_T, false, true, false, IDC_NEW_TAB }, + { base::VKEY_N, false, true, false, IDC_NEW_WINDOW }, + { base::VKEY_N, true, true, false, IDC_NEW_INCOGNITO_WINDOW }, + { base::VKEY_DOWN, false, true, false, IDC_SELECT_NEXT_TAB }, + { base::VKEY_UP, false, true, false, IDC_SELECT_PREVIOUS_TAB }, + { base::VKEY_W, false, true, false, IDC_CLOSE_TAB }, + { base::VKEY_T, true, true, false, IDC_RESTORE_TAB }, + + { base::VKEY_1, false, true, false, IDC_SELECT_TAB_0 }, + { base::VKEY_2, false, true, false, IDC_SELECT_TAB_1 }, + { base::VKEY_3, false, true, false, IDC_SELECT_TAB_2 }, + { base::VKEY_4, false, true, false, IDC_SELECT_TAB_3 }, + { base::VKEY_5, false, true, false, IDC_SELECT_TAB_4 }, + { base::VKEY_6, false, true, false, IDC_SELECT_TAB_5 }, + { base::VKEY_7, false, true, false, IDC_SELECT_TAB_6 }, + { base::VKEY_8, false, true, false, IDC_SELECT_TAB_7 }, + { base::VKEY_9, false, true, false, IDC_SELECT_LAST_TAB }, + + { base::VKEY_1, false, false, true, IDC_SELECT_TAB_0 }, + { base::VKEY_2, false, false, true, IDC_SELECT_TAB_1 }, + { base::VKEY_3, false, false, true, IDC_SELECT_TAB_2 }, + { base::VKEY_4, false, false, true, IDC_SELECT_TAB_3 }, + { base::VKEY_5, false, false, true, IDC_SELECT_TAB_4 }, + { base::VKEY_6, false, false, true, IDC_SELECT_TAB_5 }, + { base::VKEY_7, false, false, true, IDC_SELECT_TAB_6 }, + { base::VKEY_8, false, false, true, IDC_SELECT_TAB_7 }, + { base::VKEY_9, false, false, true, IDC_SELECT_LAST_TAB }, + + { base::VKEY_NUMPAD1, false, true, false, IDC_SELECT_TAB_0 }, + { base::VKEY_NUMPAD2, false, true, false, IDC_SELECT_TAB_1 }, + { base::VKEY_NUMPAD3, false, true, false, IDC_SELECT_TAB_2 }, + { base::VKEY_NUMPAD4, false, true, false, IDC_SELECT_TAB_3 }, + { base::VKEY_NUMPAD5, false, true, false, IDC_SELECT_TAB_4 }, + { base::VKEY_NUMPAD6, false, true, false, IDC_SELECT_TAB_5 }, + { base::VKEY_NUMPAD7, false, true, false, IDC_SELECT_TAB_6 }, + { base::VKEY_NUMPAD8, false, true, false, IDC_SELECT_TAB_7 }, + { base::VKEY_NUMPAD9, false, true, false, IDC_SELECT_LAST_TAB }, + + { base::VKEY_NUMPAD1, false, false, true, IDC_SELECT_TAB_0 }, + { base::VKEY_NUMPAD2, false, false, true, IDC_SELECT_TAB_1 }, + { base::VKEY_NUMPAD3, false, false, true, IDC_SELECT_TAB_2 }, + { base::VKEY_NUMPAD4, false, false, true, IDC_SELECT_TAB_3 }, + { base::VKEY_NUMPAD5, false, false, true, IDC_SELECT_TAB_4 }, + { base::VKEY_NUMPAD6, false, false, true, IDC_SELECT_TAB_5 }, + { base::VKEY_NUMPAD7, false, false, true, IDC_SELECT_TAB_6 }, + { base::VKEY_NUMPAD8, false, false, true, IDC_SELECT_TAB_7 }, + { base::VKEY_NUMPAD9, false, false, true, IDC_SELECT_LAST_TAB }, + + { base::VKEY_F4, false, true, false, IDC_CLOSE_TAB }, + { base::VKEY_F4, false, false, true, IDC_CLOSE_WINDOW }, // Zoom level. - { GDK_plus, IDC_ZOOM_PLUS, - GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK) }, - { GDK_equal, IDC_ZOOM_PLUS, GDK_CONTROL_MASK }, - { XF86XK_ZoomIn, IDC_ZOOM_PLUS, GdkModifierType(0) }, - { GDK_0, IDC_ZOOM_NORMAL, GDK_CONTROL_MASK }, - { GDK_minus, IDC_ZOOM_MINUS, GDK_CONTROL_MASK }, - { GDK_underscore, IDC_ZOOM_MINUS, - GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK) }, - { XF86XK_ZoomOut, IDC_ZOOM_MINUS, GdkModifierType(0) }, + { base::VKEY_OEM_PLUS, false, true, false, IDC_ZOOM_PLUS }, + { base::VKEY_OEM_PLUS, true, true, false, IDC_ZOOM_PLUS }, + { base::VKEY_0, false, true, false, IDC_ZOOM_NORMAL }, + { base::VKEY_OEM_MINUS, false, true, false, IDC_ZOOM_MINUS }, + { base::VKEY_OEM_MINUS, true, true, false, IDC_ZOOM_MINUS }, // Find in page. - { GDK_g, IDC_FIND_NEXT, GDK_CONTROL_MASK }, - { GDK_F3, IDC_FIND_NEXT, GdkModifierType(0) }, - { GDK_g, IDC_FIND_PREVIOUS, - GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK) }, - { GDK_F3, IDC_FIND_PREVIOUS, GDK_SHIFT_MASK }, + { base::VKEY_F, false, true, false, IDC_FIND }, + { base::VKEY_G, false, true, false, IDC_FIND_NEXT }, + { base::VKEY_F3, false, false, false, IDC_FIND_NEXT }, + { base::VKEY_G, true, true, false, IDC_FIND_PREVIOUS }, + { base::VKEY_F3, true, false, false, IDC_FIND_PREVIOUS }, // Navigation / toolbar buttons. - { GDK_Home, IDC_HOME, GDK_MOD1_MASK }, - { XF86XK_HomePage, IDC_HOME, GdkModifierType(0) }, - { GDK_Escape, IDC_STOP, GdkModifierType(0) }, - { XF86XK_Stop, IDC_STOP, GdkModifierType(0) }, - { GDK_Left, IDC_BACK, GDK_MOD1_MASK }, - { GDK_BackSpace, IDC_BACK, GdkModifierType(0) }, - { XF86XK_Back, IDC_BACK, GdkModifierType(0) }, - { GDK_Right, IDC_FORWARD, GDK_MOD1_MASK }, - { GDK_BackSpace, IDC_FORWARD, GDK_SHIFT_MASK }, - { XF86XK_Forward, IDC_FORWARD, GdkModifierType(0) }, - { GDK_r, IDC_RELOAD, GDK_CONTROL_MASK }, - { GDK_F5, IDC_RELOAD, GdkModifierType(0) }, - { GDK_F5, IDC_RELOAD, GDK_CONTROL_MASK }, - { GDK_F5, IDC_RELOAD, GDK_SHIFT_MASK }, - { XF86XK_Reload, IDC_RELOAD, GdkModifierType(0) }, - { XF86XK_Refresh, IDC_RELOAD, GdkModifierType(0) }, + { base::VKEY_HOME, false, false, true, IDC_HOME }, + { base::VKEY_ESCAPE, false, false, false, IDC_STOP }, + { base::VKEY_LEFT, false, false, true, IDC_BACK }, + { base::VKEY_BACK, false, false, false, IDC_BACK }, + { base::VKEY_RIGHT, false, false, true, IDC_FORWARD }, + { base::VKEY_BACK, true, false, false, IDC_FORWARD }, + { base::VKEY_R, false, true, false, IDC_RELOAD }, + { base::VKEY_F5, false, false, false, IDC_RELOAD }, + { base::VKEY_F5, false, true, false, IDC_RELOAD }, + { base::VKEY_F5, true, false, false, IDC_RELOAD }, // Miscellany. - { GDK_d, IDC_STAR, GDK_CONTROL_MASK }, - { XF86XK_AddFavorite, IDC_STAR, GdkModifierType(0) }, - { XF86XK_Favorites, IDC_SHOW_BOOKMARK_BAR, GdkModifierType(0) }, - { GDK_b, IDC_SHOW_BOOKMARK_BAR, GDK_CONTROL_MASK }, - { XF86XK_History, IDC_SHOW_HISTORY, GdkModifierType(0) }, - { GDK_h, IDC_SHOW_HISTORY, GDK_CONTROL_MASK }, - { GDK_j, IDC_SHOW_DOWNLOADS, GDK_CONTROL_MASK }, - { GDK_o, IDC_OPEN_FILE, GDK_CONTROL_MASK }, - { GDK_F11, IDC_FULLSCREEN, GdkModifierType(0) }, - { GDK_u, IDC_VIEW_SOURCE, GDK_CONTROL_MASK }, - { GDK_j, IDC_DEV_TOOLS, GdkModifierType(GDK_CONTROL_MASK | GDK_MOD1_MASK) }, - { GDK_p, IDC_PRINT, GDK_CONTROL_MASK }, - { GDK_Escape, IDC_TASK_MANAGER, GDK_SHIFT_MASK }, - { GDK_f, IDC_FULLSCREEN, - GdkModifierType(GDK_CONTROL_MASK | GDK_MOD1_MASK) }, - { GDK_Delete, IDC_TASK_MANAGER, - GdkModifierType(GDK_CONTROL_MASK | GDK_MOD1_MASK) }, - { GDK_comma, IDC_CONTROL_PANEL, GdkModifierType(GDK_CONTROL_MASK) }, - { GDK_b, IDC_SHOW_BOOKMARK_MANAGER, - GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK) }, - { GDK_F1, IDC_HELP_PAGE, GdkModifierType(0) }, - { GDK_q, IDC_EXIT, GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK) }, + { base::VKEY_D, false, true, false, IDC_STAR }, + { base::VKEY_B, false, true, false, IDC_SHOW_BOOKMARK_BAR }, + { base::VKEY_H, false, true, false, IDC_SHOW_HISTORY }, + { base::VKEY_J, false, true, false, IDC_SHOW_DOWNLOADS }, + { base::VKEY_O, false, true, false, IDC_OPEN_FILE }, + { base::VKEY_F11, false, false, false, IDC_FULLSCREEN }, + { base::VKEY_U, false, true, false, IDC_VIEW_SOURCE }, + { base::VKEY_J, true, true, false, IDC_DEV_TOOLS }, + { base::VKEY_P, false, true, false, IDC_PRINT}, + { base::VKEY_ESCAPE, true, false, false, IDC_TASK_MANAGER }, + { base::VKEY_F11, false, true, true, IDC_FULLSCREEN }, + { base::VKEY_DELETE, false, true, true, IDC_TASK_MANAGER }, + { base::VKEY_OEM_COMMA, false, true, false, IDC_CONTROL_PANEL }, + { base::VKEY_B, true, true, false, IDC_SHOW_BOOKMARK_MANAGER }, + { base::VKEY_F1, false, false, false, IDC_HELP_PAGE }, + { base::VKEY_Q, true, true, false, IDC_EXIT }, }; const size_t kAcceleratorMapLength = arraysize(kAcceleratorMap); diff --git a/chrome/browser/views/accelerator_table_gtk.h b/chrome/browser/views/accelerator_table_gtk.h index 830fdb2..29f7588 100644 --- a/chrome/browser/views/accelerator_table_gtk.h +++ b/chrome/browser/views/accelerator_table_gtk.h @@ -5,16 +5,18 @@ #ifndef CHROME_BROWSER_VIEWS_ACCELERATOR_TABLE_GTK_H_ #define CHROME_BROWSER_VIEWS_ACCELERATOR_TABLE_GTK_H_ -#include <gtk/gtk.h> +#include <stdio.h> -// This contains the list of accelerators shared between the Linux Gtk and -// toolkit_view implementation. +// This contains the list of accelerators for the Linux toolkit_view +// implementation. namespace browser { struct AcceleratorMapping { - guint keyval; + int keycode; + bool shift_pressed; + bool ctrl_pressed; + bool alt_pressed; int command_id; - GdkModifierType modifier_type; }; // The list of accelerators. diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 7ef0c80..d4a0e8f 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -2008,17 +2008,10 @@ void BrowserView::LoadAccelerators() { DCHECK(focus_manager); // Let's fill our own accelerator table. for (size_t i = 0; i < browser::kAcceleratorMapLength; ++i) { - bool alt_down = - (browser::kAcceleratorMap[i].modifier_type & GDK_MOD1_MASK) == - GDK_MOD1_MASK; - bool ctrl_down = - (browser::kAcceleratorMap[i].modifier_type & GDK_CONTROL_MASK) == - GDK_CONTROL_MASK; - bool shift_down = - (browser::kAcceleratorMap[i].modifier_type & GDK_SHIFT_MASK) == - GDK_SHIFT_MASK; - views::Accelerator accelerator(browser::kAcceleratorMap[i].keyval, - shift_down, ctrl_down, alt_down); + views::Accelerator accelerator(browser::kAcceleratorMap[i].keycode, + browser::kAcceleratorMap[i].shift_pressed, + browser::kAcceleratorMap[i].ctrl_pressed, + browser::kAcceleratorMap[i].alt_pressed); accelerator_table_[accelerator] = browser::kAcceleratorMap[i].command_id; // Also register with the focus manager. diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc index 6a4f76c..dbc7c26 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc +++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc @@ -310,7 +310,7 @@ void TabContentsViewGtk::HandleKeyboardEvent( bool alt_pressed = (event.modifiers & WebInputEvent::AltKey) == WebInputEvent::AltKey; - focus_manager->ProcessAccelerator(views::Accelerator(event.os_event->keyval, + focus_manager->ProcessAccelerator(views::Accelerator(event.windowsKeyCode, shift_pressed, ctrl_pressed, alt_pressed)); diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc index c7eadca..e507d93 100644 --- a/views/controls/button/custom_button.cc +++ b/views/controls/button/custom_button.cc @@ -99,7 +99,7 @@ bool CustomButton::AcceleratorPressed(const Accelerator& accelerator) { gdk_key.state = (accelerator.IsAltDown() << 3) + (accelerator.IsCtrlDown() << 2) + accelerator.IsShiftDown(); - KeyEvent key_event(&gdk_key, false); + KeyEvent key_event(&gdk_key); #endif NotifyClick(key_event); return true; diff --git a/views/event.h b/views/event.h index 882f558..5a6efd9 100644 --- a/views/event.h +++ b/views/event.h @@ -244,9 +244,13 @@ class KeyEvent : public Event { // Create a new key event KeyEvent(EventType type, int ch, int repeat_count, int message_flags); #elif defined(OS_LINUX) - KeyEvent(GdkEventKey* event, bool make_lower_case); + explicit KeyEvent(GdkEventKey* event); #endif + // This returns a VKEY_ value as defined in base/keyboard_codes.h which is + // the Windows value. + // On GTK, you can use the methods in keyboard_code_conversion_gtk.cc to + // convert this value back to a GDK value if needed. int GetCharacter() const { return character_; } diff --git a/views/event_gtk.cc b/views/event_gtk.cc index 6f1e450..71fd056 100644 --- a/views/event_gtk.cc +++ b/views/event_gtk.cc @@ -6,18 +6,19 @@ #include <gdk/gdk.h> +#include "base/keyboard_code_conversion_gtk.h" + namespace views { // TODO(jcampan): the same physical key can send different keyvals (ex: a or A). // In order for accelerators to work, we need to normalize that. The right // solution should probably to get the key-code out of the keystate. -KeyEvent::KeyEvent(GdkEventKey* event, bool make_lower_case) +KeyEvent::KeyEvent(GdkEventKey* event) : Event(event->type == GDK_KEY_PRESS ? Event::ET_KEY_PRESSED : Event::ET_KEY_RELEASED, GetFlagsFromGdkState(event->state)), // TODO(erg): All these values are iffy. - character_(make_lower_case ? gdk_keyval_to_lower(event->keyval) : - event->keyval), + character_(base::WindowsKeyCodeForGdkKeyCode(event->keyval)), repeat_count_(0), message_flags_(0) { } diff --git a/views/focus/accelerator_handler_gtk.cc b/views/focus/accelerator_handler_gtk.cc index 8b52b98..bb519bb 100644 --- a/views/focus/accelerator_handler_gtk.cc +++ b/views/focus/accelerator_handler_gtk.cc @@ -43,7 +43,7 @@ bool AcceleratorHandler::Dispatch(GdkEvent* event) { } if (event->type == GDK_KEY_PRESS) { - KeyEvent view_key_event(key_event, true); + KeyEvent view_key_event(key_event); // FocusManager::OnKeyPressed and OnKeyReleased return false if this // message has been consumed and should not be propagated further. if (!focus_manager->OnKeyEvent(view_key_event)) { diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 8f43603..81c214d 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -700,12 +700,12 @@ gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) { } gboolean WidgetGtk::OnKeyPress(GtkWidget* widget, GdkEventKey* event) { - KeyEvent key_event(event, false); + KeyEvent key_event(event); return root_view_->ProcessKeyEvent(key_event); } gboolean WidgetGtk::OnKeyRelease(GtkWidget* widget, GdkEventKey* event) { - KeyEvent key_event(event, false); + KeyEvent key_event(event); return root_view_->ProcessKeyEvent(key_event); } |