From b6bc72b09dade18dfc0fa32640db907a27c2ddee Mon Sep 17 00:00:00 2001 From: Yee Cheng Chin Date: Mon, 10 Dec 2018 01:01:27 -0800 Subject: [PATCH] Fix starting up in non-native fullscreen resulting in black screen Fix issues related to starting up in fullscreen mode (by setting `set fullscreen` in gvimrc). Fix black screen when starting in non-native fullscreen: - Fix #804 - Non-native fullscreen has an old behavior where it sets CGLayer mode on core text renderer to address rendering artifacts in pre-Mojave, and we have an insufficient block against it (by checking cgContext). In Mojave, we use buffered draws instead and prevent setting CGLayer by checking cgContext, but it is not yet initialized yet in this situation (since it's lazily initialized). Block against cgBufferDrawEnabled instead. - The CGLayer renderer is really deprecated at this point so ideally we could clean up the code a little bit in the future. Setting MMUseCGLayerAlways no longer results in black screen: - Fix #801 - CGLayer renderer is basically deprecated doesn't actually work in Mojave. Make sure setting MMUseCGLayerAlways won't trigger it if we are already using buffered draw (which is automatically the case in Mojave). Fix starting up in fullscreen resulting in a small Vim window: - When starting MacVim in fullscreen mode, the presentation is delayed until the window is made. need to make sure to set shouldResizeVimView in this code path too. Before the guioption-k fixes, there were a lot of random calls to recalculate sizes which was why this happened implicitly. Now need to make sure we do the right thing and call it. --- src/MacVim/MMCoreTextView.m | 11 ++++++++--- src/MacVim/MMWindowController.m | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index 159e4dc388..9b2a4ecaa9 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -137,8 +137,13 @@ - (id)initWithFrame:(NSRect)frame boolForKey:MMBufferedDrawingKey]; cgBufferDrawNeedsUpdateContext = NO; - cgLayerEnabled = [[NSUserDefaults standardUserDefaults] - boolForKey:MMUseCGLayerAlwaysKey]; + cgLayerEnabled = NO; + if (!cgBufferDrawEnabled) { + // Buffered draw supercedes the CGLayer renderer, which is deprecated + // and doesn't actually work in 10.14+. + cgLayerEnabled = [[NSUserDefaults standardUserDefaults] + boolForKey:MMUseCGLayerAlwaysKey]; + } cgLayerLock = [NSLock new]; // NOTE! It does not matter which font is set here, Vim will set its @@ -795,7 +800,7 @@ - (void)performBatchDrawWithData:(NSData *)data - (void)setCGLayerEnabled:(BOOL)enabled { - if (cgContext) + if (cgContext || cgBufferDrawEnabled) return; cgLayerEnabled = enabled; diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index 19e72bd96b..9e2bcf4e1d 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -348,6 +348,7 @@ - (BOOL)presentWindow:(id)unused // GUIEnter auto command could cause this). [fullScreenWindow enterFullScreen]; fullScreenEnabled = YES; + shouldResizeVimView = YES; } else if (delayEnterFullScreen) { // Set alpha to zero so that the decorated window doesn't pop up // before we enter full-screen.