>From dd73f985107937ee1c593f0878bdd5b01178af1c Mon Sep 17 00:00:00 2001 From: Alan Third Date: Thu, 6 Jul 2017 23:10:49 +0100 Subject: [PATCH] Use a run-time check for macOS Sierra tabbing support * src/nsterm.m (initFrameFromEmacs) [NS_IMPL_COCOA]: Switch from compile-time check to run-time. * src/nsterm.h (NSWindowTabbingMode): Define in pre-Sierra macOS. (NS_SILENCE_MISSING_METHOD_WARNING_BEGIN, NS_SILENCE_MISSING_METHOD_WARNING_BEGIN_END): Add #defines for silencing known missing method warnings. --- src/nsterm.h | 33 +++++++++++++++++++++++++++++++++ src/nsterm.m | 8 +++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/nsterm.h b/src/nsterm.h index 0f1b36db7b..c5b4b17eed 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -1317,6 +1317,39 @@ extern char gnustep_base_version[]; /* version tracking */ #ifdef __OBJC__ typedef NSUInteger NSWindowStyleMask; #endif + +/* Window tabbing mode enums are new too. */ +enum NSWindowTabbingMode + { + NSWindowTabbingModeAutomatic, + NSWindowTabbingModePreferred, + NSWindowTabbingModeDisallowed + }; +#endif + +/* Surround code with the following macros to silence a missing method + * warning from the compiler. This is useful when testing whether a + * method is available on an object, and then calling it if so. + * + * if ([obj respondsToSelector: @selector(methodName)]) + * [obj methodName]; + * + * Where obj doesn't have a selector methodName, the compiler will + * issue a warning. Sometimes we want to build against libraries + * where we don't know if the method exists, for example when a new + * version of Cocoa adds or removes a method. + */ +#if defined (__GNUC__) && !defined (__clang__) +/* gcc doesn't seem to have any way to silence this warning. */ +#define NS_SILENCE_MISSING_METHOD_WARNING_BEGIN +#define NS_SILENCE_MISSING_METHOD_WARNING_BEGIN_END + +#elif defined (__clang__) +#define NS_SILENCE_MISSING_METHOD_WARNING_BEGIN \ + _Pragma ("clang diagnostic push") \ + _Pragma ("clang diagnostic ignored \"-Wobjc-method-access\"") +#define NS_SILENCE_MISSING_METHOD_WARNING_BEGIN_END \ + _Pragma ("clang diagnostic pop") #endif #endif /* HAVE_NS */ diff --git a/src/nsterm.m b/src/nsterm.m index a3c7031331..e1ce05b978 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -7091,9 +7091,11 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f /* macOS Sierra automatically enables tabbed windows. We can't allow this to be enabled until it's available on a Free system. Currently it only happens by accident and is buggy anyway. */ -#if defined (NS_IMPL_COCOA) && \ - MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 - [win setTabbingMode: NSWindowTabbingModeDisallowed]; +#ifdef NS_IMPL_COCOA + NS_SILENCE_MISSING_METHOD_WARNING_BEGIN + if ([win respondsToSelector: @selector(setTabbingMode:)]) + [win setTabbingMode: NSWindowTabbingModeDisallowed]; + NS_SILENCE_MISSING_METHOD_WARNING_BEGIN_END #endif ns_window_num++; -- 2.12.0