diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 00:53:06 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 00:53:06 +0000 |
commit | 296383bd8221c9d006d6bbc35badf1a434be51fa (patch) | |
tree | 03980ff28e0f28ebf4a9d00762b3784793fe612c | |
parent | c20610d3cba2e3eaeb01927f39cc9cc21dfa1d33 (diff) | |
download | chromium_src-296383bd8221c9d006d6bbc35badf1a434be51fa.zip chromium_src-296383bd8221c9d006d6bbc35badf1a434be51fa.tar.gz chromium_src-296383bd8221c9d006d6bbc35badf1a434be51fa.tar.bz2 |
Let cmd-` switch windows again.
BUG=24817
TEST=Open three windows. Focus web contents. Cmd-` should cycle windows Cmd-shift-` should cycle in the other direction.
Review URL: http://codereview.chromium.org/280005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29229 0039d316-1c4b-4281-b951-d872f2087c98
-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]) |