diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_mac.mm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index 61195b1..21b4970 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#import <Carbon/Carbon.h> + #include "chrome/browser/tab_contents/tab_contents_view_mac.h" #include <string> @@ -259,6 +261,10 @@ void TabContentsViewMac::Observe(NotificationType type, } } +@interface NSApplication(SPI) +- (void)_cycleWindowsReversed:(BOOL)reversed; +@end + @implementation TabContentsViewCocoa - (id)initWithTabContentsViewMac:(TabContentsViewMac*)w { @@ -303,6 +309,25 @@ void TabContentsViewMac::Observe(NotificationType type, return; } + // Cmd-` is not in the menu and it's apparently handled by |NSApp sendEvent| + // if the application doesn't swallow it. We do, so we need to handle this + // key ourself. On foreign keyboards, the "switch windows" key is not the + // ` key, so do this by keycode instead of |event characters|. + if ([event type] == NSKeyDown && + [event keyCode] == kVK_ANSI_Grave && + [NSApp respondsToSelector:@selector(_cycleWindowsReversed:)]) { + const NSUInteger kModifierMask = NSShiftKeyMask | + NSControlKeyMask | + NSAlternateKeyMask | + NSCommandKeyMask; + if (([event modifierFlags] & kModifierMask) == NSCommandKeyMask) + [NSApp _cycleWindowsReversed:NO]; + else if (([event modifierFlags] & kModifierMask) == + (NSCommandKeyMask | NSShiftKeyMask) && + [NSApp respondsToSelector:@selector(_cycleWindowsReversed:)]) + [NSApp _cycleWindowsReversed:YES]; + } + // If this tab is no longer active, it's window will be |nil|. In that case, // best ignore the event. if (![self window]) |