Index: chrome/browser/ui/cocoa/browser_window_controller_private.mm |
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm |
index 3874f2005a146a1393b43bd605710d18c9cbd265..d0cb2e5923307cf351b359dd0b85b06853126067 100644 |
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm |
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm |
@@ -7,6 +7,7 @@ |
#include <cmath> |
#include "base/command_line.h" |
+#include "base/mac/bind_objc_block.h" |
#include "base/mac/mac_util.h" |
#import "base/mac/scoped_nsobject.h" |
#import "base/mac/sdk_forward_declarations.h" |
@@ -682,6 +683,8 @@ willPositionSheet:(NSWindow*)sheet |
BOOL mode = enteringPresentationMode_ || |
browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending(); |
enteringAppKitFullscreen_ = YES; |
+ enteringAppKitFullscreenOnPrimaryScreen_ = |
+ [[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]]; |
fullscreen_mac::SlidingStyle style = |
mode ? fullscreen_mac::OMNIBOX_TABS_HIDDEN |
@@ -704,6 +707,32 @@ willPositionSheet:(NSWindow*)sheet |
} |
} |
+ if ([self shouldUseMavericksAppKitFullscreenHack]) { |
+ // Apply a hack to fix the size of the window. This is the last run of the |
+ // MessageLoop where the hack will not work, so dispatch the hack to the |
+ // top of the MessageLoop. |
+ base::Callback<void(void)> callback = base::BindBlock(^{ |
+ if (![self isInAppKitFullscreen]) |
+ return; |
+ |
+ // The window's frame should be exactly 22 points too short. |
+ CGFloat kExpectedHeightDifference = 22; |
+ NSRect currentFrame = [[self window] frame]; |
+ NSRect expectedFrame = [[[self window] screen] frame]; |
+ if (!NSEqualPoints(currentFrame.origin, expectedFrame.origin)) |
+ return; |
+ if (currentFrame.size.width != expectedFrame.size.width) |
+ return; |
+ CGFloat heightDelta = |
+ expectedFrame.size.height - currentFrame.size.height; |
+ if (fabs(heightDelta - kExpectedHeightDifference) > 0.01) |
+ return; |
+ |
+ [[self window] setFrame:expectedFrame display:YES]; |
+ }); |
+ base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
+ } |
+ |
if (notification) // For System Fullscreen when non-nil. |
[self deregisterForContentViewResizeNotifications]; |
enteringAppKitFullscreen_ = NO; |
@@ -1049,4 +1078,18 @@ willPositionSheet:(NSWindow*)sheet |
} |
} |
+- (BOOL)shouldUseMavericksAppKitFullscreenHack { |
+ if (!base::mac::IsOSMavericks()) |
Robert Sesek
2014/10/17 19:13:16
This issue is resolved on Yosemite?
erikchen
2014/10/17 21:02:33
Yes. The bug only affects Mavericks.
|
+ return NO; |
+ if (![NSScreen respondsToSelector:@selector(screensHaveSeparateSpaces)] || |
+ ![NSScreen screensHaveSeparateSpaces]) |
Robert Sesek
2014/10/17 19:13:16
nit: any time the condition is multiple lines, the
erikchen
2014/10/17 21:02:32
Done.
One day, in a universe far-far away, clang
|
+ return NO; |
+ if (!enteringAppKitFullscreen_) |
+ return NO; |
+ if (enteringAppKitFullscreenOnPrimaryScreen_) |
+ return NO; |
+ |
+ return YES; |
+} |
+ |
@end // @implementation BrowserWindowController(Private) |