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

Unified Diff: chrome/browser/ui/cocoa/browser_window_cocoa.mm

Issue 7621061: Restoring a session should restore window minimization state (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing Mark's comments. Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser_window_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index 5faefc7418f4eef97825059f7abeb76cde9ba57e..c87c61ab501df3e2d5785898642ebcc37eccad1c 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -44,11 +44,31 @@
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util_mac.h"
+#include "ui/base/ui_base_types.h"
#include "ui/gfx/rect.h"
+// Replicate specific 10.7 SDK declarations for building with prior SDKs.
+#if !defined(MAC_OS_X_VERSION_10_7) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
+
+enum {
+ NSWindowAnimationBehaviorDefault = 0,
+ NSWindowAnimationBehaviorNone = 2,
+ NSWindowAnimationBehaviorDocumentWindow = 3,
+ NSWindowAnimationBehaviorUtilityWindow = 4,
+ NSWindowAnimationBehaviorAlertPanel = 5
+};
+typedef NSInteger NSWindowAnimationBehavior;
+
+@interface NSWindow (LionSDKDeclarations)
+- (NSWindowAnimationBehavior)animationBehavior;
+- (void)setAnimationBehavior:(NSWindowAnimationBehavior)newAnimationBehavior;
+@end
+
+#endif // MAC_OS_X_VERSION_10_7
+
BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser,
- BrowserWindowController* controller,
- NSWindow* window)
+ BrowserWindowController* controller)
: browser_(browser),
controller_(controller),
confirm_close_factory_(browser) {
@@ -73,11 +93,35 @@ void BrowserWindowCocoa::Show() {
// the previous browser instead if we don't explicitly set it here.
BrowserList::SetLastActive(browser_);
- [window() makeKeyAndOrderFront:controller_];
+ ui::WindowShowState show_state = browser_->GetSavedWindowShowState();
+ if (show_state == ui::SHOW_STATE_MINIMIZED) {
+ // Turn off swishing when restoring minimized windows. When creating
+ // windows from nibs it is necessary to |orderFront:| prior to |orderOut:|
+ // then |miniaturize:| when restoring windows in the minimized state.
+ NSWindowAnimationBehavior savedAnimationBehavior = 0;
+ if ([window() respondsToSelector:@selector(animationBehavior)] &&
+ [window() respondsToSelector:@selector(setAnimationBehavior:)]) {
+ savedAnimationBehavior = [window() animationBehavior];
+ [window() setAnimationBehavior:NSWindowAnimationBehaviorNone];
+ }
+
+ [window() makeKeyAndOrderFront:controller_];
+
+ [window() orderOut:controller_];
+ [window() miniaturize:controller_];
+
+ // Restore window animation behavior.
+ if ([window() respondsToSelector:@selector(animationBehavior)] &&
+ [window() respondsToSelector:@selector(setAnimationBehavior:)]) {
+ [window() setAnimationBehavior:savedAnimationBehavior];
+ }
+ } else {
+ [window() makeKeyAndOrderFront:controller_];
+ }
}
void BrowserWindowCocoa::ShowInactive() {
- [window() orderFront:controller_];
+ [window() orderFront:controller_];
}
void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) {
@@ -214,6 +258,10 @@ bool BrowserWindowCocoa::IsMaximized() const {
return [window() isZoomed];
}
+bool BrowserWindowCocoa::IsMinimized() const {
+ return [window() isMiniaturized];
+}
+
void BrowserWindowCocoa::SetFullscreen(bool fullscreen) {
[controller_ setFullscreen:fullscreen];
}
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_cocoa.h ('k') | chrome/browser/ui/cocoa/browser_window_cocoa_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698