| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" | 5 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 | 8 |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 | 10 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 for (id layout in list) { | 323 for (id layout in list) { |
| 324 TISInputSourceRef ref = (TISInputSourceRef)layout; | 324 TISInputSourceRef ref = (TISInputSourceRef)layout; |
| 325 | 325 |
| 326 NSUInteger keyCode = 0x2e; // "m" on a US layout and most other layouts. | 326 NSUInteger keyCode = 0x2e; // "m" on a US layout and most other layouts. |
| 327 | 327 |
| 328 // On a few layouts, "m" has a different key code. | 328 // On a few layouts, "m" has a different key code. |
| 329 NSString* layoutId = (NSString*)TISGetInputSourceProperty( | 329 NSString* layoutId = (NSString*)TISGetInputSourceProperty( |
| 330 ref, kTISPropertyInputSourceID); | 330 ref, kTISPropertyInputSourceID); |
| 331 if ([layoutId isEqualToString:@"com.apple.keylayout.Belgian"] || | 331 if ([layoutId isEqualToString:@"com.apple.keylayout.Belgian"] || |
| 332 [layoutId isEqualToString:@"com.apple.keylayout.Italian"] || | 332 [layoutId isEqualToString:@"com.apple.keylayout.Italian"] || |
| 333 [layoutId isEqualToString:@"com.apple.keylayout.ABC-AZERTY"] || |
| 333 [layoutId hasPrefix:@"com.apple.keylayout.French"]) { | 334 [layoutId hasPrefix:@"com.apple.keylayout.French"]) { |
| 334 keyCode = 0x29; | 335 keyCode = 0x29; |
| 335 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Turkish"]) { | 336 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Turkish"]) { |
| 336 keyCode = 0x28; | 337 keyCode = 0x28; |
| 337 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Dvorak-Left"]) { | 338 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Dvorak-Left"]) { |
| 338 keyCode = 0x16; | 339 keyCode = 0x16; |
| 339 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Dvorak-Right"]) { | 340 } else if ([layoutId isEqualToString:@"com.apple.keylayout.Dvorak-Right"]) { |
| 340 keyCode = 0x1a; | 341 keyCode = 0x1a; |
| 341 } | 342 } |
| 342 | 343 |
| 343 EventModifiers modifiers = cmdKey >> 8; | 344 EventModifiers modifiers = cmdKey >> 8; |
| 344 NSString* chars = keyCodeToCharacter(keyCode, modifiers, ref); | 345 NSString* chars = keyCodeToCharacter(keyCode, modifiers, ref); |
| 345 NSString* charsIgnoringMods = keyCodeToCharacter(keyCode, 0, ref); | 346 NSString* charsIgnoringMods = keyCodeToCharacter(keyCode, 0, ref); |
| 346 NSEvent* key = KeyEvent(0x100000, chars, charsIgnoringMods, keyCode); | 347 NSEvent* key = KeyEvent(0x100000, chars, charsIgnoringMods, keyCode); |
| 347 ExpectKeyFiresItem(key, item, false); | 348 ExpectKeyFiresItem(key, item, false); |
| 348 } | 349 } |
| 349 CFRelease(list); | 350 CFRelease(list); |
| 350 } | 351 } |
| OLD | NEW |