Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Xcode 8 build breaks #1372

Merged
merged 1 commit into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/MacVim/MMFindReplaceController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* See README.txt for an overview of the Vim source code.
*/

#import "MacVim.h"
#import "MMFindReplaceController.h"


Expand Down
2 changes: 1 addition & 1 deletion src/MacVim/MMTextViewHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ - (void)setCursor
static NSCursor *ibeamCursor = nil;

if (!ibeamCursor) {
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_14)
if (AVAILABLE_MAC_OS(10, 14))
{
// macOS 10.14 (Mojave) introduced dark mode, and seems to have
// added a thick white border around the system I-beam cursor,
Expand Down
12 changes: 6 additions & 6 deletions src/MacVim/MMVimController.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ - (id)initWithBackend:(id)backend pid:(int)processIdentifier
popupMenuItems = [[NSMutableArray alloc] init];
toolbarItemDict = [[NSMutableDictionary alloc] init];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
if (@available(macos 10.12.2, *)) {
if (AVAILABLE_MAC_OS_PATCH(10, 12, 2)) {
touchbarInfo = [[MMTouchBarInfo alloc] init];
}
#endif
Expand Down Expand Up @@ -1425,7 +1425,7 @@ - (void)addMenuWithDescriptor:(NSArray *)desc atIndex:(int)idx

if ([rootName isEqual:MMTouchbarMenuName]) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
if (@available(macos 10.12.2, *)) {
if (AVAILABLE_MAC_OS_PATCH(10, 12, 2)) {
if ([desc count] < 2) // Cannot be 1, as we need at least TouchBar.<menu_name>
return;
if ([desc count] >= 3) // Unfortunately currently Apple does not support nested popover's so we can only do one level nesting
Expand Down Expand Up @@ -1509,7 +1509,7 @@ - (void)addMenuItemWithDescriptor:(NSArray *)desc
if ([desc count] >= 4) // Unfortunately currently Apple does not support nested popover's so we can only do one level nesting
return;

if (@available(macos 10.12.2, *)) {
if (AVAILABLE_MAC_OS_PATCH(10, 12, 2)) {
MMTouchBarInfo *submenuTouchbar = nil;
if (![self touchBarItemForDescriptor:desc touchBar:&submenuTouchbar touchBarItem:nil]) {
return;
Expand Down Expand Up @@ -1597,7 +1597,7 @@ - (void)removeMenuItemWithDescriptor:(NSArray *)desc
}
if ([rootName isEqual:MMTouchbarMenuName]){
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
if (@available(macos 10.12.2, *)) {
if (AVAILABLE_MAC_OS_PATCH(10, 12, 2)) {
MMTouchBarInfo *submenuTouchbar = nil;
if (![self touchBarItemForDescriptor:desc touchBar:&submenuTouchbar touchBarItem:nil]) {
return;
Expand Down Expand Up @@ -1651,7 +1651,7 @@ - (void)enableMenuItemWithDescriptor:(NSArray *)desc state:(BOOL)on

if ([rootName isEqual:MMTouchbarMenuName]) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
if (@available(macos 10.12.2, *)) {
if (AVAILABLE_MAC_OS_PATCH(10, 12, 2)) {
MMTouchBarItemInfo *touchbarItem = nil;
if (![self touchBarItemForDescriptor:desc touchBar:nil touchBarItem:&touchbarItem]) {
return;
Expand Down Expand Up @@ -1695,7 +1695,7 @@ - (void)updateMenuItemTooltipWithDescriptor:(NSArray *)desc

if ([rootName isEqual:MMTouchbarMenuName]) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12_2
if (@available(macos 10.12.2, *)) {
if (AVAILABLE_MAC_OS_PATCH(10, 12, 2)) {
MMTouchBarItemInfo *touchbarItem = nil;
if (![self touchBarItemForDescriptor:desc touchBar:nil touchBarItem:&touchbarItem]) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/MacVim/MMWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ - (id)initWithVimController:(MMVimController *)controller
// setting it in macOS 11+.
BOOL usingTexturedBackground = NO;
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0
if (@available(macos 11.0, *)) {
if (AVAILABLE_MAC_OS(11, 0)) {
// Don't set the textured background because it's been completely deprecated and won't do anything.
} else {
styleMask = styleMask | NSWindowStyleMaskTexturedBackground;
Expand Down Expand Up @@ -592,7 +592,7 @@ - (void)refreshApperanceMode

// Transparent title bar setting
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
if (@available(macos 10.10, *)) {
if (AVAILABLE_MAC_OS(10, 10)) {
decoratedWindow.titlebarAppearsTransparent = [ud boolForKey:MMTitlebarAppearsTransparentKey];
}
#endif
Expand Down Expand Up @@ -1800,7 +1800,7 @@ - (void)updateTablineSeparator
// See initWithVimController: for textured background deprecation notes.
BOOL windowTextured = NO;
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0
if (@available(macos 11.0, *)) {
if (AVAILABLE_MAC_OS(11, 0)) {
} else {
windowTextured = ([decoratedWindow styleMask] &
NSWindowStyleMaskTexturedBackground) != 0;
Expand Down
26 changes: 26 additions & 0 deletions src/MacVim/MacVim.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,34 @@
#ifndef NSAppKitVersionNumber10_12
# define NSAppKitVersionNumber10_12 1504
#endif
#ifndef NSAppKitVersionNumber10_12_2
# define NSAppKitVersionNumber10_12_2 1504.76
#endif
#ifndef NSAppKitVersionNumber10_13
# define NSAppKitVersionNumber10_13 1561
#endif
#ifndef NSAppKitVersionNumber10_14
# define NSAppKitVersionNumber10_14 1671
#endif
#ifndef NSAppKitVersionNumber11_0
# define NSAppKitVersionNumber11_0 2022
#endif

// Macro to detect runtime OS version. Ideally, we would just like to use
// @available to test for this because the compiler can optimize it out
// depending on your min/max OS configuration. However, it was added in Xcode 9
// (macOS 10.13 SDK). For any code that we want to be compilable for Xcode 8
// (macOS 10.12) or below, we need to use the macro below which will
// selectively use NSAppKitVersionNumber instead.
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13
// Xcode 9+, can use @available, which is more efficient.
# define AVAILABLE_MAC_OS(MAJOR, MINOR) @available(macos MAJOR##.##MINOR, *)
# define AVAILABLE_MAC_OS_PATCH(MAJOR, MINOR, PATCH) @available(macos MAJOR##.##MINOR##.##PATCH, *)
#else
// Xcode 8 or below. Use the old-school NSAppKitVersionNumber check.
# define AVAILABLE_MAC_OS(MAJOR, MINOR) NSAppKitVersionNumber >= NSAppKitVersionNumber##MAJOR##_##MINOR
# define AVAILABLE_MAC_OS_PATCH(MAJOR, MINOR, PATCH) NSAppKitVersionNumber >= NSAppKitVersionNumber##MAJOR##_##MINOR##_##PATCH
#endif

// Deprecated constants. Since these are constants, we just need the compiler,
// not the runtime to know about them. As such, we can use MAX_ALLOWED to
Expand Down Expand Up @@ -111,6 +133,10 @@
// Deprecated constants in 10.13 SDK
#define NSControlStateValueOn NSOnState
#define NSControlStateValueOff NSOffState

// Newly introduced symbols in 10.13 SDK
typedef NSString* NSPasteboardType;
typedef NSString* NSAttributedStringKey;
#endif

// Deprecated runtime values. Since these are runtime values, we need to use the
Expand Down
3 changes: 2 additions & 1 deletion src/os_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@

# include <dispatch/dispatch.h>

# ifndef MAC_OS_X_VERSION_10_12
# if !defined(MAC_OS_X_VERSION_10_12) || \
(MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12)
typedef int clockid_t;
# endif
# ifndef CLOCK_REALTIME
Expand Down