diff --git a/src/MacVim/MMCoreTextView.h b/src/MacVim/MMCoreTextView.h index cfabfa66bd..4f79f42919 100644 --- a/src/MacVim/MMCoreTextView.h +++ b/src/MacVim/MMCoreTextView.h @@ -114,6 +114,7 @@ - (NSRect)rectForRow:(int)row column:(int)column numRows:(int)nr numColumns:(int)nc; - (void)setCGLayerEnabled:(BOOL)enabled; +- (BOOL)getCGLayerEnabled; // // NSTextView methods diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index 9b2a4ecaa9..0510d68842 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -809,6 +809,11 @@ - (void)setCGLayerEnabled:(BOOL)enabled [self releaseCGLayer]; } +- (BOOL)getCGLayerEnabled +{ + return cgLayerEnabled; +} + - (void)releaseCGLayer { if (cgLayer) { diff --git a/src/MacVim/MMFullScreenWindow.h b/src/MacVim/MMFullScreenWindow.h index 629570c40c..02b00f2150 100644 --- a/src/MacVim/MMFullScreenWindow.h +++ b/src/MacVim/MMFullScreenWindow.h @@ -34,6 +34,9 @@ // Controls the speed of the fade in and out. double fadeTime; double fadeReservationTime; + + // For pre-10.14 we manually sets CGLayer mode, so need to remember the original state + BOOL origCGLayerEnabled; } - (MMFullScreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v diff --git a/src/MacVim/MMFullScreenWindow.m b/src/MacVim/MMFullScreenWindow.m index 2616414e08..23e465ea8c 100644 --- a/src/MacVim/MMFullScreenWindow.m +++ b/src/MacVim/MMFullScreenWindow.m @@ -113,6 +113,8 @@ - (MMFullScreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v fadeTime = MIN(fadeTime, 0.5 * (kCGMaxDisplayReservationInterval - 1)); fadeReservationTime = 2.0 * fadeTime + 1; + origCGLayerEnabled = NO; + return self; } @@ -172,8 +174,11 @@ - (void)enterFullScreen oldPosition = [view frame].origin; [view removeFromSuperviewWithoutNeedingDisplay]; - if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) + if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) { + // This shouldn't do much in 10.14+. + origCGLayerEnabled = [[view textView] getCGLayerEnabled]; [[view textView] setCGLayerEnabled:YES]; + } [[self contentView] addSubview:view]; [self setInitialFirstResponder:[view textView]]; @@ -289,7 +294,7 @@ - (void)leaveFullScreen [self close]; if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) - [[view textView] setCGLayerEnabled:NO]; + [[view textView] setCGLayerEnabled:origCGLayerEnabled]; // Set the text view to initial first responder, otherwise the 'plus' // button on the tabline steals the first responder status. diff --git a/src/MacVim/MMTextView.h b/src/MacVim/MMTextView.h index 6938dc97fa..43e808fe69 100644 --- a/src/MacVim/MMTextView.h +++ b/src/MacVim/MMTextView.h @@ -74,4 +74,5 @@ - (void)deleteSign:(NSString *)signName; - (void)setToolTipAtMousePoint:(NSString *)string; - (void)setCGLayerEnabled:(BOOL)enabled; +- (BOOL)getCGLayerEnabled; @end diff --git a/src/MacVim/MMTextView.m b/src/MacVim/MMTextView.m index 2b7dbca6f9..bdb73725ca 100644 --- a/src/MacVim/MMTextView.m +++ b/src/MacVim/MMTextView.m @@ -527,6 +527,11 @@ - (void)setCGLayerEnabled:(BOOL)enabled // ONLY in Core Text! } +- (BOOL)getCGLayerEnabled +{ + return NO; +} + - (BOOL)isOpaque { return NO; diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index 2d72d2d0a3..7d2b6fe276 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -200,6 +200,15 @@ - (id)initWithVimController:(MMVimController *)controller // Make us safe on pre-tiger OSX if ([win respondsToSelector:@selector(_setContentHasShadow:)]) [win _setContentHasShadow:NO]; + + if (!(styleMask & NSWindowStyleMaskTitled)) { + // In the no titlebar mode (aka borderless), we need to set CGLayer + // mode since otherwise the legacy renderer would not render properly. + // For more reference see MMFullscreenWindow's enterFullscreen: + // This shouldn't do much in 10.14+. + if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) + [[vimView textView] setCGLayerEnabled:YES]; + } #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) // Building on Mac OS X 10.7 or greater.