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 17 matching lines...) Expand all Loading... |
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
29 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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/gdkkeysyms.h> | 39 #include <gdk/gdkkeysyms.h> |
39 | 40 |
| 41 #include "build/build_config.h" |
40 #include "ui/base/keycodes/keyboard_codes_posix.h" | 42 #include "ui/base/keycodes/keyboard_codes_posix.h" |
41 | 43 |
| 44 #ifdef USE_X11 |
| 45 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
| 46 #endif |
| 47 |
42 namespace ui { | 48 namespace ui { |
43 | 49 |
44 KeyboardCode WindowsKeyCodeForGdkKeyCode(int keycode) { | 50 KeyboardCode WindowsKeyCodeForGdkKeyCode(int keycode) { |
45 switch (keycode) { | 51 switch (keycode) { |
46 case GDK_KP_0: | 52 case GDK_KP_0: |
47 return VKEY_NUMPAD0; // (60) Numeric keypad 0 key | 53 return VKEY_NUMPAD0; // (60) Numeric keypad 0 key |
48 case GDK_KP_1: | 54 case GDK_KP_1: |
49 return VKEY_NUMPAD1; // (61) Numeric keypad 1 key | 55 return VKEY_NUMPAD1; // (61) Numeric keypad 1 key |
50 case GDK_KP_2: | 56 case GDK_KP_2: |
51 return VKEY_NUMPAD2; // (62) Numeric keypad 2 key | 57 return VKEY_NUMPAD2; // (62) Numeric keypad 2 key |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 case VKEY_F22: | 614 case VKEY_F22: |
609 case VKEY_F23: | 615 case VKEY_F23: |
610 case VKEY_F24: | 616 case VKEY_F24: |
611 return GDK_F1 + (keycode - VKEY_F1); | 617 return GDK_F1 + (keycode - VKEY_F1); |
612 | 618 |
613 default: | 619 default: |
614 return 0; | 620 return 0; |
615 } | 621 } |
616 } | 622 } |
617 | 623 |
| 624 KeyboardCode KeyboardCodeFromGdkEventKey(GdkEventKey* event) { |
| 625 KeyboardCode keycode = WindowsKeyCodeForGdkKeyCode(event->keyval); |
| 626 #ifdef USE_X11 |
| 627 // Gtk's key values are same as X11's keysyms. |
| 628 if (keycode == VKEY_UNKNOWN) { |
| 629 unsigned int keyval = |
| 630 DefaultXKeysymFromHardwareKeycode(event->hardware_keycode); |
| 631 keycode = WindowsKeyCodeForGdkKeyCode(keyval); |
| 632 } |
| 633 #endif |
| 634 return keycode; |
| 635 } |
| 636 |
618 } // namespace ui | 637 } // namespace ui |
OLD | NEW |