summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2021-11-01 12:46:24 (GMT)
committermarc_culler <marc.culler@gmail.com>2021-11-01 12:46:24 (GMT)
commitd51759484d268766e264c7e2c9588cedda2bb8d8 (patch)
treecbbb661e7595b0de6c765e4d9a11aa4f1b23b6ee
parent8bf0f1bae151317e296ee3cc7c43d05e0b46a130 (diff)
parentf5d2fbb546b28bcf15d7850e48f908f458641111 (diff)
downloadtk-d51759484d268766e264c7e2c9588cedda2bb8d8.zip
tk-d51759484d268766e264c7e2c9588cedda2bb8d8.tar.gz
tk-d51759484d268766e264c7e2c9588cedda2bb8d8.tar.bz2
Fix [178418e197]: work around the quirk that code compiled on macOS 10.XX and run on macOS 11 or 12 will report the host OS version as 10.16.
-rw-r--r--macosx/tkMacOSXColor.c2
-rw-r--r--macosx/tkMacOSXInit.c20
2 files changed, 21 insertions, 1 deletions
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index f82305e..edcd5d3 100644
--- a/macosx/tkMacOSXColor.c
+++ b/macosx/tkMacOSXColor.c
@@ -326,7 +326,7 @@ GetRGBA(
#endif
} else if (entry->index == selectedTabTextIndex) {
int OSVersion = [NSApp macOSVersion];
- if (OSVersion > 100600 && OSVersion < 101600) {
+ if (OSVersion > 100600 && OSVersion < 110000) {
color = [[NSColor whiteColor] colorUsingColorSpace:sRGB];
} else {
color = [[NSColor textColor] colorUsingColorSpace:sRGB];
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 440383f..bd0199a 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -17,6 +17,7 @@
#include <dlfcn.h>
#include <objc/objc-auto.h>
#include <sys/stat.h>
+#include <sys/utsname.h>
static char tkLibPath[PATH_MAX + 1] = "";
@@ -188,6 +189,7 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
*/
int minorVersion, majorVersion;
+
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000
Gestalt(gestaltSystemVersionMinor, (SInt32*)&minorVersion);
majorVersion = 10;
@@ -197,6 +199,24 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
majorVersion = systemVersion.majorVersion;
minorVersion = systemVersion.minorVersion;
#endif
+
+ if (majorVersion == 10 && minorVersion == 16) {
+
+ /*
+ * If a program compiled with a macOS 10.XX SDK is run on macOS 11.0 or
+ * later then it will report majorVersion 10 and minorVersion 16, no
+ * matter what the actual OS version of the host may be. And of course
+ * Apple never released macOS 10.16. To work around this we guess the
+ * OS version from the kernel release number, as reported by uname.
+ */
+
+ struct utsname name;
+ char *endptr;
+ if (uname(&name) == 0) {
+ majorVersion = strtol(name.release, &endptr, 10) - 9;
+ minorVersion = 0;
+ }
+ }
[NSApp setMacOSVersion: 10000*majorVersion + 100*minorVersion];
/*