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

Side by Side Diff: chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm

Issue 23494065: Fix restoring a window after maximizing it. (Mac) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 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/cocoa/apps/native_app_window_cocoa.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/apps/native_app_window_cocoa.h" 5 #include "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h"
6 6
7 #include "apps/app_shim/extension_app_shim_handler_mac.h" 7 #include "apps/app_shim/extension_app_shim_handler_mac.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 // Replicate specific 10.7 SDK declarations for building with prior SDKs. 50 // Replicate specific 10.7 SDK declarations for building with prior SDKs.
51 #if !defined(MAC_OS_X_VERSION_10_7) || \ 51 #if !defined(MAC_OS_X_VERSION_10_7) || \
52 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 52 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
53 53
54 @interface NSWindow (LionSDKDeclarations) 54 @interface NSWindow (LionSDKDeclarations)
55 - (void)toggleFullScreen:(id)sender; 55 - (void)toggleFullScreen:(id)sender;
56 @end 56 @end
57 57
58 enum { 58 enum {
59 NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7 59 NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
60 NSFullScreenWindowMask = 1 << 14
60 }; 61 };
61 62
62 #endif // MAC_OS_X_VERSION_10_7 63 #endif // MAC_OS_X_VERSION_10_7
63 64
64 @implementation NativeAppWindowController 65 @implementation NativeAppWindowController
65 66
66 @synthesize appWindow = appWindow_; 67 @synthesize appWindow = appWindow_;
67 68
68 - (void)windowWillClose:(NSNotification*)notification { 69 - (void)windowWillClose:(NSNotification*)notification {
69 if (appWindow_) 70 if (appWindow_)
70 appWindow_->WindowWillClose(); 71 appWindow_->WindowWillClose();
71 } 72 }
72 73
73 - (void)windowDidBecomeKey:(NSNotification*)notification { 74 - (void)windowDidBecomeKey:(NSNotification*)notification {
74 if (appWindow_) 75 if (appWindow_)
75 appWindow_->WindowDidBecomeKey(); 76 appWindow_->WindowDidBecomeKey();
76 } 77 }
77 78
78 - (void)windowDidResignKey:(NSNotification*)notification { 79 - (void)windowDidResignKey:(NSNotification*)notification {
79 if (appWindow_) 80 if (appWindow_)
80 appWindow_->WindowDidResignKey(); 81 appWindow_->WindowDidResignKey();
81 } 82 }
82 83
83 - (void)windowDidResize:(NSNotification*)notification { 84 - (void)windowDidResize:(NSNotification*)notification {
84 if (appWindow_) 85 if (appWindow_)
85 appWindow_->WindowDidResize(); 86 appWindow_->WindowDidResize();
86 } 87 }
87 88
89 - (void)windowDidEndLiveResize:(NSNotification*)notification {
90 if (appWindow_)
91 appWindow_->WindowDidFinishResize();
92 }
93
94 - (void)windowDidEnterFullScreen:(NSNotification*)notification {
95 if (appWindow_)
96 appWindow_->WindowDidFinishResize();
97 }
98
99 - (void)windowDidExitFullScreen:(NSNotification*)notification {
100 if (appWindow_)
101 appWindow_->WindowDidFinishResize();
102 }
103
88 - (void)windowDidMove:(NSNotification*)notification { 104 - (void)windowDidMove:(NSNotification*)notification {
89 if (appWindow_) 105 if (appWindow_)
90 appWindow_->WindowDidMove(); 106 appWindow_->WindowDidMove();
91 } 107 }
92 108
93 - (void)windowDidMiniaturize:(NSNotification*)notification { 109 - (void)windowDidMiniaturize:(NSNotification*)notification {
94 if (appWindow_) 110 if (appWindow_)
95 appWindow_->WindowDidMiniaturize(); 111 appWindow_->WindowDidMiniaturize();
96 } 112 }
97 113
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 // lose key window status. 848 // lose key window status.
833 if ([NSApp isActive] && ([NSApp keyWindow] == window())) 849 if ([NSApp isActive] && ([NSApp keyWindow] == window()))
834 return; 850 return;
835 851
836 content::RenderWidgetHostView* rwhv = 852 content::RenderWidgetHostView* rwhv =
837 web_contents()->GetRenderWidgetHostView(); 853 web_contents()->GetRenderWidgetHostView();
838 if (rwhv) 854 if (rwhv)
839 rwhv->SetActive(false); 855 rwhv->SetActive(false);
840 } 856 }
841 857
842 void NativeAppWindowCocoa::WindowDidResize() { 858 void NativeAppWindowCocoa::WindowDidFinishResize() {
843 // Update |is_maximized_| if needed: 859 // Update |is_maximized_| if needed:
844 // - Exit maximized state if resized. 860 // - Exit maximized state if resized.
845 // - Consider us maximized if resize places us back to maximized location. 861 // - Consider us maximized if resize places us back to maximized location.
846 // This happens when returning from fullscreen. 862 // This happens when returning from fullscreen.
847 NSRect frame = [window() frame]; 863 NSRect frame = [window() frame];
848 NSRect screen = [[window() screen] visibleFrame]; 864 NSRect screen = [[window() screen] visibleFrame];
849 if (!NSEqualSizes(frame.size, screen.size)) 865 if (!NSEqualSizes(frame.size, screen.size))
850 is_maximized_ = false; 866 is_maximized_ = false;
851 else if (NSEqualPoints(frame.origin, screen.origin)) 867 else if (NSEqualPoints(frame.origin, screen.origin))
852 is_maximized_ = true; 868 is_maximized_ = true;
853 869
870 // Update |is_fullscreen_| if needed.
871 is_fullscreen_ = ([window() styleMask] & NSFullScreenWindowMask) != 0;
872
854 UpdateRestoredBounds(); 873 UpdateRestoredBounds();
874 }
875
876 void NativeAppWindowCocoa::WindowDidResize() {
scheib 2013/09/24 16:04:15 Certain you don't need UpdaterestoredBounds() in t
jackhou1 2013/09/24 21:34:25 WindowDidResize is called repeatedly while a windo
tapted 2013/09/24 23:23:14 I got the impression from the Apple docs (i.e. htt
jackhou1 2013/09/30 01:46:33 You're right, the frame size is the same.
855 shell_window_->OnNativeWindowChanged(); 877 shell_window_->OnNativeWindowChanged();
856 } 878 }
857 879
858 void NativeAppWindowCocoa::WindowDidMove() { 880 void NativeAppWindowCocoa::WindowDidMove() {
859 UpdateRestoredBounds(); 881 UpdateRestoredBounds();
860 shell_window_->OnNativeWindowChanged(); 882 shell_window_->OnNativeWindowChanged();
861 } 883 }
862 884
863 void NativeAppWindowCocoa::WindowDidMiniaturize() { 885 void NativeAppWindowCocoa::WindowDidMiniaturize() {
864 shell_window_->OnNativeWindowChanged(); 886 shell_window_->OnNativeWindowChanged();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 ShellNSWindow* NativeAppWindowCocoa::window() const { 950 ShellNSWindow* NativeAppWindowCocoa::window() const {
929 NSWindow* window = [window_controller_ window]; 951 NSWindow* window = [window_controller_ window];
930 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); 952 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]);
931 return static_cast<ShellNSWindow*>(window); 953 return static_cast<ShellNSWindow*>(window);
932 } 954 }
933 955
934 void NativeAppWindowCocoa::UpdateRestoredBounds() { 956 void NativeAppWindowCocoa::UpdateRestoredBounds() {
935 if (IsRestored(*this)) 957 if (IsRestored(*this))
936 restored_bounds_ = [window() frame]; 958 restored_bounds_ = [window() frame];
937 } 959 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698