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 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1269 return XF86XK_KbdBrightnessDown; | 1269 return XF86XK_KbdBrightnessDown; |
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 unsigned int XKeyEventKeyCode(ui::KeyboardCode key_code, | |
1280 int flags, | |
1281 XDisplay* display) { | |
1282 // SHIFT state is ignored in the call to |XKeysymForWindowsKeyCode()| here | |
Daniel Erat
2014/07/07 21:07:01
nit: don't need pipes around function names in com
kpschoedel
2014/07/08 14:40:21
Done. Thanks, I'll follow that in the future.
| |
1283 // because we map the XKeysym back to a keycode, i.e. a physical key position. | |
1284 // Using a SHIFT-modified XKeysym would sometimes yield X keycodes that, | |
1285 // while technically valid, may be surprising in that they do not match | |
1286 // the keycode of the original press, and conflict with assumptions in | |
1287 // other code. | |
1288 // | |
1289 // For example, in a US layout, Shift-9 has the interpretation XK_parenleft, | |
1290 // but the keycode KEY_9 alone does not map to XK_parenleft; instead, | |
1291 // |XKeysymToKeycode()| returns KEY_KPLEFTPAREN (keypad left parenthesis) | |
1292 // which does map to XK_parenleft -- notwithstanding that keyboards with | |
1293 // dedicated number pad parenthesis keys are currently uncommon. | |
1294 // | |
1295 // Similarly, Shift-Comma has the interpretation XK_less, but KEY_COMMA | |
1296 // alone does not map to XK_less; |XKeysymToKeycode()| returns KEY_102ND | |
1297 // (the '<>' key between Shift and Z on 105-key keyboards) which does. | |
1298 // | |
1299 // crbug.com/386066 and crbug.com/390263 are examples of problems | |
1300 // associated with this. | |
1301 // | |
1302 return XKeysymToKeycode(display, XKeysymForWindowsKeyCode(key_code, false)); | |
1303 } | |
1304 | |
1279 } // namespace ui | 1305 } // namespace ui |
OLD | NEW |