Skip to content

Fix borderless (MMNoTitleBarWindow) mode in pre-Mojave renderers #828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/MacVim/MMCoreTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/MacVim/MMCoreTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,11 @@ - (void)setCGLayerEnabled:(BOOL)enabled
[self releaseCGLayer];
}

- (BOOL)getCGLayerEnabled
{
return cgLayerEnabled;
}

- (void)releaseCGLayer
{
if (cgLayer) {
Expand Down
3 changes: 3 additions & 0 deletions src/MacVim/MMFullScreenWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/MacVim/MMFullScreenWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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]];

Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/MacVim/MMTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@
- (void)deleteSign:(NSString *)signName;
- (void)setToolTipAtMousePoint:(NSString *)string;
- (void)setCGLayerEnabled:(BOOL)enabled;
- (BOOL)getCGLayerEnabled;
@end
5 changes: 5 additions & 0 deletions src/MacVim/MMTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,11 @@ - (void)setCGLayerEnabled:(BOOL)enabled
// ONLY in Core Text!
}

- (BOOL)getCGLayerEnabled
{
return NO;
}

- (BOOL)isOpaque
{
return NO;
Expand Down
9 changes: 9 additions & 0 deletions src/MacVim/MMWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down