Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_window_controller_cocoa.mm |
| diff --git a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm |
| index 4acf8259e7146d0876ef8f4c3f69416fe6821f53..04d61204890a5e654e904523e6b3fbf550c70aa3 100644 |
| --- a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm |
| +++ b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm |
| @@ -6,7 +6,6 @@ |
| #import <Cocoa/Cocoa.h> |
| -#include "base/auto_reset.h" |
| #include "base/logging.h" |
| #include "base/mac/bundle_locations.h" |
| #include "base/mac/mac_util.h" |
| @@ -84,12 +83,21 @@ enum { |
| } |
| // Prevent panel window from becoming key - for example when it is minimized. |
| +// Panel windows use a higher priority NSWindowLevel to ensure they are always |
| +// visible, causing the OS to prefer panel windows when selecting a window |
| +// to make the key window. To counter this preference, we override |
| +// -[NSWindow:canBecomeKeyWindow] to restrict when the panel can become the |
| +// key window to a limited set of scenarios, such as when cycling through |
| +// windows, when panels are the only remaining windows, when an event |
| +// triggers window activation, etc. The panel may also be prevented from |
| +// becoming the key window, regardless of the above scenarios, such as when |
| +// a panel is minimized. |
| - (BOOL)canBecomeKeyWindow { |
| // Give precedence to controller preventing activation of the window. |
| PanelWindowControllerCocoa* controller = |
| base::mac::ObjCCast<PanelWindowControllerCocoa>([self windowController]); |
| if (![controller canBecomeKeyWindow]) |
| - return false; |
| + return NO; |
| BrowserCrApplication* app = base::mac::ObjCCast<BrowserCrApplication>( |
| [BrowserCrApplication sharedApplication]); |
| @@ -97,18 +105,12 @@ enum { |
| // A Panel window can become the key window only in limited scenarios. |
| // This prevents the system from always preferring a Panel window due |
| // to its higher priority NSWindowLevel when selecting a window to make key. |
| - return canBecomeKey_ || |
| + return ([app isHandlingSendEvent] && [[app currentEvent] window] == self) || |
|
jennb
2012/04/24 18:47:15
FYI: this change is the fix needed to prevent tabb
|
| [controller activationRequestedByBrowser] || |
| [app isCyclingWindows] || |
| [app previousKeyWindow] == self || |
| [[app windows] count] == static_cast<NSUInteger>([controller numPanels]); |
| } |
| - |
| -- (void)sendEvent:(NSEvent*)anEvent { |
| - // Allow the panel to become key in response to a mouse click. |
| - AutoReset<BOOL> pin(&canBecomeKey_, YES); |
| - [super sendEvent:anEvent]; |
| -} |
| @end |
| // Transparent view covering the whole panel in order to intercept mouse |
| @@ -858,29 +860,8 @@ enum { |
| - (void)onTitlebarMouseClicked:(int)modifierFlags { |
| Panel* panel = windowShim_->panel(); |
| - if (modifierFlags & NSShiftKeyMask) { |
| - panel->OnTitlebarClicked(panel::APPLY_TO_ALL); |
| - return; |
| - } |
| - |
| - // TODO(jennb): Move remaining titlebar click handling out of here. |
| - // (http://crbug.com/118431) |
| - PanelStrip* panelStrip = panel->panel_strip(); |
| - if (!panelStrip) |
| - return; |
| - if (panelStrip->type() == PanelStrip::DOCKED && |
| - panel->expansion_state() == Panel::EXPANDED) { |
| - if ([[self titlebarView] isDrawingAttention]) { |
| - // Do not minimize if the Panel is drawing attention since user |
| - // most likely simply wants to reset the 'draw attention' status. |
| - panel->Activate(); |
| - return; |
| - } |
| - panel->SetExpansionState(Panel::MINIMIZED); |
| - // The Panel class ensures deactivation when it is minimized. |
| - } else { |
| - panel->Activate(); |
| - } |
| + panel->OnTitlebarClicked((modifierFlags & NSShiftKeyMask) ? |
| + panel::APPLY_TO_ALL : panel::NO_MODIFIER); |
| } |
| - (int)titlebarHeightInScreenCoordinates { |
| @@ -913,18 +894,7 @@ enum { |
| rwhv->SetActive(true); |
| } |
| - // If the window becomes key, lets make sure it is expanded and stop |
| - // drawing attention - since it is ready to accept input, it already has |
| - // user's attention. |
| - if ([[self titlebarView] isDrawingAttention]) { |
| - [[self titlebarView] stopDrawingAttention]; |
| - } |
| - |
| - content::NotificationService::current()->Notify( |
| - chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, |
| - content::Source<Panel>(windowShim_->panel()), |
| - content::NotificationService::NoDetails()); |
| - windowShim_->panel()->OnActiveStateChanged(); |
| + windowShim_->panel()->OnActiveStateChanged(true); |
| } |
| - (void)windowDidResignKey:(NSNotification*)notification { |
| @@ -943,11 +913,7 @@ enum { |
| rwhv->SetActive(false); |
| } |
| - content::NotificationService::current()->Notify( |
| - chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, |
| - content::Source<Panel>(windowShim_->panel()), |
| - content::NotificationService::NoDetails()); |
| - windowShim_->panel()->OnActiveStateChanged(); |
| + windowShim_->panel()->OnActiveStateChanged(false); |
| } |
| - (void)deactivate { |
| @@ -1034,8 +1000,4 @@ enum { |
| [[self window] invalidateCursorRectsForView:overlayView_]; |
| } |
| -- (BOOL)isActivationByClickingTitlebarEnabled { |
| - return !windowShim_->panel()->always_on_top(); |
| -} |
| - |
| @end |