From 45fc71df26e06074f33babae916d97880a80e9cb Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 23 Aug 2020 13:21:39 +0000 Subject: Fix [bc62f78191]: compilation issues when targeting older macOS versions. --- macosx/tkMacOSXColor.c | 26 +++++++++++++++----------- macosx/tkMacOSXWindowEvent.c | 10 ++++++---- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index e9dbfec..f9d2750 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -769,19 +769,23 @@ TkpGetColor( if (entry->type == semantic) { CGFloat rgba[4]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - NSAppearance *savedAppearance = [NSAppearance currentAppearance]; - NSAppearance *windowAppearance = savedAppearance; - if (view) { - windowAppearance = [view effectiveAppearance]; - } - if ([windowAppearance name] == NSAppearanceNameDarkAqua) { - colormap = darkColormap; + if (@available(macOS 10.14, *)) { + NSAppearance *savedAppearance = [NSAppearance currentAppearance]; + NSAppearance *windowAppearance = savedAppearance; + if (view) { + windowAppearance = [view effectiveAppearance]; + } + if ([windowAppearance name] == NSAppearanceNameDarkAqua) { + colormap = darkColormap; + } else { + colormap = lightColormap; + } + [NSAppearance setCurrentAppearance:windowAppearance]; + GetRGBA(entry, p.ulong, rgba); + [NSAppearance setCurrentAppearance:savedAppearance]; } else { - colormap = lightColormap; + GetRGBA(entry, p.ulong, rgba); } - [NSAppearance setCurrentAppearance:windowAppearance]; - GetRGBA(entry, p.ulong, rgba); - [NSAppearance setCurrentAppearance:savedAppearance]; #else GetRGBA(entry, p.ulong, rgba); #endif diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index acea6f0..e75858d 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -207,9 +207,9 @@ extern NSString *NSWindowDidOrderOffScreenNotification; TkWindow *winPtr = TkMacOSXGetTkWindow(window); if (winPtr) { TKContentView *view = [window contentView]; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - [view viewDidChangeEffectiveAppearance]; -#endif + if (@available(macOS 10.14, *)) { + [view viewDidChangeEffectiveAppearance]; + } [view addTkDirtyRect:[view bounds]]; Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL); Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); @@ -1142,7 +1142,9 @@ static const char *const accentNames[] = { { NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults]; if (object == preferences && [keyPath isEqualToString:@"AppleHighlightColor"]) { - [self viewDidChangeEffectiveAppearance]; + if (@available(macOS 10.14, *)) { + [self viewDidChangeEffectiveAppearance]; + } } } -- cgit v0.12 From 5fce3b6e1af2cae22198a50413ae9712e42422b9 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 24 Aug 2020 00:44:33 +0000 Subject: Use graphicsPort instead of CGContext if the minimum target is earlier than 10.10. --- macosx/tkMacOSXDraw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 24eb380..87bd90c 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -17,7 +17,7 @@ #include "tkMacOSXDebug.h" #include "tkButton.h" -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 #define GET_CGCONTEXT [[NSGraphicsContext currentContext] CGContext] #else #define GET_CGCONTEXT [[NSGraphicsContext currentContext] graphicsPort] -- cgit v0.12