Avoid window flashing white when first shown

This only applies to the Core Text renderer.
This commit is contained in:
Bjorn Winckler
2010-02-03 23:07:13 +01:00
parent 3c41769deb
commit 21d222a1d7
3 changed files with 27 additions and 0 deletions
+2
View File
@@ -26,6 +26,7 @@
MMTextView *textView;
NSMutableArray *scrollbars;
NSRect lastTextViewFrame;
BOOL isDirty;
}
- (MMVimView *)initWithFrame:(NSRect)frame vimController:(MMVimController *)c;
@@ -57,5 +58,6 @@
- (void)viewDidEndLiveResize;
- (void)setFrameSize:(NSSize)size;
- (void)setFrame:(NSRect)frame;
- (void)markDirty;
@end
+24
View File
@@ -191,6 +191,23 @@ enum {
- (void)drawRect:(NSRect)rect
{
if (isDirty) {
// Clear the entire view
CGContextRef ctx = [[NSGraphicsContext currentContext] graphicsPort];
NSRect rect = [self bounds];
NSColor *color = [textView defaultBackgroundColor];
CGContextSetBlendMode(ctx, kCGBlendModeCopy);
CGContextSetRGBFillColor(ctx,
[color redComponent],
[color greenComponent],
[color blueComponent],
[color alphaComponent]);
CGContextFillRect(ctx, *(CGRect*)&rect);
CGContextSetBlendMode(ctx, kCGBlendModeNormal);
isDirty = NO;
}
NSRect textViewFrame = [textView frame];
if (!NSEqualRects(lastTextViewFrame, textViewFrame)) {
// If the text view's frame changes we copy the contents of the old
@@ -627,6 +644,13 @@ enum {
[self frameSizeMayHaveChanged];
}
- (void)markDirty
{
// When the view is marked as dirty, the entire background will be cleared
// the next time the view is redrawn.
isDirty = YES;
}
@end // MMVimView
+1
View File
@@ -270,6 +270,7 @@
// later).
if (!setupDone) return;
[vimView markDirty];
[[MMAppController sharedInstance] windowControllerWillOpen:self];
[[self window] makeKeyAndOrderFront:self];
}