OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser_window_fullscreen_transition.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_fullscreen_transition.h" |
6 | 6 |
7 #include <QuartzCore/QuartzCore.h> | 7 #include <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 NSRectFillUsingOperation(frame, NSCompositeDestinationOver); | 81 NSRectFillUsingOperation(frame, NSCompositeDestinationOver); |
82 | 82 |
83 [FramedBrowserWindow drawWindowThemeInDirtyRect:frame | 83 [FramedBrowserWindow drawWindowThemeInDirtyRect:frame |
84 forView:self | 84 forView:self |
85 bounds:[self bounds] | 85 bounds:[self bounds] |
86 forceBlackBackground:NO]; | 86 forceBlackBackground:NO]; |
87 } | 87 } |
88 | 88 |
89 @end | 89 @end |
90 | 90 |
91 @interface BrowserWindowFullscreenTransition () { | 91 @interface BrowserWindowFullscreenTransition () |
| 92 <CAAnimationDelegate, CALayerDelegate> { |
92 // Flag to keep track of whether we are entering or exiting fullscreen. | 93 // Flag to keep track of whether we are entering or exiting fullscreen. |
93 BOOL isEnteringFullscreen_; | 94 BOOL isEnteringFullscreen_; |
94 | 95 |
95 // The window which is undergoing the fullscreen transition. | 96 // The window which is undergoing the fullscreen transition. |
96 base::scoped_nsobject<FramedBrowserWindow> primaryWindow_; | 97 base::scoped_nsobject<FramedBrowserWindow> primaryWindow_; |
97 | 98 |
98 // The window which is undergoing the fullscreen transition. | 99 // The window which is undergoing the fullscreen transition. |
99 BrowserWindowController* controller_; // weak | 100 BrowserWindowController* controller_; // weak |
100 | 101 |
101 // A layer that holds a snapshot of the original state of |primaryWindow_|. | 102 // A layer that holds a snapshot of the original state of |primaryWindow_|. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // - Add NSFullScreenWindowMask style mask. | 158 // - Add NSFullScreenWindowMask style mask. |
158 // - Set the size to the screen's size. | 159 // - Set the size to the screen's size. |
159 - (void)preparePrimaryWindowForAnimation; | 160 - (void)preparePrimaryWindowForAnimation; |
160 | 161 |
161 // Applies the fullscreen animation to |snapshotLayer_|. | 162 // Applies the fullscreen animation to |snapshotLayer_|. |
162 - (void)animateSnapshotWindowWithDuration:(CGFloat)duration; | 163 - (void)animateSnapshotWindowWithDuration:(CGFloat)duration; |
163 | 164 |
164 // Sets |primaryWindow_|'s frame to the expected frame. | 165 // Sets |primaryWindow_|'s frame to the expected frame. |
165 - (void)changePrimaryWindowToFinalFrame; | 166 - (void)changePrimaryWindowToFinalFrame; |
166 | 167 |
167 // Override of CAAnimation delegate method. | 168 // Overrides of CAAnimation delegate methods. |
| 169 - (void)animationDidStart:(CAAnimation*)theAnimation; |
168 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished; | 170 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished; |
169 | 171 |
170 // Returns the layer of the root view of |window|. | 172 // Returns the layer of the root view of |window|. |
171 - (CALayer*)rootLayerOfWindow:(NSWindow*)window; | 173 - (CALayer*)rootLayerOfWindow:(NSWindow*)window; |
172 | 174 |
173 // Convert the point to be relative to the screen the primary window is on. | 175 // Convert the point to be relative to the screen the primary window is on. |
174 // This is important because if we're using multiple screens, the coordinate | 176 // This is important because if we're using multiple screens, the coordinate |
175 // system extends to the second screen. | 177 // system extends to the second screen. |
176 // | 178 // |
177 // For example, if the screen width is 1440, the second screen's frame origin | 179 // For example, if the screen width is 1440, the second screen's frame origin |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 CALayer* root = [self rootLayerOfWindow:primaryWindow_]; | 477 CALayer* root = [self rootLayerOfWindow:primaryWindow_]; |
476 [root addAnimation:group forKey:kPrimaryWindowAnimationID]; | 478 [root addAnimation:group forKey:kPrimaryWindowAnimationID]; |
477 } | 479 } |
478 | 480 |
479 - (void)changePrimaryWindowToFinalFrame { | 481 - (void)changePrimaryWindowToFinalFrame { |
480 changingPrimaryWindowSize_ = YES; | 482 changingPrimaryWindowSize_ = YES; |
481 [primaryWindow_ setFrame:finalFrame_ display:NO]; | 483 [primaryWindow_ setFrame:finalFrame_ display:NO]; |
482 changingPrimaryWindowSize_ = NO; | 484 changingPrimaryWindowSize_ = NO; |
483 } | 485 } |
484 | 486 |
| 487 - (void)animationDidStart:(CAAnimation*)theAnimation { |
| 488 // CAAnimationDelegate method added on OSX 10.12. |
| 489 } |
| 490 |
485 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { | 491 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { |
486 NSString* animationID = [theAnimation valueForKey:kAnimationIDKey]; | 492 NSString* animationID = [theAnimation valueForKey:kAnimationIDKey]; |
487 | 493 |
488 // Remove the snapshot window. | 494 // Remove the snapshot window. |
489 if ([animationID isEqual:kSnapshotWindowAnimationID]) { | 495 if ([animationID isEqual:kSnapshotWindowAnimationID]) { |
490 [snapshotWindow_ orderOut:nil]; | 496 [snapshotWindow_ orderOut:nil]; |
491 snapshotWindow_.reset(); | 497 snapshotWindow_.reset(); |
492 snapshotLayer_.reset(); | 498 snapshotLayer_.reset(); |
493 return; | 499 return; |
494 } | 500 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 return [[[window contentView] superview] layer]; | 550 return [[[window contentView] superview] layer]; |
545 } | 551 } |
546 | 552 |
547 - (NSPoint)pointRelativeToCurrentScreen:(NSPoint)point { | 553 - (NSPoint)pointRelativeToCurrentScreen:(NSPoint)point { |
548 NSRect screenFrame = [[primaryWindow_ screen] frame]; | 554 NSRect screenFrame = [[primaryWindow_ screen] frame]; |
549 return NSMakePoint(point.x - screenFrame.origin.x, | 555 return NSMakePoint(point.x - screenFrame.origin.x, |
550 point.y - screenFrame.origin.y); | 556 point.y - screenFrame.origin.y); |
551 } | 557 } |
552 | 558 |
553 @end | 559 @end |
OLD | NEW |