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

Issue 357613002: Gets correct KeyboardCode from XEvent for non-US layouts. (Closed)

Created:
6 years, 6 months ago by Shu Chen
Modified:
6 years, 5 months ago
Reviewers:
sadrul, garykac
CC:
chromium-reviews, tdresser+watch_chromium.org, James Su, Yuki, garykac
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Gets correct KeyboardCode from XEvent for non-US layouts. Originally KeyboardCodeFromXKeyEvent() doesn't support non-US keyboard layouts. It directly does 1-1 mapping from keysym to VKEY. To make it support non-US keyboard, this cl uses the generated maps: - ch0: vk - ch0+sc: vk - ch0+sc+ch1: vk - ch0+sc+ch1+ch2: vk The maps data is from Windows keyboard DLLs. BUG=386066 TEST=Verified on Pixel device. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=281395

Patch Set 1 #

Patch Set 2 : changed DefaultXKeysymFromHardwareKeycode to DefaultKeyboardCodeFromHardwareKeycode. #

Patch Set 3 : fixed test failures due to unsorted MAP1. #

Total comments: 6

Patch Set 4 : nits per comments. #

Patch Set 5 : fixed unit_tests failures. #

Patch Set 6 : #

Patch Set 7 : considering perf, only find in maps when keysym is not function/cursor/modifier/etc. key. #

Patch Set 8 : updated the maps data, and make sure 2-bytes keysym to lookup in maps. #

Patch Set 9 : fixed bugs in generator scripts and updated the maps data. #

Patch Set 10 : #

Total comments: 26

Patch Set 11 : reviseded per comments. #

Patch Set 12 : map KEY_RO to VKEY_OEM_102. #

Patch Set 13 : #

Total comments: 1

Patch Set 14 : Fallback to find with (ch0+sc+ch1) if (ch0+sc+ch1+ch2) is not found in map3. #

Total comments: 4

Patch Set 15 : git cl format #

Unified diffs Side-by-side diffs Delta from patch set Stats (+671 lines, -272 lines) Patch
M ui/events/keycodes/keyboard_code_conversion_x.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +3 lines, -3 lines 0 comments Download
M ui/events/keycodes/keyboard_code_conversion_x.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 4 chunks +663 lines, -263 lines 0 comments Download
M ui/events/test/events_test_utils_x11.cc View 1 2 3 12 1 chunk +5 lines, -6 lines 0 comments Download

Messages

