| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /* | 5 /* |
| 6 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 6 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com | 7 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com |
| 8 * Copyright (C) 2007 Holger Hans Peter Freyther | 8 * Copyright (C) 2007 Holger Hans Peter Freyther |
| 9 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. | 9 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. |
| 10 * Copyright (C) 2008, 2009 Google Inc. | 10 * Copyright (C) 2008, 2009 Google Inc. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 */ | 32 */ |
| 33 | 33 |
| 34 // WindowsKeyCodeForGdkKeyCode is copied from platform/gtk/KeyEventGtk.cpp | 34 // WindowsKeyCodeForGdkKeyCode is copied from platform/gtk/KeyEventGtk.cpp |
| 35 | 35 |
| 36 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" | 36 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" |
| 37 | 37 |
| 38 #include <gdk/gdk.h> | 38 #include <gdk/gdk.h> |
| 39 #include <gdk/gdkkeysyms.h> | 39 #include <gdk/gdkkeysyms.h> |
| 40 | 40 |
| 41 #include "build/build_config.h" | 41 #include "build/build_config.h" |
| 42 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
| 42 #include "ui/base/keycodes/keyboard_codes_posix.h" | 43 #include "ui/base/keycodes/keyboard_codes_posix.h" |
| 43 | 44 |
| 44 #ifdef USE_X11 | |
| 45 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | |
| 46 #endif | |
| 47 | |
| 48 namespace ui { | 45 namespace ui { |
| 49 | 46 |
| 50 KeyboardCode WindowsKeyCodeForGdkKeyCode(int keycode) { | 47 KeyboardCode WindowsKeyCodeForGdkKeyCode(int keycode) { |
| 51 switch (keycode) { | 48 switch (keycode) { |
| 52 case GDK_KP_0: | 49 case GDK_KP_0: |
| 53 return VKEY_NUMPAD0; // (60) Numeric keypad 0 key | 50 return VKEY_NUMPAD0; // (60) Numeric keypad 0 key |
| 54 case GDK_KP_1: | 51 case GDK_KP_1: |
| 55 return VKEY_NUMPAD1; // (61) Numeric keypad 1 key | 52 return VKEY_NUMPAD1; // (61) Numeric keypad 1 key |
| 56 case GDK_KP_2: | 53 case GDK_KP_2: |
| 57 return VKEY_NUMPAD2; // (62) Numeric keypad 2 key | 54 return VKEY_NUMPAD2; // (62) Numeric keypad 2 key |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 if (keyval && gdk_keymap_get_entries_for_keyval(0, keyval, &keys, &n_keys)) { | 627 if (keyval && gdk_keymap_get_entries_for_keyval(0, keyval, &keys, &n_keys)) { |
| 631 native_keycode = keys[0].keycode; | 628 native_keycode = keys[0].keycode; |
| 632 g_free(keys); | 629 g_free(keys); |
| 633 } | 630 } |
| 634 | 631 |
| 635 return native_keycode; | 632 return native_keycode; |
| 636 } | 633 } |
| 637 | 634 |
| 638 KeyboardCode KeyboardCodeFromGdkEventKey(GdkEventKey* event) { | 635 KeyboardCode KeyboardCodeFromGdkEventKey(GdkEventKey* event) { |
| 639 KeyboardCode keycode = WindowsKeyCodeForGdkKeyCode(event->keyval); | 636 KeyboardCode keycode = WindowsKeyCodeForGdkKeyCode(event->keyval); |
| 640 #ifdef USE_X11 | |
| 641 // Gtk's key values are same as X11's keysyms. | 637 // Gtk's key values are same as X11's keysyms. |
| 642 if (keycode == VKEY_UNKNOWN) { | 638 if (keycode == VKEY_UNKNOWN) { |
| 643 unsigned int keyval = | 639 unsigned int keyval = |
| 644 DefaultXKeysymFromHardwareKeycode(event->hardware_keycode); | 640 DefaultXKeysymFromHardwareKeycode(event->hardware_keycode); |
| 645 keycode = WindowsKeyCodeForGdkKeyCode(keyval); | 641 keycode = WindowsKeyCodeForGdkKeyCode(keyval); |
| 646 } | 642 } |
| 647 #endif | |
| 648 return keycode; | 643 return keycode; |
| 649 } | 644 } |
| 650 | 645 |
| 651 } // namespace ui | 646 } // namespace ui |
| OLD | NEW |