diff options
author | culler <culler> | 2024-06-22 02:29:26 (GMT) |
---|---|---|
committer | culler <culler> | 2024-06-22 02:29:26 (GMT) |
commit | cb90cb6add00df5bec77b2625f20b3302e3a48ed (patch) | |
tree | f0b89109b7a9863b8617ab53e36b983d39af017f /macosx | |
parent | 716977c2dc0bb759c929da0f34a0a20b4eb967ad (diff) | |
download | tk-cb90cb6add00df5bec77b2625f20b3302e3a48ed.zip tk-cb90cb6add00df5bec77b2625f20b3302e3a48ed.tar.gz tk-cb90cb6add00df5bec77b2625f20b3302e3a48ed.tar.bz2 |
Make setFrameSize a tiny bit more efficient.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 2c16cf8..6c3f07a 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -982,9 +982,9 @@ ConfigureRestrictProc( return YES; } - (void) updateLayer { - CGContextRef ctx = self.tkLayerBitmapContext; + CGContextRef context = self.tkLayerBitmapContext; - if (ctx) { + if (context) { /* * Create a CGImage by copying (probably using copy-on-write) the * bitmap data of the CGBitmapContext that we have been using for @@ -993,7 +993,8 @@ ConfigureRestrictProc( * layer. This will cause all drawing done since the last call to this * function to become visible. */ - CGImageRef newImg = CGBitmapContextCreateImage(ctx); + + CGImageRef newImg = CGBitmapContextCreateImage(context); self.layer.contents = (__bridge id) newImg; CGImageRelease(newImg); // will quickly leak memory if this is missing [self clearTkDirtyRect]; @@ -1032,19 +1033,24 @@ ConfigureRestrictProc( -(void) setFrameSize: (NSSize)newsize { + NSSize oldsize = self.bounds.size; [super setFrameSize: newsize]; + if (newsize.width == 1 && newsize.height == 1 || + oldsize.width == 0 && oldsize.height == 0) { + return; + } NSWindow *w = [self window]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window)winPtr; if (winPtr) { - unsigned int width = (unsigned int)newsize.width; - unsigned int height=(unsigned int)newsize.height; + unsigned int width = (unsigned int) newsize.width; + unsigned int height= (unsigned int) newsize.height; void *oldArg; Tk_RestrictProc *oldProc; /* - * This function can be re-entered. So we need to make sure we don't + * This function can be re-entered, so we need to make sure we don't * clobber any AutoreleasePool set up by the caller. */ @@ -1064,7 +1070,7 @@ ConfigureRestrictProc( /* * Update Tk's window data for the new size. */ - + if ([w respondsToSelector: @selector (tkLayoutChanged)]) { [(TKWindow *)w tkLayoutChanged]; } @@ -1079,7 +1085,7 @@ ConfigureRestrictProc( * In live resize we seem to need to draw a second time to * avoid artifacts. */ - + if ([self inLiveResize]) { [self generateExposeEvents:self.bounds]; } @@ -1093,11 +1099,10 @@ ConfigureRestrictProc( } /* - * Schedule a redisplay of the view. + * Request a call to updateLayer. */ [self setNeedsDisplay:YES]; - } /* |