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

Unified Diff: chrome/browser/tab_contents/tab_contents_view_mac.mm

Issue 280005: Let cmd-` switch windows again. (Closed)
Patch Set: Created 11 years, 2 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: chrome/browser/tab_contents/tab_contents_view_mac.mm
diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm
index 61195b1a72f8e49ce8341f5ebc75258fed1ad144..21b4970b4edb7b127ba1a3a4032d5cdaf0284a9f 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;
James Su 2009/10/15 08:00:49 Is it ok for us to depend on a private method? It
Nico 2009/10/15 15:40:00 I think it's ok for often-used stuff as long as we
+@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|.
James Su 2009/10/15 08:00:49 Is Cmd-` the only key handled by |NSApp sendEvent|
Nico 2009/10/15 15:40:00 Experimental evidence suggests that it really is t
+ 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])
« 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