From 89f5a6802f0e3aa56d0f612913683dc432646bd0 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 25 Jun 2020 21:12:33 +0000 Subject: Aqua: replace [NSApp macMinorVersion] by [NSApp macOSVersion] event though the Big Sur (11.1) beta release identifies itself as 10.16. --- macosx/tkMacOSXButton.c | 4 ++-- macosx/tkMacOSXColor.c | 12 ++++++------ macosx/tkMacOSXDialog.c | 2 +- macosx/tkMacOSXInit.c | 10 +++++++--- macosx/tkMacOSXMenus.c | 2 +- macosx/tkMacOSXMouseEvent.c | 2 +- macosx/tkMacOSXPrivate.h | 4 ++-- macosx/tkMacOSXScrlbr.c | 4 ++-- macosx/tkMacOSXTest.c | 2 +- macosx/tkMacOSXWindowEvent.c | 2 +- macosx/tkMacOSXWm.c | 12 ++++++------ macosx/ttkMacOSXTheme.c | 32 ++++++++++++++++---------------- 12 files changed, 46 insertions(+), 42 deletions(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 721dd03..5aa8f7d 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -397,7 +397,7 @@ TkpComputeButtonGeometry( width += butPtr->inset*2; height += butPtr->inset*2; - if ([NSApp macMinorVersion] == 6) { + if ([NSApp macOSVersion] == 100600) { width += 12; } if (mbPtr->btnkind == kThemePushButton) { @@ -1052,7 +1052,7 @@ TkMacOSXComputeButtonParams( * the button periodically. */ - if (!mbPtr->defaultPulseHandler && ([NSApp macMinorVersion] <= 9)) { + if (!mbPtr->defaultPulseHandler && ([NSApp macOSVersion] <= 100900)) { mbPtr->defaultPulseHandler = Tcl_CreateTimerHandler( PULSE_TIMER_MSECS, PulseDefaultButtonProc, butPtr); } diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 7694b1d..5b59b58 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -308,7 +308,7 @@ SetCGColorComponents( * windowBackGroundColor. */ - if ([NSApp macMinorVersion] < 14) { + if ([NSApp macOSVersion] < 101400) { for (int i=0; i<3; i++) { rgba[i] = windowBackground[i]; } @@ -335,7 +335,7 @@ SetCGColorComponents( color = [[NSColor selectedTextColor] colorUsingColorSpace:sRGB]; break; case 2: - if ([NSApp macMinorVersion] > 9) { + if ([NSApp macOSVersion] > 100900) { #if MAC_OS_X_VERSION_MAX_ALLOWED > 1090 color = [[NSColor labelColor] colorUsingColorSpace:sRGB]; #endif @@ -351,7 +351,7 @@ SetCGColorComponents( colorUsingColorSpace:sRGB]; break; case 5: - if ([NSApp macMinorVersion] > 6) { + if ([NSApp macOSVersion] > 100600) { color = [[NSColor whiteColor] colorUsingColorSpace:sRGB]; } else { color = [[NSColor blackColor] colorUsingColorSpace:sRGB]; @@ -378,7 +378,7 @@ SetCGColorComponents( } break; case 9: - if ([NSApp macMinorVersion] >= 10) { + if ([NSApp macOSVersion] >= 101000) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 color = [[NSColor linkColor] colorUsingColorSpace:sRGB]; #endif @@ -387,7 +387,7 @@ SetCGColorComponents( } break; default: - if ([NSApp macMinorVersion] >= 10) { + if ([NSApp macOSVersion] >= 101000) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 color = [[NSColor labelColor] colorUsingColorSpace:sRGB]; #endif @@ -442,7 +442,7 @@ TkMacOSXInDarkMode(Tk_Window tkwin) #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 static NSAppearanceName darkAqua = @"NSAppearanceNameDarkAqua"; - if ([NSApp macMinorVersion] >= 14) { + if ([NSApp macOSVersion] >= 101400) { TkWindow *winPtr = (TkWindow*) tkwin; NSView *view = nil; if (winPtr && winPtr->privatePtr) { diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 76bb742..ceaa2ac 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -725,7 +725,7 @@ Tk_GetOpenFileObjCmd( * panel. Prepend the title to the message in this case. */ - if ([NSApp macMinorVersion] > 10) { + if ([NSApp macOSVersion] > 101000) { if (message) { NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@", title, message]; diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index e806b24..ab5b2ec 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -32,7 +32,7 @@ static char scriptPath[PATH_MAX + 1] = ""; @implementation TKApplication @synthesize poolLock = _poolLock; -@synthesize macMinorVersion = _macMinorVersion; +@synthesize macOSVersion = _macOSVersion; @synthesize isDrawing = _isDrawing; @end @@ -154,15 +154,19 @@ static char scriptPath[PATH_MAX + 1] = ""; /* * Record the OS version we are running on. */ - int minorVersion; + + int minorVersion, majorVersion; #if MAC_OS_X_VERSION_MAX_ALLOWED < 101000 Gestalt(gestaltSystemVersionMinor, (SInt32*)&minorVersion); + majorVersion = 10; #else NSOperatingSystemVersion systemVersion; systemVersion = [[NSProcessInfo processInfo] operatingSystemVersion]; + majorVersion = systemVersion.majorVersion; minorVersion = systemVersion.minorVersion; #endif - [NSApp setMacMinorVersion: minorVersion]; + printf("Major: %d; Minor: %d\n", majorVersion, minorVersion); + [NSApp setMacOSVersion: 10000*majorVersion + 100*minorVersion]; /* * We are not drawing right now. diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index 1c033a4..9b85e7a 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.c @@ -112,7 +112,7 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp); * On OS X 10.12 we get duplicate tab control items if we create them here. */ - if ([NSApp macMinorVersion] > 12) { + if ([NSApp macOSVersion] > 101200) { _defaultWindowsMenuItems = [_defaultWindowsMenuItems arrayByAddingObjectsFromArray: [NSArray arrayWithObjects: diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 435caf9..e457a96 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -105,7 +105,7 @@ enum { if (eventType == NSLeftMouseDown && ([eventWindow styleMask] & NSResizableWindowMask) && - [NSApp macMinorVersion] > 6) { + [NSApp macOSVersion] > 100600) { NSRect frame = [eventWindow frame]; if (local.x < 3 || local.x > frame.size.width - 3 || local.y < 3) { return theEvent; diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index be69fcd..1266c8b 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -340,12 +340,12 @@ VISIBILITY_HIDDEN #ifdef __i386__ /* The Objective C runtime used on i386 requires this. */ int _poolLock; - int _macMinorVersion; + int _macOSVersion; /* 10000 * major + 100*minor */ Bool _isDrawing; #endif } @property int poolLock; -@property int macMinorVersion; +@property int macOSVersion; @property Bool isDrawing; @end diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index dff6cc9..8bf2998 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -316,7 +316,7 @@ TkpDisplayScrollbar( if (SNOW_LEOPARD_STYLE) { HIThemeDrawTrack(&msPtr->info, 0, dc.context, kHIThemeOrientationInverted); - } else if ([NSApp macMinorVersion] <= 8) { + } else if ([NSApp macOSVersion] <= 100800) { HIThemeDrawTrack(&msPtr->info, 0, dc.context, kHIThemeOrientationNormal); } else { @@ -377,7 +377,7 @@ TkpComputeScrollbarGeometry( scrollPtr->highlightWidth = 0; } scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth; - if ([NSApp macMinorVersion] == 6) { + if ([NSApp macOSVersion] == 100600) { scrollPtr->arrowLength = scrollPtr->width; } else { scrollPtr->arrowLength = 0; diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 0a739a1..a5d1d83 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -119,7 +119,7 @@ DebuggerObjCmd( */ MODULE_SCOPE Bool TkTestLogDisplay(void) { - if ([NSApp macMinorVersion] >= 14) { + if ([NSApp macOSVersion] >= 101400) { return [NSApp isDrawing]; } else { return ![NSApp isDrawing]; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index ee49541..61b647e 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -966,7 +966,7 @@ RedisplayView( */ if ([NSApp isDrawing]) { - if ([NSApp macMinorVersion] > 13) { + if ([NSApp macOSVersion] > 101300) { TKLog(@"WARNING: a recursive call to drawRect was aborted."); } return; diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index cab2b9a..d7df594 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -5585,7 +5585,7 @@ TkUnsupported1ObjCmd( } return WmWinStyle(interp, winPtr, objc, objv); case TKMWS_TABID: - if ([NSApp macMinorVersion] < 12) { + if ([NSApp macOSVersion] < 101200) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Tabbing identifiers did not exist until OSX 10.12.", -1)); Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "TABBINGID", NULL); @@ -5597,7 +5597,7 @@ TkUnsupported1ObjCmd( } return WmWinTabbingId(interp, winPtr, objc, objv); case TKMWS_APPEARANCE: - if ([NSApp macMinorVersion] < 9) { + if ([NSApp macOSVersion] < 100900) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Window appearances did not exist until OSX 10.9.", -1)); Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "APPEARANCE", NULL); @@ -5607,7 +5607,7 @@ TkUnsupported1ObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "window ?appearancename?"); return TCL_ERROR; } - if (objc == 4 && [NSApp macMinorVersion] < 14) { + if (objc == 4 && [NSApp macOSVersion] < 101400) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Window appearances cannot be changed before OSX 10.14.", -1)); @@ -6886,7 +6886,7 @@ ApplyWindowAttributeFlagChanges( * window. To work around this we make the max size equal * to the screen size. (For 10.11 and up, only) */ - if ([NSApp macMinorVersion] > 10) { + if ([NSApp macOSVersion] > 101000) { [macWindow setMaxFullScreenContentSize:screenSize]; } } @@ -6970,7 +6970,7 @@ ApplyMasterOverrideChanges( wmPtr->attributes = macClassAttrs[kSimpleWindowClass].defaultAttrs; } wmPtr->attributes |= kWindowNoActivatesAttribute; - if ([NSApp macMinorVersion] == 6) { + if ([NSApp macOSVersion] == 100600) { styleMask = 0; } else { styleMask &= ~NSTitledWindowMask; @@ -6983,7 +6983,7 @@ ApplyMasterOverrideChanges( macClassAttrs[kDocumentWindowClass].defaultAttrs; } wmPtr->attributes &= ~kWindowNoActivatesAttribute; - if ([NSApp macMinorVersion] == 6) { + if ([NSApp macOSVersion] == 100600) { styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 7e8377e..f1b7b8e 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -269,7 +269,7 @@ static void GetBackgroundColor( rgba[i] = masterPtr->privatePtr->fillRGBA[i]; } } else { - if ([NSApp macMinorVersion] > 13) { + if ([NSApp macOSVersion] > 101300) { NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *windowColor = [[NSColor windowBackgroundColor] colorUsingColorSpace: deviceRGB]; @@ -1409,7 +1409,7 @@ static void ButtonElementDraw( } else if (info.kind == kThemePushButton && (state & TTK_STATE_PRESSED)) { bounds.size.height += 2; - if ([NSApp macMinorVersion] > 8) { + if ([NSApp macOSVersion] > 100800) { GradientFillRoundedRectangle(dc.context, bounds, 4, pressedPushButtonGradient, 2); } @@ -1603,7 +1603,7 @@ static void PaneElementDraw( bounds.origin.y -= kThemeMetricTabFrameOverlap; bounds.size.height += kThemeMetricTabFrameOverlap; BEGIN_DRAWING(d) - if ([NSApp macMinorVersion] > 8) { + if ([NSApp macOSVersion] > 100800) { DrawGroupBox(bounds, dc.context, tkwin); } else { HIThemeTabPaneDrawInfo info = { @@ -1662,7 +1662,7 @@ static void GroupElementDraw( CGRect bounds = BoxToRect(d, b); BEGIN_DRAWING(d) - if ([NSApp macMinorVersion] > 8) { + if ([NSApp macOSVersion] > 100800) { DrawGroupBox(bounds, dc.context, tkwin); } else { const HIThemeGroupBoxDrawInfo info = { @@ -1785,7 +1785,7 @@ static void EntryElementDraw( } BEGIN_DRAWING(d) if (backgroundPtr == NULL) { - if ([NSApp macMinorVersion] > 8) { + if ([NSApp macOSVersion] > 100800) { background = [NSColor textBackgroundColor]; CGContextSetFillColorWithColor(dc.context, CGCOLOR(background)); } else { @@ -1863,7 +1863,7 @@ static void ComboboxElementDraw( if (TkMacOSXInDarkMode(tkwin)) { bounds.size.height += 1; DrawDarkButton(bounds, info.kind, state, dc.context); - } else if ([NSApp macMinorVersion] > 8) { + } else if ([NSApp macOSVersion] > 100800) { if ((state & TTK_STATE_BACKGROUND) && !(state & TTK_STATE_DISABLED)) { NSColor *background = [NSColor textBackgroundColor]; @@ -2309,12 +2309,12 @@ static void TroughElementSize( ChkErr(GetThemeMetric, kThemeMetricScrollBarWidth, &thickness); if (orientation == TTK_ORIENT_HORIZONTAL) { *minHeight = thickness; - if ([NSApp macMinorVersion] > 7) { + if ([NSApp macOSVersion] > 100700) { *paddingPtr = Ttk_MakePadding(4, 4, 4, 3); } } else { *minWidth = thickness; - if ([NSApp macMinorVersion] > 7) { + if ([NSApp macOSVersion] > 100700) { *paddingPtr = Ttk_MakePadding(4, 4, 3, 4); } } @@ -2359,7 +2359,7 @@ static void TroughElementDraw( components: rgba count: 4]; BEGIN_DRAWING(d) - if ([NSApp macMinorVersion] > 8) { + if ([NSApp macOSVersion] > 100800) { CGContextSetFillColorWithColor(dc.context, CGCOLOR(troughColor)); } else { ChkErr(HIThemeSetFill, kThemeBrushDocumentWindowBackground, NULL, @@ -2422,7 +2422,7 @@ static void ThumbElementDraw( * draw the thumb directly. */ - if ([NSApp macMinorVersion] > 8) { + if ([NSApp macOSVersion] > 100800) { CGRect thumbBounds = BoxToRect(d, b); NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *thumbColor; @@ -2482,7 +2482,7 @@ static void ThumbElementDraw( visibleSize = (thumbSize / trackSize) * factor; info.max = factor - visibleSize; info.trackInfo.scrollbar.viewsize = visibleSize; - if ([NSApp macMinorVersion] < 8 || + if ([NSApp macOSVersion] < 100800 || orientation == TTK_ORIENT_HORIZONTAL) { info.value = factor * fraction; } else { @@ -2520,7 +2520,7 @@ static void ArrowElementSize( int *minHeight, Ttk_Padding *paddingPtr) { - if ([NSApp macMinorVersion] < 8) { + if ([NSApp macOSVersion] < 100800) { *minHeight = *minWidth = 14; } else { *minHeight = *minWidth = -1; @@ -2704,7 +2704,7 @@ static void FillElementDraw( { CGRect bounds = BoxToRect(d, b); - if ([NSApp macMinorVersion] > 8) { + if ([NSApp macOSVersion] > 100800) { NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; NSColor *bgColor; CGFloat fill[4]; @@ -2876,7 +2876,7 @@ static void TreeAreaElementSize ( * widget expects the heading to be the same height as a row. */ - if ([NSApp macMinorVersion] > 8) { + if ([NSApp macOSVersion] > 100800) { paddingPtr->top = 4; } } @@ -2896,7 +2896,7 @@ static void TreeHeaderElementSize( int *minHeight, Ttk_Padding *paddingPtr) { - if ([NSApp macMinorVersion] > 8) { + if ([NSApp macOSVersion] > 100800) { *minHeight = 24; } else { ButtonElementSize(clientData, elementRecord, tkwin, minWidth, @@ -2923,7 +2923,7 @@ static void TreeHeaderElementDraw( }; BEGIN_DRAWING(d) - if ([NSApp macMinorVersion] > 8) { + if ([NSApp macOSVersion] > 100800) { /* * Compensate for the padding added in TreeHeaderElementSize, so -- cgit v0.12