From e3f627385b02a29326439ffe0159930466944f6a Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 24 Apr 2021 19:47:30 +0000 Subject: Possibly a genuine fix - use an explicit CALayer for the TKContentView. --- macosx/tkMacOSXNotify.c | 7 ++++--- macosx/tkMacOSXPrivate.h | 1 + macosx/tkMacOSXWindowEvent.c | 32 ++++++++++++++++++++++++++++++++ unix/configure | 2 +- unix/configure.in | 2 +- 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index f32fa76..0438525 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -340,8 +340,9 @@ TkMacOSXNotifyExitHandler( * for all views that need display before it returns. We call it with * deQueue=NO so that it will not change anything on the AppKit event * queue, because we only want the side effect that it runs drawRect. The - * only time when any NSViews have the needsDisplay property set to YES - * is during execution of this function. + * only times when any NSViews have the needsDisplay property set to YES + * are during execution of this function or in the addDirtyRect method + * of TKContentView. * * The reason for running this function as an idle task is to try to * arrange that all widgets will be fully configured before they are @@ -377,7 +378,7 @@ TkMacOSXDrawAllViews( if (dirtyCount) { continue; } - [view setNeedsDisplayInRect:[view tkDirtyRect]]; + [[view layer] setNeedsDisplayInRect:[view tkDirtyRect]]; } } else { [window displayIfNeeded]; diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 29e7c53..be2264f 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -27,6 +27,7 @@ #define TextStyle MacTextStyle #import #import +#import #ifndef NO_CARBON_H #import #endif diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 0075fb8..b6b58d8 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -915,11 +915,43 @@ ConfigureRestrictProc( @implementation TKContentView(TKWindowEvent) +- (id)initWithFrame:(NSRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + /* + * The layer must exist before we set wantsLayer to YES. + */ + + self.layer = [CALayer layer]; + self.wantsLayer = YES; + self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawOnSetNeedsDisplay; + + /* + * Nothing gets drawn at all if the layer does not have a delegate. + * Currently, we do not implement any methods of the delegate, however. + */ + + self.layer.delegate = (id) self; + } + return self; +} + +/* + * We will just use drawRect. + */ + +- (BOOL) wantsUpdateLayer +{ + return NO; +} + - (void) addTkDirtyRect: (NSRect) rect { _tkNeedsDisplay = YES; _tkDirtyRect = NSUnionRect(_tkDirtyRect, rect); [NSApp setNeedsToDraw:YES]; + [self setNeedsDisplay:YES]; } - (void) clearTkDirtyRect diff --git a/unix/configure b/unix/configure index 45c215e..691d43b 100755 --- a/unix/configure +++ b/unix/configure @@ -9385,7 +9385,7 @@ cat >>confdefs.h <<\_ACEOF #define MAC_OSX_TK 1 _ACEOF - LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit" + LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit -framework QuartzCore" EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c' TK_WINDOWINGSYSTEM=AQUA if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then diff --git a/unix/configure.in b/unix/configure.in index 78dd688..9720b91 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -354,7 +354,7 @@ fi if test $tk_aqua = yes; then AC_DEFINE(MAC_OSX_TK, 1, [Are we building TkAqua?]) - LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit" + LIBS="$LIBS -framework Cocoa -framework Carbon -framework IOKit -framework QuartzCore" EXTRA_CC_SWITCHES='-std=gnu99 -x objective-c' TK_WINDOWINGSYSTEM=AQUA if test -n "${enable_symbols}" -a "${enable_symbols}" != no; then -- cgit v0.12