Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_cocoa.mm

Issue 7809013: Remove Animation When "Resuming" Window in Lion (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addresses Marks comments, choosing Browser::is_session_restore flag approach. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" 5 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 void BrowserWindowCocoa::Show() { 86 void BrowserWindowCocoa::Show() {
87 // The Browser associated with this browser window must become the active 87 // The Browser associated with this browser window must become the active
88 // browser at the time |Show()| is called. This is the natural behaviour under 88 // browser at the time |Show()| is called. This is the natural behaviour under
89 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| 89 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:|
90 // until we return to the runloop. Therefore any calls to 90 // until we return to the runloop. Therefore any calls to
91 // |BrowserList::GetLastActive()| (for example, in bookmark_util), will return 91 // |BrowserList::GetLastActive()| (for example, in bookmark_util), will return
92 // the previous browser instead if we don't explicitly set it here. 92 // the previous browser instead if we don't explicitly set it here.
93 BrowserList::SetLastActive(browser_); 93 BrowserList::SetLastActive(browser_);
94 94
95 ui::WindowShowState show_state = browser_->GetSavedWindowShowState(); 95 bool is_session_restore = browser_->is_session_restore();
96 if (show_state == ui::SHOW_STATE_MINIMIZED) { 96 NSWindowAnimationBehavior saved_animation_behavior = 0;
Mark Mentovai 2011/08/31 17:58:54 This no longer needs to be initialized to 0, since
dhollowa 2011/08/31 18:40:55 Done.
97 // Turn off swishing when restoring minimized windows. When creating 97 bool did_save_animation_behavior = false;
98 // windows from nibs it is necessary to |orderFront:| prior to |orderOut:| 98 // Turn off swishing when restoring windows.
99 // then |miniaturize:| when restoring windows in the minimized state. 99 if (is_session_restore &&
100 NSWindowAnimationBehavior savedAnimationBehavior = 0; 100 [window() respondsToSelector:@selector(animationBehavior)] &&
101 if ([window() respondsToSelector:@selector(animationBehavior)] && 101 [window() respondsToSelector:@selector(setAnimationBehavior:)]) {
102 [window() respondsToSelector:@selector(setAnimationBehavior:)]) { 102 saved_animation_behavior = [window() animationBehavior];
103 savedAnimationBehavior = [window() animationBehavior]; 103 [window() setAnimationBehavior:NSWindowAnimationBehaviorNone];
104 [window() setAnimationBehavior:NSWindowAnimationBehaviorNone]; 104 did_save_animation_behavior = true;
Mark Mentovai 2011/08/31 17:58:54 I would do this before changing the value, just be
dhollowa 2011/08/31 18:40:55 Done.
105 } 105 }
106 106
107 [window() makeKeyAndOrderFront:controller_]; 107 [window() makeKeyAndOrderFront:controller_];
108 108
109 // When creating windows from nibs it is necessary to |makeKeyAndOrderFront:|
110 // prior to |orderOut:| then |miniaturize:| when restoring windows in the
111 // minimized state.
112 if (browser_->GetSavedWindowShowState() == ui::SHOW_STATE_MINIMIZED) {
109 [window() orderOut:controller_]; 113 [window() orderOut:controller_];
110 [window() miniaturize:controller_]; 114 [window() miniaturize:controller_];
115 }
111 116
117 if (did_save_animation_behavior) {
112 // Restore window animation behavior. 118 // Restore window animation behavior.
113 if ([window() respondsToSelector:@selector(animationBehavior)] && 119 [window() setAnimationBehavior:saved_animation_behavior];
114 [window() respondsToSelector:@selector(setAnimationBehavior:)]) {
115 [window() setAnimationBehavior:savedAnimationBehavior];
116 }
117 } else {
118 [window() makeKeyAndOrderFront:controller_];
119 } 120 }
121
122 // Once the window has been shown, clear the session restore flag.
123 browser_->set_is_session_restore(false);
Mark Mentovai 2011/08/31 17:58:54 This is the only platform on which this happens, r
dhollowa 2011/08/31 18:40:55 Yes, this is Mac-only logic. I agree though, this
120 } 124 }
121 125
122 void BrowserWindowCocoa::ShowInactive() { 126 void BrowserWindowCocoa::ShowInactive() {
123 [window() orderFront:controller_]; 127 [window() orderFront:controller_];
124 } 128 }
125 129
126 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { 130 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) {
127 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; 131 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds];
128 132
129 SetFullscreen(false); 133 SetFullscreen(false);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 581
578 NSWindow* BrowserWindowCocoa::window() const { 582 NSWindow* BrowserWindowCocoa::window() const {
579 return [controller_ window]; 583 return [controller_ window];
580 } 584 }
581 585
582 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { 586 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) {
583 if (tab_contents == browser_->GetSelectedTabContents()) { 587 if (tab_contents == browser_->GetSelectedTabContents()) {
584 [controller_ updateSidebarForContents:tab_contents]; 588 [controller_ updateSidebarForContents:tab_contents];
585 } 589 }
586 } 590 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698