Skip to content

Commit b517b31

Browse files
committed
Merge pull request #4 from jquave/master
Fix the fullscreen display rect for multiple monitors on Yosemite
2 parents cbb3ecd + 3530d1d commit b517b31

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/MacVim/MMFullScreenWindow.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ - (MMFullScreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v
6565
// you can't change the style of an existing window in cocoa. create a new
6666
// window and move the MMTextView into it.
6767
// (another way would be to make the existing window large enough that the
68-
// title bar is off screen. but that doesn't work with multiple screens).
68+
// title bar is off screen. but that doesn't work with multiple screens).
6969
self = [super initWithContentRect:[screen frame]
7070
styleMask:NSBorderlessWindowMask
7171
backing:NSBackingStoreBuffered
@@ -371,6 +371,15 @@ - (void)applicationDidChangeScreenParameters:(NSNotification *)notification
371371
[self resizeVimView];
372372
}
373373

374+
- (CGFloat) viewOffset {
375+
CGFloat menuBarHeight = 0;
376+
if([self screen] != [[NSScreen screens] objectAtIndex:0]) {
377+
// Screens other than the primary screen will not hide their menu bar, adjust the visible view down by the menu height
378+
menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight]-1;
379+
}
380+
return menuBarHeight;
381+
}
382+
374383
- (void)centerView
375384
{
376385
NSRect outer = [self frame], inner = [view frame];
@@ -379,7 +388,7 @@ - (void)centerView
379388
// rendering issues may arise (screen looks blurry, each redraw clears the
380389
// entire window, etc.).
381390
NSPoint origin = { floor((outer.size.width - inner.size.width)/2),
382-
floor((outer.size.height - inner.size.height)/2) };
391+
floor((outer.size.height - inner.size.height)/2 - [self viewOffset]/2) };
383392

384393
[view setFrameOrigin:origin];
385394
}
@@ -478,6 +487,8 @@ - (void)resizeVimView
478487
// size since it compensates for menu and dock.
479488
int maxRows, maxColumns;
480489
NSSize size = [[self screen] frame].size;
490+
size.height -= [self viewOffset];
491+
481492
[view constrainRows:&maxRows columns:&maxColumns toSize:size];
482493

483494
// Compute current fu size

0 commit comments

Comments
 (0)