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/XF86keysym.h> | 10 #include <X11/XF86keysym.h> |
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 xkeyevent->xkey.time = xievent->time; | 1320 xkeyevent->xkey.time = xievent->time; |
1321 xkeyevent->xkey.x = xievent->event_x; | 1321 xkeyevent->xkey.x = xievent->event_x; |
1322 xkeyevent->xkey.y = xievent->event_y; | 1322 xkeyevent->xkey.y = xievent->event_y; |
1323 xkeyevent->xkey.x_root = xievent->root_x; | 1323 xkeyevent->xkey.x_root = xievent->root_x; |
1324 xkeyevent->xkey.y_root = xievent->root_y; | 1324 xkeyevent->xkey.y_root = xievent->root_y; |
1325 xkeyevent->xkey.state = xievent->mods.effective; | 1325 xkeyevent->xkey.state = xievent->mods.effective; |
1326 xkeyevent->xkey.keycode = xievent->detail; | 1326 xkeyevent->xkey.keycode = xievent->detail; |
1327 xkeyevent->xkey.same_screen = 1; | 1327 xkeyevent->xkey.same_screen = 1; |
1328 } | 1328 } |
1329 | 1329 |
| 1330 unsigned int XKeyCodeForWindowsKeyCode(ui::KeyboardCode key_code, |
| 1331 int flags, |
| 1332 XDisplay* display) { |
| 1333 // SHIFT state is ignored in the call to XKeysymForWindowsKeyCode() here |
| 1334 // because we map the XKeysym back to a keycode, i.e. a physical key position. |
| 1335 // Using a SHIFT-modified XKeysym would sometimes yield X keycodes that, |
| 1336 // while technically valid, may be surprising in that they do not match |
| 1337 // the keycode of the original press, and conflict with assumptions in |
| 1338 // other code. |
| 1339 // |
| 1340 // For example, in a US layout, Shift-9 has the interpretation XK_parenleft, |
| 1341 // but the keycode KEY_9 alone does not map to XK_parenleft; instead, |
| 1342 // XKeysymToKeycode() returns KEY_KPLEFTPAREN (keypad left parenthesis) |
| 1343 // which does map to XK_parenleft -- notwithstanding that keyboards with |
| 1344 // dedicated number pad parenthesis keys are currently uncommon. |
| 1345 // |
| 1346 // Similarly, Shift-Comma has the interpretation XK_less, but KEY_COMMA |
| 1347 // alone does not map to XK_less; XKeysymToKeycode() returns KEY_102ND |
| 1348 // (the '<>' key between Shift and Z on 105-key keyboards) which does. |
| 1349 // |
| 1350 // crbug.com/386066 and crbug.com/390263 are examples of problems |
| 1351 // associated with this. |
| 1352 // |
| 1353 return XKeysymToKeycode(display, XKeysymForWindowsKeyCode(key_code, false)); |
| 1354 } |
| 1355 |
1330 } // namespace ui | 1356 } // namespace ui |
OLD | NEW |