diff options
Diffstat (limited to 'chrome/browser/ui')
4 files changed, 25 insertions, 49 deletions
diff --git a/chrome/browser/ui/cocoa/notifications/balloon_controller.h b/chrome/browser/ui/cocoa/notifications/balloon_controller.h index 61376b4..fadd35a 100644 --- a/chrome/browser/ui/cocoa/notifications/balloon_controller.h +++ b/chrome/browser/ui/cocoa/notifications/balloon_controller.h @@ -52,9 +52,6 @@ class NotificationOptionsMenuModel; // The host for the renderer of the HTML contents. scoped_ptr<BalloonViewHost> htmlContents_; - - // The psn of the front application process. - ProcessSerialNumber frontProcessNum_; } // Initialize with a balloon object containing the notification data. @@ -86,9 +83,6 @@ class NotificationOptionsMenuModel; // The BalloonHost - (BalloonViewHost*)getHost; - -// Handle the event if it is for the balloon. -- (BOOL)handleEvent:(NSEvent*)event; @end @interface BalloonController (UnitTesting) diff --git a/chrome/browser/ui/cocoa/notifications/balloon_controller.mm b/chrome/browser/ui/cocoa/notifications/balloon_controller.mm index b7daca6f..6fca0a1 100644 --- a/chrome/browser/ui/cocoa/notifications/balloon_controller.mm +++ b/chrome/browser/ui/cocoa/notifications/balloon_controller.mm @@ -113,45 +113,12 @@ const int kRightMargin = 2; assumeInside:NO]; } -- (BOOL)handleEvent:(NSEvent*)event { - BOOL eventHandled = NO; - if ([event type] == NSLeftMouseDown) { - NSPoint mouse = [shelf_ convertPoint:[event locationInWindow] - fromView:nil]; - if (NSPointInRect(mouse, [closeButton_ frame])) { - [closeButton_ mouseDown:event]; - - // Bring back the front process that is deactivated when we click the - // close button. - if (frontProcessNum_.highLongOfPSN || frontProcessNum_.lowLongOfPSN) { - SetFrontProcessWithOptions(&frontProcessNum_, - kSetFrontProcessFrontWindowOnly); - frontProcessNum_.highLongOfPSN = 0; - frontProcessNum_.lowLongOfPSN = 0; - } - - eventHandled = YES; - } else if (NSPointInRect(mouse, [optionsButton_ frame])) { - [optionsButton_ mouseDown:event]; - eventHandled = YES; - } - } - return eventHandled; -} - - (void) mouseEntered:(NSEvent*)event { [[closeButton_ cell] setHighlighted:YES]; - - // Remember the current front process so that we can bring it back later. - if (!frontProcessNum_.highLongOfPSN && !frontProcessNum_.lowLongOfPSN) - GetFrontProcess(&frontProcessNum_); } - (void) mouseExited:(NSEvent*)event { [[closeButton_ cell] setHighlighted:NO]; - - frontProcessNum_.highLongOfPSN = 0; - frontProcessNum_.lowLongOfPSN = 0; } - (IBAction)optionsButtonPressed:(id)sender { diff --git a/chrome/browser/ui/cocoa/notifications/balloon_view.h b/chrome/browser/ui/cocoa/notifications/balloon_view.h index b742eaf..916bcec 100644 --- a/chrome/browser/ui/cocoa/notifications/balloon_view.h +++ b/chrome/browser/ui/cocoa/notifications/balloon_view.h @@ -24,5 +24,12 @@ } @end +// This view overlays the notification balloon on top. It is used to intercept +// mouse input to prevent reordering of the other browser windows when clicking +// on the notification balloon. +@interface BalloonOverlayViewCocoa : NSView { +} +@end + #endif // CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_BALLOON_VIEW_H_ diff --git a/chrome/browser/ui/cocoa/notifications/balloon_view.mm b/chrome/browser/ui/cocoa/notifications/balloon_view.mm index e88331a..aa78be6 100644 --- a/chrome/browser/ui/cocoa/notifications/balloon_view.mm +++ b/chrome/browser/ui/cocoa/notifications/balloon_view.mm @@ -37,16 +37,6 @@ const int kRoundedCornerSize = 6; - (BOOL)canBecomeMainWindow { return NO; } - -- (void)sendEvent:(NSEvent*)event { - // We do not want to bring chrome window to foreground when we click on close - // or option button. To do this, we have to intercept the event. - BalloonController* delegate = - static_cast<BalloonController*>([self delegate]); - if (![delegate handleEvent:event]) { - [super sendEvent:event]; - } -} @end @implementation BalloonShelfViewCocoa @@ -82,3 +72,21 @@ const int kRoundedCornerSize = 6; [path stroke]; } @end + +@implementation BalloonOverlayViewCocoa + +// We do not want to bring chrome window to foreground when we click on any +// part of the notification balloon. To do this, we first postpone the window +// reorder here (shouldDelayWindowOrderingForEvent is called during mouseDown) +// and then complete canceling the reorder by [NSApp preventWindowOrdering] in +// mouseDown handler of this view. +- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent*)theEvent { + return YES; +} + +- (void)mouseDown:(NSEvent*)event { + [NSApp preventWindowOrdering]; + // Continue bubbling the event up the chain of responders. + [super mouseDown:event]; +} +@end |