From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#27810: NS runtime feature detection Date: Mon, 24 Jul 2017 21:44:04 +0100 Message-ID: <20170724204404.GA20189@breton.holly.idiocy.org> References: <20170716230109.GA54914@breton.holly.idiocy.org> <1ce59431-ff6b-dc89-31a6-8fc5bd4e3926@aurox.ch> <20170718221629.GA55506@breton.holly.idiocy.org> <20170722112230.GA58424@breton.holly.idiocy.org> <20170723121701.GA3730@breton.holly.idiocy.org> <508a4930-feab-588b-0ab9-f55a10ea85ec@aurox.ch> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="+HP7ph2BbKc20aGI" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1500929327 14954 195.159.176.226 (24 Jul 2017 20:48:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 24 Jul 2017 20:48:47 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: Anders Lindgren , 27810@debbugs.gnu.org To: "Charles A. Roelli" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 24 22:48:40 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZkHN-0003ND-US for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Jul 2017 22:48:38 +0200 Original-Received: from localhost ([::1]:56921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZkHT-00036a-J6 for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Jul 2017 16:48:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZkDy-0000Ga-Sw for bug-gnu-emacs@gnu.org; Mon, 24 Jul 2017 16:45:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZkDu-0003vD-VB for bug-gnu-emacs@gnu.org; Mon, 24 Jul 2017 16:45:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52058) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZkDu-0003ua-PN for bug-gnu-emacs@gnu.org; Mon, 24 Jul 2017 16:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dZkDu-0001C8-Cf for bug-gnu-emacs@gnu.org; Mon, 24 Jul 2017 16:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 Jul 2017 20:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27810 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27810-submit@debbugs.gnu.org id=B27810.15009290564508 (code B ref 27810); Mon, 24 Jul 2017 20:45:02 +0000 Original-Received: (at 27810) by debbugs.gnu.org; 24 Jul 2017 20:44:16 +0000 Original-Received: from localhost ([127.0.0.1]:54735 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZkD9-0001Ae-A0 for submit@debbugs.gnu.org; Mon, 24 Jul 2017 16:44:15 -0400 Original-Received: from mail-wm0-f43.google.com ([74.125.82.43]:38402) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZkD5-0001AM-4K for 27810@debbugs.gnu.org; Mon, 24 Jul 2017 16:44:13 -0400 Original-Received: by mail-wm0-f43.google.com with SMTP id m85so26909289wma.1 for <27810@debbugs.gnu.org>; Mon, 24 Jul 2017 13:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=Zy4yw7XSoQ5APRffCSn/ivKz8oUS4Mds/ubjAhStbCQ=; b=L1Wgl33D6vKUgmCQ/cQFOaO3MFRN2S6ifn+8EDvg2lKTom7MAd+mzE9uTBn6y4J/6G DI5G2VAHsQ4LOxcxNB7cGNdKunPI1BGC/TtnCiNMrlqpqUKVZG8q8ESowBQfGp2dAqM0 v+Q3+sEIukrwMKX5MSur6CLMXdzTtrkRiWAMuZvWogLw2pejwYdzPc+ZRADbuVbF3GUV bE9BYQNxehZWjAfNJ/oPPZ5AbA+fBsr3i/iQDPQjzwuAIna9zTnU5/6IhMHw+Oza/bcz Hycyc3PfW3wXYRJSnOLLgo0TjtFk+qpsr9M6L7+zkAgocCjN70Ojw1lOVb9A6a4R9HNi 8ADQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=Zy4yw7XSoQ5APRffCSn/ivKz8oUS4Mds/ubjAhStbCQ=; b=I8fULIOIG5dRHnZLLxFS1kEH1M5cF4MTjVjIci9Fe+gLTn9qRCg4NVUJkdv0lgrEwz 5P/lSrz2rLabTc8ngD14SvmxOlq79Izu8Yl+SduGLqz742+bEB2hu/opkUvT43m0yMBt bmqIkYUvmsz+3TENHNTRNZDFLbX81EM8HLECo7wIZaw8iiJ59WyiAtEwer542M/1fonu McEBa88ZELqqannrqyegvH4B1cry+RnRQO/mxOCRkKGXgZGKo+Qk0bkvEPilpzFK4LGn XJ2fhmllCheAybBtHa8BANI6j+17XHT5wkdodP0Ew5jEkPYo/QgoeaFbvpulfIMtl889 uK/A== X-Gm-Message-State: AIVw112Rthgdfv02NFlHmzFMSozPDXy+qzl7iUavk5PAe6aIpW5/y0f+ nDKFE+IEW2ciNg== X-Received: by 10.28.59.8 with SMTP id i8mr5524590wma.53.1500929045231; Mon, 24 Jul 2017 13:44:05 -0700 (PDT) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-38a3-b7bd-bb2f-3561.holly.idiocy.org. [2001:8b0:3f8:8129:38a3:b7bd:bb2f:3561]) by smtp.gmail.com with ESMTPSA id s2sm10395857wra.71.2017.07.24.13.44.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 13:44:03 -0700 (PDT) Content-Disposition: inline In-Reply-To: <508a4930-feab-588b-0ab9-f55a10ea85ec@aurox.ch> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:134944 Archived-At: --+HP7ph2BbKc20aGI Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit I wrote a big reply to this but seem to have lost it. On Mon, Jul 24, 2017 at 09:02:57PM +0200, Charles A. Roelli wrote: > nsterm.m: In function ‘-[EmacsView windowDidEnterFullScreen]’: > nsterm.m:7395: error: ‘NSApplicationPresentationFullScreen’ undeclared > (first use in this function) > nsterm.m:7395: error: (Each undeclared identifier is reported only once > nsterm.m:7395: error: for each function it appears in.) > nsterm.m:7396: error: ‘NSApplicationPresentationAutoHideToolbar’ undeclared > (first use in this function) I think perhaps we need to just test ‘< 10.7’. I’ve attached a new patch that deals with that and some other bits and pieces. > I'm confused why the macro call you wrote doesn't prevent this. But > when I change it to #if MAC_OS_X_VERSION_MIN_ALLOWED <= > MAC_OS_X_VERSION_10_6, then it compiles. This min/max stuff always > confuses me... I’m unclear where we should be using MIN_REQUIRED vs MAX_ALLOWED, but I think we’re OK with MAX everywhere for what we’re doing. I’ve just used MAX in both my new macros. We need a proper runtime OS version check in a few places. I think there are two ways of doing this depending on which OS version you’re building on. It’s getting very close to circular. ;) macfont.m looks like it could be a small nightmare as it has a LOT of version dependent code. Thanks for testing this patch. -- Alan Third --+HP7ph2BbKc20aGI Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Use-a-run-time-check-for-macOS-Sierra-tabbing-suppor.patch" >From b26a3594f62544f3942e2eaceb4a1b1b92a2166d 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 * configure.ac: Add --enable-macos-runtime-feature-detection flag. * src/nsterm.h (NSWindowTabbingMode): Define in pre-Sierra macOS. (MACOS_MIN_VERSION, MACOS_MAX_VERSION): Add new defines for version detection. * src/nsterm.m (colorForEmacsRed): (colorUsingDefaultColorSpace): (runAlertPanel): (firstRectForCharacterRange): (initFrameFromEmacs): (windowDidEnterFullScreen): (toggleFullScreen): (constrainFrameRect): (scrollerWidth): Allow run-time checks. * src/nsfns.m (ns_screen_name): Allow run-time checks. --- configure.ac | 6 ++++ src/nsfns.m | 7 ++-- src/nsterm.h | 16 ++++++++- src/nsterm.m | 113 ++++++++++++++++++++++++++++++++++++----------------------- 4 files changed, 96 insertions(+), 46 deletions(-) diff --git a/configure.ac b/configure.ac index 5e6dbda2b6..09ce9a851a 100644 --- a/configure.ac +++ b/configure.ac @@ -426,6 +426,12 @@ AC_DEFUN EN_NS_SELF_CONTAINED=$enableval, EN_NS_SELF_CONTAINED=yes) +AC_ARG_ENABLE(macos-runtime-feature-detection, +[AS_HELP_STRING([--enable-macos-runtime-feature-detection], + [bypass compiler checks of macOS versions])], + AC_DEFINE(NS_RUNTIME_CHECKS, 1, + [Perform runtime checks of macOS features.])) + locallisppathset=no AC_ARG_ENABLE(locallisppath, [AS_HELP_STRING([--enable-locallisppath=PATH], diff --git a/src/nsfns.m b/src/nsfns.m index 36748cebb8..c5ff65806a 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -2512,12 +2512,15 @@ and GNUstep implementations ("distributor-specific release { char *name = NULL; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 +#if MACOS_MIN_VERSION (MAC_OS_X_VERSION_10_9) mach_port_t masterPort; io_iterator_t it; io_object_t obj; - // CGDisplayIOServicePort is deprecated. Do it another (harder) way. + /* CGDisplayIOServicePort is deprecated. Do it another (harder) way. + + Is this code OK for macOS < 10.9, and GNUstep? I suspect it is, + in which case is it worth keeping the other method in here? */ if (IOMasterPort (MACH_PORT_NULL, &masterPort) != kIOReturnSuccess || IOServiceGetMatchingServices (masterPort, diff --git a/src/nsterm.h b/src/nsterm.h index 0f1b36db7b..9578591d9d 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -49,6 +49,13 @@ along with GNU Emacs. If not, see . */ #endif /* NS_IMPL_COCOA */ +#define MACOS_MIN_VERSION(min) (defined (NS_IMPL_COCOA) \ + && (MAC_OS_X_VERSION_MAX_ALLOWED >= min \ + || defined (NS_RUNTIME_CHECKS))) +#define MACOS_MAX_VERSION(max) (defined (NS_IMPL_COCOA) \ + && (MAC_OS_X_VERSION_MAX_ALLOWED <= max \ + || defined (NS_RUNTIME_CHECKS))) + #ifdef __OBJC__ /* CGFloat on GNUstep may be 4 or 8 byte, but functions expect float* for some @@ -1317,6 +1324,13 @@ extern char gnustep_base_version[]; /* version tracking */ #ifdef __OBJC__ typedef NSUInteger NSWindowStyleMask; #endif -#endif +/* Window tabbing mode enums are new too. */ +enum NSWindowTabbingMode + { + NSWindowTabbingModeAutomatic, + NSWindowTabbingModePreferred, + NSWindowTabbingModeDisallowed + }; +#endif #endif /* HAVE_NS */ diff --git a/src/nsterm.m b/src/nsterm.m index a3c7031331..07ec899583 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -136,15 +136,15 @@ @implementation NSColor (EmacsColor) + (NSColor *)colorForEmacsRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha { -#ifdef NS_IMPL_COCOA -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if (ns_use_srgb_colorspace) +#if MACOS_MIN_VERSION (MAC_OS_X_VERSION_10_7) + if (ns_use_srgb_colorspace + && [NSColor respondsToSelector: + @selector(colorWithSRGBRed:green:blue:alpha:)]) return [NSColor colorWithSRGBRed: red green: green blue: blue alpha: alpha]; #endif -#endif return [NSColor colorWithCalibratedRed: red green: green blue: blue @@ -153,12 +153,15 @@ + (NSColor *)colorForEmacsRed:(CGFloat)red green:(CGFloat)green - (NSColor *)colorUsingDefaultColorSpace { -#ifdef NS_IMPL_COCOA -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if (ns_use_srgb_colorspace) +#if MACOS_MIN_VERSION (MAC_OS_X_VERSION_10_7) + /* FIXMES: We're checking for colorWithSRGBRed here so this will + only work in the same place as in the method above. It should + really be a check whether we're on macOS 10.7 or above. */ + if (ns_use_srgb_colorspace + && [NSColor respondsToSelector: + @selector(colorWithSRGBRed:green:blue:alpha:)]) return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]]; #endif -#endif return [self colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; } @@ -5550,8 +5553,7 @@ - (void) terminate: (id)sender NSString *defaultButton, NSString *alternateButton) { -#if !defined (NS_IMPL_COCOA) || \ - MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 +#ifdef NS_IMPL_GNUSTEP return NSRunAlertPanel(title, msgFormat, defaultButton, alternateButton, nil) == NSAlertDefaultReturn; #else @@ -6312,14 +6314,28 @@ - (NSRect)firstRectForCharacterRange: (NSRange)theRange +FRAME_LINE_HEIGHT (emacsframe)); pt = [self convertPoint: pt toView: nil]; -#if !defined (NS_IMPL_COCOA) || \ - MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 - pt = [[self window] convertBaseToScreen: pt]; - rect.origin = pt; -#else - rect.origin = pt; - rect = [[self window] convertRectToScreen: rect]; + +#ifdef NS_RUNTIME_CHECKS + if ([[self window] respondsToSelector: @selector(convertRectToScreen:)]) + { +#endif +#if MACOS_MIN_VERSION (MAC_OS_X_VERSION_10_7) + rect.origin = pt; + rect = [[self window] convertRectToScreen: rect]; +#endif +#ifdef NS_RUNTIME_CHECKS + } + else + { +#endif +#if MACOS_MAX_VERSION (MAC_OS_X_VERSION_10_6) || defined (NS_IMPL_GNUSTEP) + pt = [[self window] convertBaseToScreen: pt]; + rect.origin = pt; +#endif +#ifdef NS_RUNTIME_CHECKS + } #endif + return rect; } @@ -7019,9 +7035,9 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f [win setAcceptsMouseMovedEvents: YES]; [win setDelegate: self]; -#if !defined (NS_IMPL_COCOA) || \ - MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 - [win useOptimizedDrawing: YES]; +#if !defined (NS_IMPL_COCOA) || MACOS_MAX_VERSION (MAC_OS_X_VERSION_10_9) + if ([win respondsToSelector: @selector(useOptimizedDrawing:)]) + [win useOptimizedDrawing: YES]; #endif [[win contentView] addSubview: self]; @@ -7081,19 +7097,19 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f if ([col alphaComponent] != (EmacsCGFloat) 1.0) [win setOpaque: NO]; -#if !defined (NS_IMPL_COCOA) || \ - MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 - [self allocateGState]; +#if !defined (NS_IMPL_COCOA) || MACOS_MAX_VERSION (MAC_OS_X_VERSION_10_9) + if ([self respondsToSelector: @selector(allocateGState)]) + [self allocateGState]; #endif [NSApp registerServicesMenuSendTypes: ns_send_types returnTypes: [NSArray array]]; +#if MACOS_MIN_VERSION (MAC_OS_X_VERSION_10_12) /* 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]; + if ([win respondsToSelector: @selector(setTabbingMode:)]) + [win setTabbingMode: NSWindowTabbingModeDisallowed]; #endif ns_window_num++; @@ -7349,7 +7365,11 @@ - (void)windowDidEnterFullScreen /* provided for direct calls */ { BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (emacsframe) ? YES : NO; #ifdef NS_IMPL_COCOA -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 + /* These two values are only defined in 10.7 and above. */ + int NSApplicationPresentationFullScreen = (1 << 10); + int NSApplicationPresentationAutoHideToolbar = (1 << 11); +#endif unsigned val = (unsigned)[NSApp presentationOptions]; // Mac OS X 10.7 bug fix, the menu won't appear without this. @@ -7365,7 +7385,6 @@ - (void)windowDidEnterFullScreen /* provided for direct calls */ [NSApp setPresentationOptions: options]; } #endif -#endif [toolbar setVisible:tbar_visible]; } } @@ -7499,10 +7518,10 @@ - (void)toggleFullScreen: (id)sender { NSScreen *screen = [w screen]; -#if defined (NS_IMPL_COCOA) && \ - MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 +#if MACOS_MIN_VERSION (MAC_OS_X_VERSION_10_9) /* Hide ghost menu bar on secondary monitor? */ - if (! onFirstScreen) + if (! onFirstScreen + && [NSScreen respondsToSelector: @selector(screensHaveSeparateSpaces)]) onFirstScreen = [NSScreen screensHaveSeparateSpaces]; #endif /* Hide dock and menubar if we are on the primary screen. */ @@ -7530,9 +7549,9 @@ - (void)toggleFullScreen: (id)sender [fw setTitle:[w title]]; [fw setDelegate:self]; [fw setAcceptsMouseMovedEvents: YES]; -#if !defined (NS_IMPL_COCOA) || \ - MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 - [fw useOptimizedDrawing: YES]; +#if !defined (NS_IMPL_COCOA) || MACOS_MAX_VERSION (MAC_OS_X_VERSION_10_9) + if ([fw respondsToSelector: @selector(useOptimizedDrawing:)]) + [fw useOptimizedDrawing: YES]; #endif [fw setBackgroundColor: col]; if ([col alphaComponent] != (EmacsCGFloat) 1.0) @@ -8093,10 +8112,11 @@ - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen NSTRACE_ARG_RECT (frameRect)); #ifdef NS_IMPL_COCOA -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 +#if MACOS_MIN_VERSION (MAC_OS_X_VERSION_10_9) // If separate spaces is on, it is like each screen is independent. There is // no spanning of frames across screens. - if ([NSScreen screensHaveSeparateSpaces]) + if ([NSScreen respondsToSelector: @selector(screensHaveSeparateSpaces)] + && [NSScreen screensHaveSeparateSpaces]) { NSTRACE_MSG ("Screens have separate spaces"); frameRect = [super constrainFrameRect:frameRect toScreen:screen]; @@ -8104,7 +8124,7 @@ - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen return frameRect; } else -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 */ +#endif /* MACOS_MIN_VERSION (MAC_OS_X_VERSION_10_9) */ // Check that the proposed frameRect is visible in at least one // screen. If it is not, ask the system to reposition it (only // for non-child windows). @@ -8310,12 +8330,19 @@ + (CGFloat) scrollerWidth /* TODO: if we want to allow variable widths, this is the place to do it, however neither GNUstep nor Cocoa support it very well */ CGFloat r; -#if !defined (NS_IMPL_COCOA) || \ - MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 - r = [NSScroller scrollerWidth]; -#else - r = [NSScroller scrollerWidthForControlSize: NSControlSizeRegular - scrollerStyle: NSScrollerStyleLegacy]; +#ifdef NS_RUNTIME_CHECKS + if ([NSScroller respondsToSelector: + @selector(scrollerWidthForControlSize:scrollerStyle:)]) +#endif +#if MACOS_MIN_VERSION (MAC_OS_X_VERSION_10_7) + r = [NSScroller scrollerWidthForControlSize: NSControlSizeRegular + scrollerStyle: NSScrollerStyleLegacy]; +#endif +#ifdef NS_RUNTIME_CHECKS + else +#endif +#if MACOS_MAX_VERSION (MAC_OS_X_VERSION_10_6) + r = [NSScroller scrollerWidth]; #endif return r; } -- 2.12.0 --+HP7ph2BbKc20aGI--