From 3530d1dab1edd436f74ef620ae87ade324eb3939 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Tue, 24 Mar 2015 07:40:44 -0500 Subject: [PATCH] Fix the fullscreen display rect for multiple monitors on Yosemite When using a second display on Yosemite, the menu bar is not animated out as it is on the primary display, which causes the Mac OS menu bar to cover up the first line or so of MacVim in fullscreen. This fix defines a viewOffset method and adjusts the vim view rect based on whether or not the primary display is being used. --- src/MacVim/MMFullScreenWindow.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/MacVim/MMFullScreenWindow.m b/src/MacVim/MMFullScreenWindow.m index 658c24ac92..eccf9147c4 100644 --- a/src/MacVim/MMFullScreenWindow.m +++ b/src/MacVim/MMFullScreenWindow.m @@ -65,7 +65,7 @@ - (MMFullScreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v // you can't change the style of an existing window in cocoa. create a new // window and move the MMTextView into it. // (another way would be to make the existing window large enough that the - // title bar is off screen. but that doesn't work with multiple screens). + // title bar is off screen. but that doesn't work with multiple screens). self = [super initWithContentRect:[screen frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered @@ -371,6 +371,15 @@ - (void)applicationDidChangeScreenParameters:(NSNotification *)notification [self resizeVimView]; } +- (CGFloat) viewOffset { + CGFloat menuBarHeight = 0; + if([self screen] != [[NSScreen screens] objectAtIndex:0]) { + // Screens other than the primary screen will not hide their menu bar, adjust the visible view down by the menu height + menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight]-1; + } + return menuBarHeight; +} + - (void)centerView { NSRect outer = [self frame], inner = [view frame]; @@ -379,7 +388,7 @@ - (void)centerView // rendering issues may arise (screen looks blurry, each redraw clears the // entire window, etc.). NSPoint origin = { floor((outer.size.width - inner.size.width)/2), - floor((outer.size.height - inner.size.height)/2) }; + floor((outer.size.height - inner.size.height)/2 - [self viewOffset]/2) }; [view setFrameOrigin:origin]; } @@ -478,6 +487,8 @@ - (void)resizeVimView // size since it compensates for menu and dock. int maxRows, maxColumns; NSSize size = [[self screen] frame].size; + size.height -= [self viewOffset]; + [view constrainRows:&maxRows columns:&maxColumns toSize:size]; // Compute current fu size