Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Side by Side Diff: ui/events/keycodes/keyboard_code_conversion_x.cc

Issue 378503007: Fix some surprising reverse key mappings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix renaming thinko Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 XKeyCodeForWindowsKeyCode(ui::KeyboardCode key_code,
kpschoedel 2014/07/14 18:41:21 Function moved from ui/events/test/events_test_uti
1280 int flags,
1281 XDisplay* display) {
1282 // SHIFT state is ignored in the call to XKeysymForWindowsKeyCode() here
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));
Shu Chen 2014/07/15 04:23:55 XKeysymForWindowsKeyCode() method doesn't consider
kpschoedel 2014/07/15 14:35:05 I agree. Changing the keyboard event rewriting to
Shu Chen 2014/07/15 14:42:12 Got it. I think it's ok for a temporary fix. And y
1303 }
1304
1279 } // namespace ui 1305 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/keycodes/keyboard_code_conversion_x.h ('k') | ui/events/test/events_test_utils_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698