diff options
author | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-27 05:20:14 +0000 |
---|---|---|
committer | dimich@chromium.org <dimich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-27 05:20:14 +0000 |
commit | 8aad1f6c0123dc2bc018c5500d265d2da998210e (patch) | |
tree | 6ccec2c98c6432e66e18c152169cf711c486c82e | |
parent | 1dfa83b6272e7f2bb60a6181c7eda23baab33a7f (diff) | |
download | chromium_src-8aad1f6c0123dc2bc018c5500d265d2da998210e.zip chromium_src-8aad1f6c0123dc2bc018c5500d265d2da998210e.tar.gz chromium_src-8aad1f6c0123dc2bc018c5500d265d2da998210e.tar.bz2 |
Make Mac panels to activate on mousedown in detached mode.
This is to make behavior of detached panels more in line with user expectations on a free-floating windows. It also prevents the drag of non-activated panels across other windows, with a panel getting behind of it and invisible.
XIB change is to change the type of overlay view on top of the Titlebar.
BUG=120340
Review URL: https://chromiumcodereview.appspot.com/9836101
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129142 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/nibs/Panel.xib | 77 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_titlebar_view_cocoa.h | 10 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm | 25 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_window_controller_cocoa.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_window_controller_cocoa.mm | 7 |
5 files changed, 83 insertions, 41 deletions
diff --git a/chrome/app/nibs/Panel.xib b/chrome/app/nibs/Panel.xib index 829e3c9..e484904 100644 --- a/chrome/app/nibs/Panel.xib +++ b/chrome/app/nibs/Panel.xib @@ -3,12 +3,12 @@ <data> <int key="IBDocument.SystemTarget">1050</int> <string key="IBDocument.SystemVersion">10K549</string> - <string key="IBDocument.InterfaceBuilderVersion">804</string> + <string key="IBDocument.InterfaceBuilderVersion">851</string> <string key="IBDocument.AppKitVersion">1038.36</string> <string key="IBDocument.HIToolboxVersion">461.00</string> <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> - <string key="NS.object.0">804</string> + <string key="NS.object.0">851</string> </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -67,7 +67,7 @@ <int key="NSvFlags">274</int> <string key="NSFrame">{{0, -36}, {319, 96}}</string> <reference key="NSSuperview" ref="304499912"/> - <string key="NSClassName">BalloonOverlayViewCocoa</string> + <string key="NSClassName">PanelTitlebarOverlayView</string> </object> <object class="NSCustomView" id="892753116"> <reference key="NSNextResponder" ref="304499912"/> @@ -271,6 +271,14 @@ </object> <int key="connectionID">25</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">controller_</string> + <reference key="source" ref="438255290"/> + <reference key="destination" ref="1001"/> + </object> + <int key="connectionID">27</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -455,36 +463,12 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">25</int> + <int key="maxID">27</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBPartialClassDescription"> - <string key="className">BalloonOverlayViewCocoa</string> - <string key="superclassName">NSView</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/ui/cocoa/notifications/balloon_view.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">ChromeBrowserWindow</string> - <string key="superclassName">ChromeEventProcessingWindow</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/ui/cocoa/chrome_browser_window.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">ChromeEventProcessingWindow</string> - <string key="superclassName">NSWindow</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/ui/cocoa/chrome_event_processing_window.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> <string key="className">FirstResponder</string> <string key="superclassName">NSObject</string> <object class="NSMutableDictionary" key="actions"> @@ -576,6 +560,25 @@ </object> </object> <object class="IBPartialClassDescription"> + <string key="className">PanelTitlebarOverlayView</string> + <string key="superclassName">NSView</string> + <object class="NSMutableDictionary" key="outlets"> + <string key="NS.key.0">controller_</string> + <string key="NS.object.0">PanelWindowControllerCocoa</string> + </object> + <object class="NSMutableDictionary" key="toOneOutletInfosByName"> + <string key="NS.key.0">controller_</string> + <object class="IBToOneOutletInfo" key="NS.object.0"> + <string key="name">controller_</string> + <string key="candidateClassName">PanelWindowControllerCocoa</string> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="501324801"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/ui/panels/panel_titlebar_view_cocoa.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">PanelTitlebarViewCocoa</string> <string key="superclassName">NSView</string> <object class="NSMutableDictionary" key="actions"> @@ -670,18 +673,7 @@ </object> </object> </object> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/ui/panels/panel_titlebar_view_cocoa.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">PanelWindowCocoaImpl</string> - <string key="superclassName">ChromeBrowserWindow</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="113923837"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/ui/panels/panel_window_controller_cocoa.h</string> - </object> + <reference key="sourceIdentifier" ref="501324801"/> </object> <object class="IBPartialClassDescription"> <string key="className">PanelWindowControllerCocoa</string> @@ -697,7 +689,10 @@ <string key="candidateClassName">PanelTitlebarViewCocoa</string> </object> </object> - <reference key="sourceIdentifier" ref="113923837"/> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/ui/panels/panel_window_controller_cocoa.h</string> + </object> </object> <object class="IBPartialClassDescription"> <string key="className">PanelWindowControllerCocoa</string> diff --git a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h index d8c9576..82e75e2 100644 --- a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h +++ b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h @@ -33,6 +33,16 @@ enum PanelDragState { PANEL_DRAG_SUPPRESSED // Ignore drag events until PANEL_DRAG_CAN_START. }; +// This view overlays the titlebar on top. It is used to intercept +// mouse input to prevent reordering of the other browser windows when clicking +// on the titlebar (to minimize or reorder) while in a docked strip. +@interface PanelTitlebarOverlayView : NSView { + @private + IBOutlet PanelWindowControllerCocoa* controller_; + BOOL disableReordering_; +} +@end + @interface RepaintAnimation : NSAnimation { @private NSView* targetView_; diff --git a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm index ca3a89f..54828a9 100644 --- a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm +++ b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm @@ -55,6 +55,31 @@ static NSEvent* MakeMouseEvent(NSEventType type, pressure:0.0]; } +@implementation PanelTitlebarOverlayView +// Sometimes we do not want to bring chrome window to foreground when we click +// on any part of the titlebar. To do this, we first postpone the window +// reorder here (shouldDelayWindowOrderingForEvent is called during when mouse +// button is pressed but before mouseDown: is dispatched) and then complete +// canceling the reorder by [NSApp preventWindowOrdering] in mouseDown handler +// of this view. +- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent*)theEvent { + disableReordering_ = ![controller_ IsActivationByClickingTitlebarEnabled]; + return disableReordering_; +} + +- (void)mouseDown:(NSEvent*)event { + if (disableReordering_) + [NSApp preventWindowOrdering]; + disableReordering_ = NO; + // Continue bubbling the event up the chain of responders. + [super mouseDown:event]; +} + +- (BOOL)acceptsFirstMouse:(NSEvent*)event { + return YES; +} +@end + @implementation RepaintAnimation - (id)initWithView:(NSView*)targetView duration:(double) duration { if (![super initWithDuration:duration animationCurve:NSAnimationEaseInOut]) diff --git a/chrome/browser/ui/panels/panel_window_controller_cocoa.h b/chrome/browser/ui/panels/panel_window_controller_cocoa.h index a33f9e3..e528400 100644 --- a/chrome/browser/ui/panels/panel_window_controller_cocoa.h +++ b/chrome/browser/ui/panels/panel_window_controller_cocoa.h @@ -143,6 +143,11 @@ class PanelBrowserWindowCocoa; // Turns on user-resizable corners/sides indications and enables live resize. - (void)enableResizeByMouse:(BOOL)enable; + +// In certain cases (when in a Docked strip for example) we want +// the standard behavior of activating the app when clicking on the titlebar +// to be disabled. This way, user can minimize the panel w/o activating it. +- (BOOL)IsActivationByClickingTitlebarEnabled; @end // @interface PanelWindowController #endif // CHROME_BROWSER_UI_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ diff --git a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm index c39a28d..051416d 100644 --- a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm +++ b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm @@ -1076,4 +1076,11 @@ enum { [[self window] invalidateCursorRectsForView:overlayView_]; } +- (BOOL)IsActivationByClickingTitlebarEnabled { + PanelStrip* panelStrip = windowShim_->panel()->panel_strip(); + if (!panelStrip) + return NO; // Unlikely user-clickable at this moment. + return panelStrip->type() == PanelStrip::DETACHED; +} + @end |