Use correct screen for full screen

The autocommand "au GUIEnter * set fu" would cause the full screen
window to always appear on the primary monitor when multiple monitors
were connected.  This commit fixes this problem.
This commit is contained in:
Bjorn Winckler
2010-10-14 17:37:10 +02:00
parent 291a5c40b4
commit 98b5cd3e62
3 changed files with 46 additions and 16 deletions
+3 -2
View File
@@ -19,6 +19,7 @@
MMVimView *view;
NSPoint oldPosition;
NSString *oldTabBarStyle;
int options;
// These are only valid in fullscreen mode and store pre-fu vim size
int nonFuRows, nonFuColumns;
@@ -32,8 +33,8 @@
- (MMFullscreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v
backgroundColor:(NSColor *)back;
- (void)enterFullscreen:(int)fuoptions;
- (void)setOptions:(int)opt;
- (void)enterFullscreen;
- (void)leaveFullscreen;
- (void)centerView;
+17 -6
View File
@@ -107,8 +107,15 @@
[super dealloc];
}
- (void)enterFullscreen:(int)fuoptions
- (void)setOptions:(int)opt
{
options = opt;
}
- (void)enterFullscreen
{
ASLogDebug(@"Enter full screen now");
// fade to black
Boolean didBlend = NO;
CGDisplayFadeReservationToken token;
@@ -117,7 +124,11 @@
kCGDisplayBlendSolidColor, .0, .0, .0, true);
didBlend = YES;
}
// NOTE: The window may have moved to another screen in between init.. and
// this call so set the frame again just in case.
[self setFrame:[[target screen] frame] display:NO];
// fool delegate
id delegate = [target delegate];
[target setDelegate:nil];
@@ -146,7 +157,7 @@
// focus gained message
[self setDelegate:delegate];
// resize vim view according to fuoptions
// resize vim view according to options
int currRows, currColumns;
[[view textView] getMaxRows:&currRows columns:&currColumns];
@@ -163,12 +174,12 @@
nonFuColumns = currColumns;
// Compute current fu size
if (fuoptions & FUOPT_MAXVERT)
if (options & FUOPT_MAXVERT)
fuRows = maxRows;
if (fuoptions & FUOPT_MAXHORZ)
if (options & FUOPT_MAXHORZ)
fuColumns = maxColumns;
startFuFlags = fuoptions;
startFuFlags = options;
// if necessary, resize vim to target fu size
if (currRows != fuRows || currColumns != fuColumns) {
+26 -8
View File
@@ -273,6 +273,13 @@
[[MMAppController sharedInstance] windowControllerWillOpen:self];
[[self window] makeKeyAndOrderFront:self];
if (fullscreenWindow) {
// Delayed entering of full screen happens here (a ":set fu" in a
// GUIEnter auto command could cause this).
[fullscreenWindow enterFullscreen];
fullscreenEnabled = YES;
}
return YES;
}
@@ -607,17 +614,28 @@
{
if (fullscreenEnabled) return;
// fullscreenWindow could be nil here if this is called multiple times
// during startup.
[fullscreenWindow release];
fullscreenWindow = [[MMFullscreenWindow alloc]
initWithWindow:decoratedWindow view:vimView backgroundColor:back];
[fullscreenWindow enterFullscreen:fuoptions];
[fullscreenWindow setDelegate:self];
initWithWindow:decoratedWindow view:vimView backgroundColor:back];
[fullscreenWindow setOptions:fuoptions];
[fullscreenWindow setRepresentedFilename:
[decoratedWindow representedFilename]];
fullscreenEnabled = YES;
// The resize handle disappears so the vim view needs to update the
// scrollbars.
shouldResizeVimView = YES;
// If the window is not visible then delay entering full screen until the
// window is presented.
if ([decoratedWindow isVisible]) {
[fullscreenWindow enterFullscreen];
fullscreenEnabled = YES;
// The resize handle disappears so the vim view needs to update the
// scrollbars.
shouldResizeVimView = YES;
} else {
ASLogDebug(@"Delay enter full screen");
}
}
- (void)leaveFullscreen
@@ -635,7 +653,7 @@
- (void)setFullscreenBackgroundColor:(NSColor *)back
{
if (fullscreenEnabled)
if (fullscreenWindow)
[fullscreenWindow setBackgroundColor:back];
}