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

Unified Diff: ui/events/keycodes/keyboard_code_conversion_mac.mm

Issue 1943553002: [Mac DomCode] Swap 'IntlBackslash' and 'Backquote' on ISO keyboard (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/keycodes/keyboard_code_conversion_mac.mm
diff --git a/ui/events/keycodes/keyboard_code_conversion_mac.mm b/ui/events/keycodes/keyboard_code_conversion_mac.mm
index 8aae1d92eb41ceab8a36ed93a3dbc8a4debac499..6edba3e01f2655c386bcdf71b7cd6f8e98d0f336 100644
--- a/ui/events/keycodes/keyboard_code_conversion_mac.mm
+++ b/ui/events/keycodes/keyboard_code_conversion_mac.mm
@@ -788,7 +788,25 @@ KeyboardCode KeyboardCodeFromNSEvent(NSEvent* event) {
return KeyboardCodeFromKeyCode([event keyCode]);
}
+int ISOKeyboardKeyCodeMap(int nativeKeyCode) {
+ // OS X will swap 'Backquote' and 'IntlBackslash' if it's an ISO keyboard.
+ // https://crbug.com/600607
+ switch (nativeKeyCode) {
+ case kVK_ISO_Section:
+ return kVK_ANSI_Grave;
+ case kVK_ANSI_Grave:
+ return kVK_ISO_Section;
+ default:
+ return nativeKeyCode;
+ }
+}
+
DomCode DomCodeFromNSEvent(NSEvent* event) {
+ if (KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) {
chongz 2016/05/02 21:33:25 I'm not sure how to test this code, it seems magic
garykac 2016/05/02 22:03:23 For which keyboards does this return kKeyboardISO?
chongz 2016/05/02 22:31:12 It returns |kKeyboardISO| for 1. Apple's ISO Fr C
+ return ui::KeycodeConverter::NativeKeycodeToDomCode(
+ ISOKeyboardKeyCodeMap([event keyCode]));
+ }
+
return ui::KeycodeConverter::NativeKeycodeToDomCode([event keyCode]);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698