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

Unified Diff: chrome/browser/cocoa/chrome_event_processing_window.mm

Issue 303002: Make window cycling work even if you change it to something else than cmd-` in sysprefs. (Closed)
Patch Set: Fix spelling. 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
Index: chrome/browser/cocoa/chrome_event_processing_window.mm
diff --git a/chrome/browser/cocoa/chrome_event_processing_window.mm b/chrome/browser/cocoa/chrome_event_processing_window.mm
index 8633c1c2f81bf319863d6838685e02d4bd0d938d..c1b270f68280483923d5223f32265ffaf60d1eb0 100644
--- a/chrome/browser/cocoa/chrome_event_processing_window.mm
+++ b/chrome/browser/cocoa/chrome_event_processing_window.mm
@@ -50,10 +50,30 @@ typedef int (*KeyToCommandMapper)(bool, bool, bool, int);
fromTable:CommandForBrowserKeyboardShortcut];
}
+- (BOOL)shortcircuitEvent:(NSEvent*)event {
+ if (!redispatchingEvent_ &&
+ ([event type] == NSKeyDown || [event type] == NSKeyUp)) {
+ if ([[self firstResponder]
+ isKindOfClass:[RenderWidgetHostViewCocoa class]]) {
+ // No other mac browser sends keyup() for keyboard equivalents, so let's
+ // suppress this.
+ if (([event modifierFlags] & NSCommandKeyMask) && [event type] == NSKeyUp)
+ return YES;
+
+ RenderWidgetHostViewCocoa* rwhv = static_cast<RenderWidgetHostViewCocoa*>(
+ [self firstResponder]);
+ [rwhv keyEvent:event];
+ return YES;
+ }
+ }
+ return NO;
+}
+
- (BOOL)performKeyEquivalent:(NSEvent*)event {
- // We have some magic in |CrApplication sendEvent:| that always sends key
- // events to |RWHVCocoa keyEvent:| so that cocoa doesn't have a chance to
- // intercept it.
+ if (redispatchingEvent_)
+ return NO;
+
+ // |shortcircuitEvent:| should handle all events directed to the RWHV.
DCHECK(![[self firstResponder]
isKindOfClass:[RenderWidgetHostViewCocoa class]]);
@@ -66,5 +86,17 @@ typedef int (*KeyToCommandMapper)(bool, bool, bool, int);
return [super performKeyEquivalent:event];
}
+- (void)redispatchEvent:(NSEvent*)event {
+ DCHECK([event window] == self);
+ redispatchingEvent_ = YES;
+ [NSApp sendEvent:event];
+ redispatchingEvent_ = NO;
+}
+
+- (void)sendEvent:(NSEvent*)event {
+ if (!redispatchingEvent_)
+ [super sendEvent:event];
+}
+
@end // ChromeEventProcessingWindow

Powered by Google App Engine
This is Rietveld 408576698