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

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

Issue 402443003: mac: [Yosemite] Fix bug where zoom button causes fullscreen mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from andresantoso, round 2. Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/version_independent_window.mm
diff --git a/chrome/browser/ui/cocoa/version_independent_window.mm b/chrome/browser/ui/cocoa/version_independent_window.mm
index 24284a490d064e8b943e5d236653544bd56db79c..99d52caf0e008fadd46e1155b9e966a4ecd61e4e 100644
--- a/chrome/browser/ui/cocoa/version_independent_window.mm
+++ b/chrome/browser/ui/cocoa/version_independent_window.mm
@@ -6,6 +6,33 @@
#include "base/logging.h"
#include "base/mac/mac_util.h"
+#include "base/mac/scoped_nsobject.h"
+
+// This view always takes the size of its superview. It is intended to be used
+// as a NSWindow's contentView. It is needed because NSWindow's implementation
+// explicitly resizes the contentView at inopportune times.
+@interface FullSizeContentView : NSView
+@end
+
+namespace {
+
+// Reorders the subviews of NSWindow's root view so that the contentView is
+// moved to the back, and the ordering of the other views is unchanged.
+// |context| should be an NSArray containing the subviews of the root view as
+// they were previously ordered.
+int ReorderContentViewToBack(id firstView, id secondView, void* context) {
+ NSView* contentView = [[firstView window] contentView];
+ NSArray* subviews = static_cast<NSArray*>(context);
+ if (firstView == contentView)
+ return NSOrderedAscending;
+ if (secondView == contentView)
+ return NSOrderedDescending;
+ NSUInteger index1 = [subviews indexOfObject:firstView];
+ NSUInteger index2 = [subviews indexOfObject:secondView];
+ return (index1 < index2) ? NSOrderedAscending : NSOrderedDescending;
+}
+
+} // namespace
@interface VersionIndependentWindow ()
@@ -15,12 +42,6 @@
@end
-// This view always takes the size of its superview. It is intended to be used
-// as a NSWindow's contentView. It is needed because NSWindow's implementation
-// explicitly resizes the contentView at inopportune times.
-@interface FullSizeContentView : NSView
-@end
-
@implementation FullSizeContentView
// This method is directly called by NSWindow during a window resize on OSX
@@ -81,6 +102,19 @@
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[chromeWindowView_ setFrame:[[[self contentView] superview] bounds]];
[self setContentView:chromeWindowView_];
+
+ // Move the content view to the back.
+ // In Yosemite, the content view takes up the full size of the window,
+ // and when it is in front of the zoom/fullscreen button, alt-clicking
+ // the button has the wrong effect.
+ // Adding subviews to the NSThemeFrame provokes a warning in Yosemite, so
+ // we sort the subviews in place.
+ // http://crbug.com/393808
+
+ NSView* superview = [[self contentView] superview];
+ base::scoped_nsobject<NSArray> subviews([[superview subviews] copy]);
+ [superview sortSubviewsUsingFunction:&ReorderContentViewToBack
+ context:subviews.get()];
Scott Hess - ex-Googler 2014/07/17 21:03:09 Wow. I'm assuming the comment refers to an attemp
erikchen 2014/07/17 21:17:08 I tried out your suggestion. It works fine and doe
}
}
return self;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698