From 516dfe38de8777526bfbfa12814b2fbdb8e91018 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Sat, 13 Sep 2008 00:30:07 +0200 Subject: [PATCH] Be more conservative about flushing output queue Don't flush on gui_mch_flush(); instead only flush when forced (happens e.g. if Vim is about to take a nap) or just before waiting for new input. This reduces screen flicker dramatically in certain cases. --- src/MacVim/MMBackend.h | 1 - src/MacVim/MMBackend.m | 18 ------------------ src/MacVim/gui_macvim.m | 6 ++++-- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/MacVim/MMBackend.h b/src/MacVim/MMBackend.h index f0560263..df7d1b32 100644 --- a/src/MacVim/MMBackend.h +++ b/src/MacVim/MMBackend.h @@ -31,7 +31,6 @@ unsigned specialColor; unsigned defaultBackgroundColor; unsigned defaultForegroundColor; - NSDate *lastFlushDate; id dialogReturn; NSTimer *blinkTimer; int blinkState; diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 2847fdcf..1c21b126 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -44,13 +44,6 @@ #define WIN_VER 2 // "-O" vertically split windows #define WIN_TABS 3 // "-p" windows on tab pages -// This constant controls how often the command queue may be flushed. If it is -// too small the app might feel unresponsive; if it is too large there might be -// long periods without the screen updating (e.g. when sourcing a large session -// file). (The unit is seconds.) -static float MMFlushTimeoutInterval = 0.1f; -static int MMFlushQueueLenHint = 80*40; - static unsigned MMServerMax = 1000; // TODO: Move to separate file. @@ -487,14 +480,6 @@ static NSString *MMSymlinkWarningString = // NO. if (flushDisabled) return; - // NOTE! This method gets called a lot; if we were to flush every time it - // got called MacVim would feel unresponsive. So there is a time out which - // ensures that the queue isn't flushed too often. - if (!force && lastFlushDate - && -[lastFlushDate timeIntervalSinceNow] < MMFlushTimeoutInterval - && [drawData length] < MMFlushQueueLenHint) - return; - if ([drawData length] > 0) { // HACK! Detect changes to 'guifontwide'. if (gui.wide_font != (GuiFont)oldWideFont) { @@ -523,9 +508,6 @@ static NSString *MMSymlinkWarningString = } [outputQueue removeAllObjects]; - - [lastFlushDate release]; - lastFlushDate = [[NSDate date] retain]; } } diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index 5e0ae5a9..990a07d2 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -225,12 +225,14 @@ gui_mch_update(void) void gui_mch_flush(void) { - [[MMBackend sharedInstance] flushQueue:NO]; + // This function is called way too often to be useful as a hint for + // flushing. If we were to flush every time it was called the screen would + // flicker. } /* Force flush output to MacVim. Do not call this method unless absolutely - * necessary (use gui_mch_flush() instead). */ + * necessary. */ void gui_macvim_force_flush(void) { -- 2.11.4.GIT