From 0f30f6151e25bcdfd7390ce79236deb8df7920cb Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Wed, 3 Feb 2010 14:46:56 +0100 Subject: [PATCH] Fix vert split problems in Core Text renderer The display is no longer corrupted on :vsp when using the Core Text renderer. Also fixes a problem where background would not be cleared correctly when left scrollbar was visible. Remove a hack in live resizing code when using CT. This may cause the window to flicker more during live resize (have to find a better fix). --- src/MacVim/MMCoreTextView.h | 2 -- src/MacVim/MMCoreTextView.m | 27 ++++++--------------------- src/MacVim/MMVimView.h | 1 + src/MacVim/MMVimView.m | 13 ++++++++++++- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/MacVim/MMCoreTextView.h b/src/MacVim/MMCoreTextView.h index babbd3b8..aba94238 100644 --- a/src/MacVim/MMCoreTextView.h +++ b/src/MacVim/MMCoreTextView.h @@ -37,8 +37,6 @@ unsigned maxlen; CGGlyph *glyphs; CGSize *advances; - - NSRect lastClearRect; } - (id)initWithFrame:(NSRect)frame; diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index 0acb42bb..9b27650b 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -567,21 +567,6 @@ defaultAdvanceForFont(CTFontRef fontRef) NSGraphicsContext *context = [NSGraphicsContext currentContext]; [context setShouldAntialias:antialias]; - NSRect frame = [self frame]; - if (!NSEqualRects(lastClearRect, frame)) { - // HACK! If the view frame changes then clear the entire frame - // otherwise the screen flickers e.g. when the window is resized. -#if 1 - [self clearAll]; -#else - float y = frame.size.height - lastClearRect.size.height; - if (y > 0 && y < frame.size.height) { - NSCopyBits(0, lastClearRect, NSMakePoint(0, y)); - } -#endif - lastClearRect = frame; - } - id data; NSEnumerator *e = [drawData objectEnumerator]; while ((data = [e nextObject])) @@ -726,7 +711,7 @@ defaultAdvanceForFont(CTFontRef fontRef) // View is not flipped, instead the atsui code draws to a flipped image; // thus we need to 'flip' the coordinate here since the column number // increases in an up-to-down order. - point.y = [self frame].size.height - point.y; + point.y = [self bounds].size.height - point.y; NSPoint origin = { insetSize.width, insetSize.height }; @@ -801,7 +786,7 @@ defaultAdvanceForFont(CTFontRef fontRef) - (NSPoint)pointForRow:(int)row column:(int)col { - NSRect frame = [self frame]; + NSRect frame = [self bounds]; return NSMakePoint( col*cellSize.width + insetSize.width, frame.size.height - (row+1)*cellSize.height - insetSize.height); @@ -811,7 +796,7 @@ defaultAdvanceForFont(CTFontRef fontRef) numColumns:(int)nc { NSRect rect; - NSRect frame = [self frame]; + NSRect frame = [self bounds]; rect.origin.x = col*cellSize.width + insetSize.width; rect.origin.y = frame.size.height - (row+nr)*cellSize.height - @@ -825,7 +810,7 @@ defaultAdvanceForFont(CTFontRef fontRef) - (NSRect)rectFromRow:(int)row1 column:(int)col1 toRow:(int)row2 column:(int)col2 { - NSRect frame = [self frame]; + NSRect frame = [self bounds]; return NSMakeRect( insetSize.width + col1*cellSize.width, frame.size.height - insetSize.height - (row2+1)*cellSize.height, @@ -1069,7 +1054,7 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGSize *advances, backgroundColor:(int)bg specialColor:(int)sp { CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; - NSRect frame = [self frame]; + NSRect frame = [self bounds]; float x = col*cellSize.width + insetSize.width; float y = frame.size.height - insetSize.height - (1+row)*cellSize.height; float w = cellSize.width; @@ -1232,7 +1217,7 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGSize *advances, - (void)clearAll { CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; - NSRect rect = [self frame]; + NSRect rect = [self bounds]; float r = [defaultBackgroundColor redComponent]; float g = [defaultBackgroundColor greenComponent]; float b = [defaultBackgroundColor blueComponent]; diff --git a/src/MacVim/MMVimView.h b/src/MacVim/MMVimView.h index 5a8335ed..12c3a49c 100644 --- a/src/MacVim/MMVimView.h +++ b/src/MacVim/MMVimView.h @@ -25,6 +25,7 @@ BOOL vimTaskSelectedTab; MMTextView *textView; NSMutableArray *scrollbars; + NSRect lastTextViewFrame; } - (MMVimView *)initWithFrame:(NSRect)frame vimController:(MMVimController *)c; diff --git a/src/MacVim/MMVimView.m b/src/MacVim/MMVimView.m index a4112ef7..14aed802 100644 --- a/src/MacVim/MMVimView.m +++ b/src/MacVim/MMVimView.m @@ -191,6 +191,17 @@ enum { - (void)drawRect:(NSRect)rect { + NSRect textViewFrame = [textView frame]; + if (!NSEqualRects(lastTextViewFrame, textViewFrame)) { + // If the text view's frame changes we copy the contents of the old + // frame to the origin of the new frame. The reason for this is that + // Vim expects the contents of its view not to change unless Vim + // changes it. (Omitting this code causes the view contents to get + // messed up e.g. when the left scrollbar is shown.) + NSCopyBits(0, lastTextViewFrame, textViewFrame.origin); + lastTextViewFrame = textViewFrame; + } + // On Leopard, we want to have a textured window background for nice // looking tabs. However, the textured window background looks really // weird behind the window resize throbber, so emulate the look of an @@ -224,7 +235,7 @@ enum { // If the left scrollbar is visible there is an empty square under it. // Fill it in just like on the right hand corner. The half pixel // offset ensures the outline goes on the top and right side of the - // square; the left and bottom parts are clipped. + // square; the left and bottom parts of the outline are clipped. sizerRect = NSMakeRect(-.5,-.5,sw,sw); path = [NSBezierPath bezierPathWithRect:sizerRect]; [[NSColor controlBackgroundColor] set]; -- 2.11.4.GIT