OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h" |
6 | 6 |
7 #import "base/mac/mac_util.h" | 7 #import "base/mac/mac_util.h" |
8 #include "base/mac/scoped_cftyperef.h" | 8 #include "base/mac/scoped_cftyperef.h" |
9 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" | 9 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" |
10 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" | 10 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" |
11 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 11 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
12 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" | 12 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" |
13 | 13 |
| 14 // Provide the forward-declarations of new 10.7 SDK symbols so they can be |
| 15 // called when building with the 10.5 SDK. |
| 16 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
| 17 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
| 18 |
| 19 enum { |
| 20 NSWindowAnimationBehaviorDefault = 0, |
| 21 NSWindowAnimationBehaviorNone = 2, |
| 22 NSWindowAnimationBehaviorDocumentWindow = 3, |
| 23 NSWindowAnimationBehaviorUtilityWindow = 4, |
| 24 NSWindowAnimationBehaviorAlertPanel = 5 |
| 25 }; |
| 26 typedef NSInteger NSWindowAnimationBehavior; |
| 27 |
| 28 @interface NSWindow (LionSDKDeclarations) |
| 29 - (NSWindowAnimationBehavior)animationBehavior; |
| 30 - (void)setAnimationBehavior:(NSWindowAnimationBehavior)newAnimationBehavior; |
| 31 @end |
| 32 |
| 33 #endif // MAC_OS_X_VERSION_10_7 |
| 34 |
14 const CGFloat kTearDistance = 36.0; | 35 const CGFloat kTearDistance = 36.0; |
15 const NSTimeInterval kTearDuration = 0.333; | 36 const NSTimeInterval kTearDuration = 0.333; |
16 | 37 |
17 @interface TabStripDragController (Private) | 38 @interface TabStripDragController (Private) |
18 - (void)resetDragControllers; | 39 - (void)resetDragControllers; |
19 - (NSArray*)dropTargetsForController:(TabWindowController*)dragController; | 40 - (NSArray*)dropTargetsForController:(TabWindowController*)dragController; |
20 - (void)setWindowBackgroundVisibility:(BOOL)shouldBeVisible; | 41 - (void)setWindowBackgroundVisibility:(BOOL)shouldBeVisible; |
21 // TODO(davidben): When we stop supporting 10.5, this can be removed. | 42 // TODO(davidben): When we stop supporting 10.5, this can be removed. |
22 - (int)getWorkspaceID:(NSWindow*)window useCache:(BOOL)useCache; | 43 - (int)getWorkspaceID:(NSWindow*)window useCache:(BOOL)useCache; |
23 @end | 44 @end |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // controller. | 256 // controller. |
236 draggedController_ = | 257 draggedController_ = |
237 [sourceController_ detachTabToNewWindow:[draggedTab_ tabView]]; | 258 [sourceController_ detachTabToNewWindow:[draggedTab_ tabView]]; |
238 dragWindow_ = [draggedController_ window]; | 259 dragWindow_ = [draggedController_ window]; |
239 [dragWindow_ setAlphaValue:0.0]; | 260 [dragWindow_ setAlphaValue:0.0]; |
240 if (![sourceController_ hasLiveTabs]) { | 261 if (![sourceController_ hasLiveTabs]) { |
241 sourceController_ = draggedController_; | 262 sourceController_ = draggedController_; |
242 sourceWindow_ = dragWindow_; | 263 sourceWindow_ = dragWindow_; |
243 } | 264 } |
244 | 265 |
| 266 // Disable window animation before calling |orderFront:| when detatching |
| 267 // to a new window. |
| 268 NSWindowAnimationBehavior savedAnimationBehavior = 0; |
| 269 if ([dragWindow_ respondsToSelector:@selector(animationBehavior)] && |
| 270 [dragWindow_ respondsToSelector:@selector(setAnimationBehavior:)]) { |
| 271 savedAnimationBehavior = [dragWindow_ animationBehavior]; |
| 272 [dragWindow_ setAnimationBehavior:NSWindowAnimationBehaviorNone]; |
| 273 } |
| 274 |
245 // If dragging the tab only moves the current window, do not show overlay | 275 // If dragging the tab only moves the current window, do not show overlay |
246 // so that sheets stay on top of the window. | 276 // so that sheets stay on top of the window. |
247 // Bring the target window to the front and make sure it has a border. | 277 // Bring the target window to the front and make sure it has a border. |
248 [dragWindow_ setLevel:NSFloatingWindowLevel]; | 278 [dragWindow_ setLevel:NSFloatingWindowLevel]; |
249 [dragWindow_ setHasShadow:YES]; | 279 [dragWindow_ setHasShadow:YES]; |
250 [dragWindow_ orderFront:nil]; | 280 [dragWindow_ orderFront:nil]; |
251 [dragWindow_ makeMainWindow]; | 281 [dragWindow_ makeMainWindow]; |
252 [draggedController_ showOverlay]; | 282 [draggedController_ showOverlay]; |
253 dragOverlay_ = [draggedController_ overlayWindow]; | 283 dragOverlay_ = [draggedController_ overlayWindow]; |
254 // Force the new tab button to be hidden. We'll reset it on mouse up. | 284 // Force the new tab button to be hidden. We'll reset it on mouse up. |
255 [draggedController_ showNewTabButton:NO]; | 285 [draggedController_ showNewTabButton:NO]; |
256 tearTime_ = [NSDate timeIntervalSinceReferenceDate]; | 286 tearTime_ = [NSDate timeIntervalSinceReferenceDate]; |
257 tearOrigin_ = sourceWindowFrame_.origin; | 287 tearOrigin_ = sourceWindowFrame_.origin; |
| 288 |
| 289 // Restore window animation behavior |
| 290 if ([dragWindow_ respondsToSelector:@selector(animationBehavior)] && |
| 291 [dragWindow_ respondsToSelector:@selector(setAnimationBehavior:)]) { |
| 292 [dragWindow_ setAnimationBehavior:savedAnimationBehavior]; |
| 293 } |
258 } | 294 } |
259 | 295 |
260 // TODO(pinkerton): http://crbug.com/25682 demonstrates a way to get here by | 296 // TODO(pinkerton): http://crbug.com/25682 demonstrates a way to get here by |
261 // some weird circumstance that doesn't first go through mouseDown:. We | 297 // some weird circumstance that doesn't first go through mouseDown:. We |
262 // really shouldn't go any farther. | 298 // really shouldn't go any farther. |
263 if (!draggedController_ || !sourceController_) | 299 if (!draggedController_ || !sourceController_) |
264 return; | 300 return; |
265 | 301 |
266 // When the user first tears off the window, we want slide the window to | 302 // When the user first tears off the window, we want slide the window to |
267 // the current mouse location (to reduce the jarring appearance). We do this | 303 // the current mouse location (to reduce the jarring appearance). We do this |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 NOTREACHED(); | 550 NOTREACHED(); |
515 } | 551 } |
516 } | 552 } |
517 if (useCache) { | 553 if (useCache) { |
518 workspaceIDCache_[windowID] = workspace; | 554 workspaceIDCache_[windowID] = workspace; |
519 } | 555 } |
520 return workspace; | 556 return workspace; |
521 } | 557 } |
522 | 558 |
523 @end | 559 @end |
OLD | NEW |