diff --git a/src/MacVim/MMFullScreenWindow.h b/src/MacVim/MMFullScreenWindow.h index 9a86c5c5d8..629570c40c 100644 --- a/src/MacVim/MMFullScreenWindow.h +++ b/src/MacVim/MMFullScreenWindow.h @@ -30,6 +30,10 @@ // This stores the contents of fuoptions_flags at fu start time int startFuFlags; + + // Controls the speed of the fade in and out. + double fadeTime; + double fadeReservationTime; } - (MMFullScreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v diff --git a/src/MacVim/MMFullScreenWindow.m b/src/MacVim/MMFullScreenWindow.m index ed6bd970af..d0af2bc681 100644 --- a/src/MacVim/MMFullScreenWindow.m +++ b/src/MacVim/MMFullScreenWindow.m @@ -104,7 +104,24 @@ enum { // NOTE: Vim needs to process mouse moved events, so enable them here. [self setAcceptsMouseMovedEvents:YES]; - + + // Prefer to get the fade time from preferences, but default to the original time + // if the key doesn't exist yet. + NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; + if ([[[defaults dictionaryRepresentation] allKeys] containsObject:MMFullScreenFadeTimeKey]) { + fadeTime = [[NSUserDefaults standardUserDefaults] doubleForKey:MMFullScreenFadeTimeKey]; + } else { + fadeTime = 0.25; + } + + // Each fade goes in and then out, so the fade hardware must be reserved accordingly and the + // actual fade time can't exceed half the allowable reservation time... plus some slack to + // prevent visual artifacts caused by defaulting on the fade hardware lease. + if (fadeTime > 0.45 * kCGMaxDisplayReservationInterval) { + fadeTime = 0.45 * kCGMaxDisplayReservationInterval; + } + fadeReservationTime = 2.0 * fadeTime + 0.1; + return self; } @@ -137,8 +154,8 @@ enum { // fade to black Boolean didBlend = NO; CGDisplayFadeReservationToken token; - if (CGAcquireDisplayFadeReservation(.5, &token) == kCGErrorSuccess) { - CGDisplayFade(token, .25, kCGDisplayBlendNormal, + if (CGAcquireDisplayFadeReservation(fadeReservationTime, &token) == kCGErrorSuccess) { + CGDisplayFade(token, fadeTime, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, .0, .0, .0, true); didBlend = YES; } @@ -212,7 +229,7 @@ enum { // fade back in if (didBlend) { - CGDisplayFade(token, .25, kCGDisplayBlendSolidColor, + CGDisplayFade(token, fadeTime, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, .0, .0, .0, false); CGReleaseDisplayFadeReservation(token); } @@ -225,8 +242,8 @@ enum { // fade to black Boolean didBlend = NO; CGDisplayFadeReservationToken token; - if (CGAcquireDisplayFadeReservation(.5, &token) == kCGErrorSuccess) { - CGDisplayFade(token, .25, kCGDisplayBlendNormal, + if (CGAcquireDisplayFadeReservation(fadeReservationTime, &token) == kCGErrorSuccess) { + CGDisplayFade(token, fadeTime, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, .0, .0, .0, true); didBlend = YES; } @@ -320,7 +337,7 @@ enum { // fade back in if (didBlend) { - CGDisplayFade(token, .25, kCGDisplayBlendSolidColor, + CGDisplayFade(token, fadeTime, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, .0, .0, .0, false); CGReleaseDisplayFadeReservation(token); } diff --git a/src/MacVim/Miscellaneous.h b/src/MacVim/Miscellaneous.h index da513c1b32..263917eea8 100644 --- a/src/MacVim/Miscellaneous.h +++ b/src/MacVim/Miscellaneous.h @@ -51,6 +51,7 @@ extern NSString *MMUseInlineImKey; extern NSString *MMSuppressTerminationAlertKey; extern NSString *MMNativeFullScreenKey; extern NSString *MMUseMouseTimeKey; +extern NSString *MMFullScreenFadeTimeKey; // Enum for MMUntitledWindowKey diff --git a/src/MacVim/Miscellaneous.m b/src/MacVim/Miscellaneous.m index 8760ba5e56..bba9d280cf 100644 --- a/src/MacVim/Miscellaneous.m +++ b/src/MacVim/Miscellaneous.m @@ -47,6 +47,7 @@ NSString *MMUseInlineImKey = @"MMUseInlineIm"; NSString *MMSuppressTerminationAlertKey = @"MMSuppressTerminationAlert"; NSString *MMNativeFullScreenKey = @"MMNativeFullScreen"; NSString *MMUseMouseTimeKey = @"MMUseMouseTime"; +NSString *MMFullScreenFadeTimeKey = @"MMFullScreenFadeTime";