Total messages: 20 (0 generated)
Shu Chen
Can you please help review this cl? Thanks Please let me know if you have ...
6 years, 6 months ago (2014-06-25 14:13:23 UTC) #1
sadrul
The try failures look related. Mind taking a look at those? On 2014/06/25 14:13:23, Shu ...
6 years, 6 months ago (2014-06-25 22:35:34 UTC) #2
Wez
Why are we expending effort on trying to patch up our generation of VKEY codes, ...
6 years, 6 months ago (2014-06-26 02:10:43 UTC) #3
Shu Chen
The reasons to get correct VKEY code: 1) many web apps are using KeyboardEvent.keyCode instead ...
6 years, 6 months ago (2014-06-26 06:55:40 UTC) #4
Shu Chen
I've made test green. Can you please take another look? Thanks On 2014/06/25 22:35:34, sadrul ...
6 years, 6 months ago (2014-06-26 16:00:20 UTC) #5
Wez
Handing off to Gary to review this one.
6 years, 6 months ago (2014-06-26 20:24:57 UTC) #6
Shu Chen
Hi Gary, can you please take a look at this cl? Thanks To Sadrul, the ...
6 years, 6 months ago (2014-06-27 02:49:11 UTC) #7
garykac
https://codereview.chromium.org/357613002/diff/160001/ui/events/keycodes/keyboard_code_conversion_x.cc File ui/events/keycodes/keyboard_code_conversion_x.cc (left): https://codereview.chromium.org/357613002/diff/160001/ui/events/keycodes/keyboard_code_conversion_x.cc#oldcode25 ui/events/keycodes/keyboard_code_conversion_x.cc:25: // etc. keys. So it is necessary to use ...
6 years, 5 months ago (2014-07-01 00:07:43 UTC) #8
Shu Chen
https://codereview.chromium.org/357613002/diff/160001/ui/events/keycodes/keyboard_code_conversion_x.cc File ui/events/keycodes/keyboard_code_conversion_x.cc (left): https://codereview.chromium.org/357613002/diff/160001/ui/events/keycodes/keyboard_code_conversion_x.cc#oldcode25 ui/events/keycodes/keyboard_code_conversion_x.cc:25: // etc. keys. So it is necessary to use ...
6 years, 5 months ago (2014-07-01 17:14:34 UTC) #9
garykac
lgtm This seems fine, but it's hard to verify that all the mappings are correct. ...
6 years, 5 months ago (2014-07-02 23:45:31 UTC) #10
Shu Chen
The KeyboardCodeFromXKeyEvent methods uses XLookupString. Do you know a feasible way to change different XKB ...
6 years, 5 months ago (2014-07-04 02:10:37 UTC) #11
Shu Chen
sadrul@, do you have comments on this cl? Your lgtm is required for changes in ...
6 years, 5 months ago (2014-07-04 04:02:23 UTC) #12
sadrul
On 2014/06/27 02:49:11, Shu Chen wrote: > Hi Gary, can you please take a look ...
6 years, 5 months ago (2014-07-04 05:58:39 UTC) #13
Shu Chen
On 2014/07/04 05:58:39, sadrul wrote: > On 2014/06/27 02:49:11, Shu Chen wrote: > > Hi ...
6 years, 5 months ago (2014-07-04 08:17:05 UTC) #14
Shu Chen
https://codereview.chromium.org/357613002/diff/230001/ui/events/keycodes/keyboard_code_conversion_x.cc File ui/events/keycodes/keyboard_code_conversion_x.cc (right): https://codereview.chromium.org/357613002/diff/230001/ui/events/keycodes/keyboard_code_conversion_x.cc#newcode400 ui/events/keycodes/keyboard_code_conversion_x.cc:400: {0x03F9, 0x2F, 0x03D9, 0x01DE, 0xBA}, // XK_uogonek+AC10+XK_Uogonek+XK_Tcedilla: VKEY_OEM_1 On ...
6 years, 5 months ago (2014-07-04 09:49:44 UTC) #15
Shu Chen
The CQ bit was checked by shuchen@chromium.org
6 years, 5 months ago (2014-07-04 09:49:56 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/shuchen@chromium.org/357613002/250001
6 years, 5 months ago (2014-07-04 09:50:51 UTC) #17
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: ios_rel_device on tryserver.chromium ...
6 years, 5 months ago (2014-07-04 11:43:08 UTC) #18
commit-bot: I haz the power
Change committed as 281395
6 years, 5 months ago (2014-07-04 11:48:53 UTC) #19
Alexis Menard (Chromium)
6 years, 5 months ago (2014-07-16 16:39:31 UTC) #20
Message was sent while issue was closed.
On 2014/07/04 11:48:53, I haz the power (commit-bot) wrote:
> Change committed as 281395

This broke the build on my 64 bits Archlinux with GCC 4.8 : 

../../ui/events/keycodes/keyboard_code_conversion_x.cc: In function
‘ui::KeyboardCode ui::KeyboardCodeFromXKeyEvent(XEvent*)’:
../../ui/events/keycodes/keyboard_code_conversion_x.cc:497:25: error: narrowing
conversion of ‘(keysym & 65535ul)’ from ‘KeySym {aka long unsigned int}’ to
‘uint16 {aka short unsigned int}’ inside { } is ill-formed in C++11
[-Werror=narrowing]
     MAP0 key0 = {keysym & 0xFFFF, 0};
                         ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:502:25: error: narrowing
conversion of ‘(keysym & 65535ul)’ from ‘KeySym {aka long unsigned int}’ to
‘uint16 {aka short unsigned int}’ inside { } is ill-formed in C++11
[-Werror=narrowing]
     MAP1 key1 = {keysym & 0xFFFF, xkey.keycode, 0};
                         ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:502:50: error: narrowing
conversion of ‘xkey.XKeyEvent::keycode’ from ‘unsigned int’ to ‘uint8 {aka
unsigned char}’ inside { } is ill-formed in C++11 [-Werror=narrowing]
     MAP1 key1 = {keysym & 0xFFFF, xkey.keycode, 0};
                                                  ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:510:25: error: narrowing
conversion of ‘(keysym & 65535ul)’ from ‘KeySym {aka long unsigned int}’ to
‘uint16 {aka short unsigned int}’ inside { } is ill-formed in C++11
[-Werror=narrowing]
     MAP2 key2 = {keysym & 0xFFFF, xkey.keycode, keysym_shift & 0xFFFF, 0};
                         ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:510:73: error: narrowing
conversion of ‘xkey.XKeyEvent::keycode’ from ‘unsigned int’ to ‘uint8 {aka
unsigned char}’ inside { } is ill-formed in C++11 [-Werror=narrowing]
     MAP2 key2 = {keysym & 0xFFFF, xkey.keycode, keysym_shift & 0xFFFF, 0};
                                                                         ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:510:62: error: narrowing
conversion of ‘(keysym_shift & 65535ul)’ from ‘KeySym {aka long unsigned int}’
to ‘uint16 {aka short unsigned int}’ inside { } is ill-formed in C++11
[-Werror=narrowing]
     MAP2 key2 = {keysym & 0xFFFF, xkey.keycode, keysym_shift & 0xFFFF, 0};
                                                              ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:519:25: error: narrowing
conversion of ‘(keysym & 65535ul)’ from ‘KeySym {aka long unsigned int}’ to
‘uint16 {aka short unsigned int}’ inside { } is ill-formed in C++11
[-Werror=narrowing]
     MAP3 key3 = {keysym & 0xFFFF, xkey.keycode, keysym_shift & 0xFFFF,
                         ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:520:42: error: narrowing
conversion of ‘xkey.XKeyEvent::keycode’ from ‘unsigned int’ to ‘uint8 {aka
unsigned char}’ inside { } is ill-formed in C++11 [-Werror=narrowing]
                  keysym_altgr & 0xFFFF, 0};
                                          ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:519:62: error: narrowing
conversion of ‘(keysym_shift & 65535ul)’ from ‘KeySym {aka long unsigned int}’
to ‘uint16 {aka short unsigned int}’ inside { } is ill-formed in C++11
[-Werror=narrowing]
     MAP3 key3 = {keysym & 0xFFFF, xkey.keycode, keysym_shift & 0xFFFF,
                                                              ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:520:31: error: narrowing
conversion of ‘(keysym_altgr & 65535ul)’ from ‘KeySym {aka long unsigned int}’
to ‘uint16 {aka short unsigned int}’ inside { } is ill-formed in C++11
[-Werror=narrowing]
                  keysym_altgr & 0xFFFF, 0};
                               ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:528:25: error: narrowing
conversion of ‘(keysym & 65535ul)’ from ‘KeySym {aka long unsigned int}’ to
‘uint16 {aka short unsigned int}’ inside { } is ill-formed in C++11
[-Werror=narrowing]
     MAP3 key4 = {keysym & 0xFFFF, xkey.keycode, keysym_shift & 0xFFFF, 0xFFFF,
                         ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:529:19: error: narrowing
conversion of ‘xkey.XKeyEvent::keycode’ from ‘unsigned int’ to ‘uint8 {aka
unsigned char}’ inside { } is ill-formed in C++11 [-Werror=narrowing]
                  0};
                   ^
../../ui/events/keycodes/keyboard_code_conversion_x.cc:528:62: error: narrowing
conversion of ‘(keysym_shift & 65535ul)’ from ‘KeySym {aka long unsigned int}’
to ‘uint16 {aka short unsigned int}’ inside { } is ill-formed in C++11
[-Werror=narrowing]
     MAP3 key4 = {keysym & 0xFFFF, xkey.keycode, keysym_shift & 0xFFFF, 0xFFFF,
                                                              ^
cc1plus: all warnings being treated as errors

Powered by Google App Engine
This is Rietveld 408576698