| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 5 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #define XK_3270 // for XK_3270_BackTab | 9 #define XK_3270 // for XK_3270_BackTab |
| 10 #include <X11/keysym.h> | 10 #include <X11/keysym.h> |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 // 5. If not found, fallback to find keysym + keysym_shift + hardware_code | 469 // 5. If not found, fallback to find keysym + keysym_shift + hardware_code |
| 470 // in map2. | 470 // in map2. |
| 471 // 6. If not found, fallback to find keysym + keysym_shift + keysym_altgr + | 471 // 6. If not found, fallback to find keysym + keysym_shift + keysym_altgr + |
| 472 // hardware_code in map3. | 472 // hardware_code in map3. |
| 473 // 7. If not found, fallback to find in KeyboardCodeFromXKeysym(), which | 473 // 7. If not found, fallback to find in KeyboardCodeFromXKeysym(), which |
| 474 // mainly for non-letter keys. | 474 // mainly for non-letter keys. |
| 475 // 8. If not found, fallback to find with the hardware code in US layout. | 475 // 8. If not found, fallback to find with the hardware code in US layout. |
| 476 | 476 |
| 477 KeySym keysym = NoSymbol; | 477 KeySym keysym = NoSymbol; |
| 478 XKeyEvent xkey = xev->xkey; | 478 XKeyEvent xkey = xev->xkey; |
| 479 xkey.state &= ~(ShiftMask | Mod1Mask); | 479 xkey.state &= (~0xFF | Mod2Mask); // Clears the xkey's state except numlock. |
| 480 // XLookupKeysym does not take into consideration the state of the lock/shift | 480 // XLookupKeysym does not take into consideration the state of the lock/shift |
| 481 // etc. keys. So it is necessary to use XLookupString instead. | 481 // etc. keys. So it is necessary to use XLookupString instead. |
| 482 XLookupString(&xkey, NULL, 0, &keysym, NULL); | 482 XLookupString(&xkey, NULL, 0, &keysym, NULL); |
| 483 | 483 |
| 484 // [a-z] cases. | 484 // [a-z] cases. |
| 485 if (keysym >= XK_a && keysym <= XK_z) | 485 if (keysym >= XK_a && keysym <= XK_z) |
| 486 return static_cast<KeyboardCode>(VKEY_A + keysym - XK_a); | 486 return static_cast<KeyboardCode>(VKEY_A + keysym - XK_a); |
| 487 | 487 |
| 488 // [0-9] cases. | 488 // [0-9] cases. |
| 489 if (keysym >= XK_0 && keysym <= XK_9) | 489 if (keysym >= XK_0 && keysym <= XK_9) |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 case VKEY_KBD_BRIGHTNESS_UP: | 1270 case VKEY_KBD_BRIGHTNESS_UP: |
| 1271 return XF86XK_KbdBrightnessUp; | 1271 return XF86XK_KbdBrightnessUp; |
| 1272 | 1272 |
| 1273 default: | 1273 default: |
| 1274 LOG(WARNING) << "Unknown keycode:" << keycode; | 1274 LOG(WARNING) << "Unknown keycode:" << keycode; |
| 1275 return 0; | 1275 return 0; |
| 1276 } | 1276 } |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 } // namespace ui | 1279 } // namespace ui |
| OLD | NEW |