mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Avoid window flashing white when first shown
This only applies to the Core Text renderer.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -270,6 +270,7 @@
|
||||
// later).
|
||||
if (!setupDone) return;
|
||||
|
||||
[vimView markDirty];
|
||||
[[MMAppController sharedInstance] windowControllerWillOpen:self];
|
||||
[[self window] makeKeyAndOrderFront:self];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user