diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index db2f9fb8d7..2d93266484 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -1914,6 +1914,11 @@ fsEventCallback(ConstFSEventStreamRef streamRef, [cachedVimControllers removeObjectAtIndex:0]; [vc setIsPreloading:NO]; + // If the Vim process has finished loading then the window will displayed + // now, otherwise it will be displayed when the OpenWindowMsgID message is + // received. + [[vc windowController] presentWindow:nil]; + // Since we've taken one controller from the cache we take the opportunity // to preload another. [self scheduleVimControllerPreloadAfterDelay:1]; diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index bf5b58a8ba..416ba42cbe 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -473,6 +473,9 @@ extern GuiFont gui_mch_retain_font(GuiFont font); [self queueMessage:OpenWindowMsgID data:nil]; + // HACK: Clear window immediately upon opening to avoid it flashing white. + [self clearAll]; + return YES; } diff --git a/src/MacVim/MMVimController.h b/src/MacVim/MMVimController.h index 622234eac5..982d2d2ae8 100644 --- a/src/MacVim/MMVimController.h +++ b/src/MacVim/MMVimController.h @@ -41,7 +41,6 @@ #endif BOOL isPreloading; NSDate *creationDate; - BOOL windowHasBeenPresented; } - (id)initWithBackend:(id)backend pid:(int)processIdentifier; diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index 9d8de09c81..b66b4cf601 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -548,14 +548,17 @@ static BOOL isUnsafeMessage(int msgid); { if (OpenWindowMsgID == msgid) { [windowController openWindow]; + + // HACK: Delay actually presenting the window onscreen until after + // processing the queue since it contains drawing commands that need to + // be issued before presentation; otherwise the window may flash white + // just as it opens. + if (!isPreloading) + [windowController performSelector:@selector(presentWindow:) + withObject:nil + afterDelay:0]; } else if (BatchDrawMsgID == msgid) { [[[windowController vimView] textView] performBatchDrawWithData:data]; - - // HACK! In order to avoid the window flashing white on startup we take - // care to only present the window on screen once something has been - // drawn to it. - if (!windowHasBeenPresented) - windowHasBeenPresented = [windowController presentWindow]; } else if (SelectTabMsgID == msgid) { #if 0 // NOTE: Tab selection is done inside updateTabsWithData:. const void *bytes = [data bytes]; diff --git a/src/MacVim/MMWindowController.h b/src/MacVim/MMWindowController.h index eec3045288..1961cecb1b 100644 --- a/src/MacVim/MMWindowController.h +++ b/src/MacVim/MMWindowController.h @@ -48,7 +48,7 @@ - (void)setWindowAutosaveKey:(NSString *)key; - (void)cleanup; - (void)openWindow; -- (BOOL)presentWindow; +- (BOOL)presentWindow:(id)unused; - (void)updateTabsWithData:(NSData *)data; - (void)selectTabWithIndex:(int)idx; - (void)setTextDimensionsWithRows:(int)rows columns:(int)cols isLive:(BOOL)live diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index 26abdbb94e..e4f1ba7368 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -263,7 +263,7 @@ keepOnScreen:YES]; } -- (BOOL)presentWindow +- (BOOL)presentWindow:(id)unused { // Actually show the window on screen. However, if openWindow hasn't // already been called nothing will happen (the window will be displayed