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: Wed, 26 Jul 2017 22:57:46 +0100 Message-ID: <20170726215746.GA59679@breton.holly.idiocy.org> References: <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> <20170724204404.GA20189@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="wac7ysb48OaltWcw" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1501106299 3834 195.159.176.226 (26 Jul 2017 21:58:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 26 Jul 2017 21:58:19 +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 Wed Jul 26 23:58:13 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 1daUJk-0000M9-Cn for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Jul 2017 23:58:08 +0200 Original-Received: from localhost ([::1]:40139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daUJp-0005Sa-LE for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Jul 2017 17:58:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daUJh-0005R0-Od for bug-gnu-emacs@gnu.org; Wed, 26 Jul 2017 17:58:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daUJe-0008F3-Dh for bug-gnu-emacs@gnu.org; Wed, 26 Jul 2017 17:58:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55075) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1daUJe-0008Eh-7A for bug-gnu-emacs@gnu.org; Wed, 26 Jul 2017 17:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1daUJd-00024r-PL for bug-gnu-emacs@gnu.org; Wed, 26 Jul 2017 17:58:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Jul 2017 21:58:01 +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.15011062797976 (code B ref 27810); Wed, 26 Jul 2017 21:58:01 +0000 Original-Received: (at 27810) by debbugs.gnu.org; 26 Jul 2017 21:57:59 +0000 Original-Received: from localhost ([127.0.0.1]:57752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1daUJa-00024a-Gi for submit@debbugs.gnu.org; Wed, 26 Jul 2017 17:57:59 -0400 Original-Received: from mail-wr0-f179.google.com ([209.85.128.179]:33582) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1daUJX-00024L-W1 for 27810@debbugs.gnu.org; Wed, 26 Jul 2017 17:57:57 -0400 Original-Received: by mail-wr0-f179.google.com with SMTP id v105so106411526wrb.0 for <27810@debbugs.gnu.org>; Wed, 26 Jul 2017 14:57:55 -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=U2mXvBVmENoCef+mh7THqyPZpDJhVu/VRibbDlQq930=; b=PnEzJwF41PWcN/GV/RXThCqQwr5G93KCW+Q+qCqE4IkaNkQldxRMyYejgCpwuo9qJ+ uylVzKUk4QuDN82Amn2R5bVmKO+7/A+vfEmKqR8+fvPuMdwbqi2ShTTNMZtoI46V3bgs kOgsdG13yDlscT8sTnT9Gv4kM2sGNxHpeoYBxGtUTz9lqe9J+Nj+SOKVhxuCDeLz7i3i u503nx1ry/u8vEjQKRQz8dN2n7BzRNv/s4Pm2EhPFoVuZ6zbDw+5GaV+FrCtR/IF2aLK PpxYqzcqq2s6U6FW6FlPjuYfWKiUsIPd0OiQuoUNOaSeG/Uon0X9KDr468h3LLRduQtk Sjvw== 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=U2mXvBVmENoCef+mh7THqyPZpDJhVu/VRibbDlQq930=; b=qv5gkS9QIeQ6CUYUfXimaxTJG8DWs6AmHJoMbdi29cHDP7Vz81HaP/1lFXITLrDXii EYQB3drppxzFRPZhLdiIKURbJyh5eoXLtoWlYzRxuxHbTO5bimpXK9gAyTTOzh/d7jdT 4iIW2fm5LDu1LIwXQsJ7FBd+EecErUZn7LvqgBJKPSrMqtHI89Y+sf6ztU/8XDE6eXMB tuSvu157BHzO+TF1Ds+amAHpPQOv15eV5nDC0KNxFxVbIyhgvryfRkUsXqvlTU1wNHMb lJjtI1T4z3ihnY8O+tbiOCkQW09fEtq/l2vtSJwJ+4HXw9qeOcEd8MkQ29yHWZKhiUax KC4A== X-Gm-Message-State: AIVw111VrxMYKtzffvUFPqXiNmEEz1YP5g/PINgsv3oaRo+/tFWAvbII pi1GftNivnm08Q== X-Received: by 10.223.149.102 with SMTP id 93mr1763425wrs.25.1501106270028; Wed, 26 Jul 2017 14:57:50 -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 b25sm23107317wrb.79.2017.07.26.14.57.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jul 2017 14:57:48 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20170724204404.GA20189@breton.holly.idiocy.org> 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:135032 Archived-At: --wac7ysb48OaltWcw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Mon, Jul 24, 2017 at 09:44:04PM +0100, Alan Third wrote: > > 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. I think I finally worked it out by reading macfont.m. I’ve attached YET ANOTHER version of this which doesn't use any custom macros. To compile for multiple versions you do something like: ./configure --with-ns CFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=1070 -DMAC_OS_X_VERSION_MAX_ALLOWED=101200 -g -O3" By default max and min are set to the version you’re running on, afaict. Please be aware that 10.6 isn’t fully compatible with this at the moment, as there is at least one place (nsmenu.m:535) where there’s a bug fix for it that I can’t see an immediate way of making dynamic. Additionally the native fullscreen stuff is based on a simple check against MAX. I expect I’ll be able to fix that with a bit of work, though. I’d be interested to see if this builds on systems lower than 10.10 with the above configure command. There are probably bits and pieces I’ve not quite got right. -- Alan Third --wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Allow-use-of-run-time-OS-version-checks-on-macOS-bug.patch" >From 44d3d2d20789997505a93101d6d14e6c854dbd50 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Thu, 6 Jul 2017 23:10:49 +0100 Subject: [PATCH] Allow use of run-time OS version checks on macOS (bug#27810) * src/nsterm.h (NSWindowTabbingMode): Define in pre-Sierra macOS. * src/nsterm.m (colorForEmacsRed): (colorUsingDefaultColorSpace): (runAlertPanel): (firstRectForCharacterRange): (initFrameFromEmacs): (windowDidEnterFullScreen): (toggleFullScreen): (constrainFrameRect): (scrollerWidth): Allow run-time checks. * src/nsfns.m (ns_screen_name): Use run-time OS version checks. * src/macfont.m (macfont_draw): Use run-time OS version checks. --- src/macfont.m | 16 +++++-- src/nsfns.m | 79 ++++++++++++++++++-------------- src/nsterm.h | 9 +++- src/nsterm.m | 144 ++++++++++++++++++++++++++++++++++++++++------------------ 4 files changed, 164 insertions(+), 84 deletions(-) diff --git a/src/macfont.m b/src/macfont.m index 4d310e47ae..d373e391f9 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -2870,10 +2870,18 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no Apple says there are no plans to address this issue (rdar://11644870) currently. So we add a workaround. */ #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - CGContextSetLineWidth (context, synthetic_bold_factor * font_size - * [[FRAME_NS_VIEW(f) window] backingScaleFactor]); -#else - CGContextSetLineWidth (context, synthetic_bold_factor * font_size); +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 + if ([[FRAME_NS_VIEW(f) window] respondsToSelector: + @selector(backingScaleFactor)]) +#endif + CGContextSetLineWidth (context, synthetic_bold_factor * font_size + * [[FRAME_NS_VIEW(f) window] backingScaleFactor]); +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 + else +#endif +#endif +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 + CGContextSetLineWidth (context, synthetic_bold_factor * font_size); #endif CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND (context, face, f); } diff --git a/src/nsfns.m b/src/nsfns.m index 36748cebb8..62c25d5e87 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -2513,51 +2513,60 @@ and GNUstep implementations ("distributor-specific release char *name = NULL; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 - mach_port_t masterPort; - io_iterator_t it; - io_object_t obj; +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 + if (CGDisplayIOServicePort == NULL) +#endif + { + 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. - if (IOMasterPort (MACH_PORT_NULL, &masterPort) != kIOReturnSuccess - || IOServiceGetMatchingServices (masterPort, - IOServiceMatching ("IONDRVDevice"), - &it) != kIOReturnSuccess) - return name; + 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? */ - /* Must loop until we find a name. Many devices can have the same unit - number (represents different GPU parts), but only one has a name. */ - while (! name && (obj = IOIteratorNext (it))) - { - CFMutableDictionaryRef props; - const void *val; - - if (IORegistryEntryCreateCFProperties (obj, - &props, - kCFAllocatorDefault, - kNilOptions) == kIOReturnSuccess - && props != nil - && (val = CFDictionaryGetValue(props, @"IOFBDependentIndex"))) + if (IOMasterPort (MACH_PORT_NULL, &masterPort) != kIOReturnSuccess + || IOServiceGetMatchingServices (masterPort, + IOServiceMatching ("IONDRVDevice"), + &it) != kIOReturnSuccess) + return name; + + /* Must loop until we find a name. Many devices can have the same unit + number (represents different GPU parts), but only one has a name. */ + while (! name && (obj = IOIteratorNext (it))) { - unsigned nr = [(NSNumber *)val unsignedIntegerValue]; - if (nr == CGDisplayUnitNumber (did)) - name = ns_get_name_from_ioreg (obj); + CFMutableDictionaryRef props; + const void *val; + + if (IORegistryEntryCreateCFProperties (obj, + &props, + kCFAllocatorDefault, + kNilOptions) == kIOReturnSuccess + && props != nil + && (val = CFDictionaryGetValue(props, @"IOFBDependentIndex"))) + { + unsigned nr = [(NSNumber *)val unsignedIntegerValue]; + if (nr == CGDisplayUnitNumber (did)) + name = ns_get_name_from_ioreg (obj); + } + + CFRelease (props); + IOObjectRelease (obj); } - CFRelease (props); - IOObjectRelease (obj); + IOObjectRelease (it); } - - IOObjectRelease (it); - -#else - - name = ns_get_name_from_ioreg (CGDisplayIOServicePort (did)); - +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 + else +#endif +#endif /* #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 */ +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 + name = ns_get_name_from_ioreg (CGDisplayIOServicePort (did)); #endif return name; } -#endif +#endif /* NS_IMPL_COCOA */ static Lisp_Object ns_make_monitor_attribute_list (struct MonitorInfo *monitors, diff --git a/src/nsterm.h b/src/nsterm.h index 0f1b36db7b..e1dae28111 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -1317,6 +1317,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 36d906a7ce..10f726be86 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -136,14 +136,18 @@ @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) - return [NSColor colorWithSRGBRed: red - green: green - blue: blue - alpha: alpha]; +#if defined (NS_IMPL_COCOA) \ + && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if (ns_use_srgb_colorspace +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 + && [NSColor respondsToSelector: + @selector(colorWithSRGBRed:green:blue:alpha:)] #endif + ) + return [NSColor colorWithSRGBRed: red + green: green + blue: blue + alpha: alpha]; #endif return [NSColor colorWithCalibratedRed: red green: green @@ -153,11 +157,18 @@ + (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) - return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]]; + /* 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 defined (NS_IMPL_COCOA) \ + && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if (ns_use_srgb_colorspace +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 + && [NSColor respondsToSelector: + @selector(colorWithSRGBRed:green:blue:alpha:)] #endif + ) + return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]]; #endif return [self colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; } @@ -5563,8 +5574,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 @@ -6325,14 +6335,27 @@ - (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]; + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 + if ([[self window] respondsToSelector: @selector(convertRectToScreen:)]) + { +#endif + rect.origin = pt; + rect = [[self window] convertRectToScreen: rect]; +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 + } + else +#endif +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 */ +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 \ + || defined (NS_IMPL_GNUSTEP) + { + pt = [[self window] convertBaseToScreen: pt]; + rect.origin = pt; + } #endif + return rect; } @@ -7032,9 +7055,12 @@ - (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) \ + || MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_9 +#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_9 + if ([win respondsToSelector: @selector(useOptimizedDrawing:)]) +#endif + [win useOptimizedDrawing: YES]; #endif [[win contentView] addSubview: self]; @@ -7094,9 +7120,12 @@ - (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) \ + || MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_9 +#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_9 + if ([self respondsToSelector: @selector(allocateGState)]) +#endif + [self allocateGState]; #endif [NSApp registerServicesMenuSendTypes: ns_send_types returnTypes: [NSArray array]]; @@ -7104,9 +7133,12 @@ - (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]; +#if defined (NS_IMPL_COCOA) \ + && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12 +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 + if ([win respondsToSelector: @selector(setTabbingMode:)]) +#endif + [win setTabbingMode: NSWindowTabbingModeDisallowed]; #endif ns_window_num++; @@ -7362,7 +7394,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. @@ -7378,7 +7414,6 @@ - (void)windowDidEnterFullScreen /* provided for direct calls */ [NSApp setPresentationOptions: options]; } #endif -#endif [toolbar setVisible:tbar_visible]; } } @@ -7512,10 +7547,14 @@ - (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 defined (NS_IMPL_COCOA) \ + && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 /* Hide ghost menu bar on secondary monitor? */ - if (! onFirstScreen) + if (! onFirstScreen +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 + && [NSScreen respondsToSelector: @selector(screensHaveSeparateSpaces)] +#endif + ) onFirstScreen = [NSScreen screensHaveSeparateSpaces]; #endif /* Hide dock and menubar if we are on the primary screen. */ @@ -7543,9 +7582,12 @@ - (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) \ + || MAC_OS_X_VERSION_MIN_ALLOWED <= MAC_OS_X_VERSION_10_9 +#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_9 + if ([fw respondsToSelector: @selector(useOptimizedDrawing:)]) +#endif + [fw useOptimizedDrawing: YES]; #endif [fw setBackgroundColor: col]; if ([col alphaComponent] != (EmacsCGFloat) 1.0) @@ -8109,7 +8151,11 @@ - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen #if MAC_OS_X_VERSION_MAX_ALLOWED >= 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 ( +#if MAC_OS_X_VERSION_MIN_ALLOWED < MAC_OS_X_VERSION_10_9 + [NSScreen respondsToSelector: @selector(screensHaveSeparateSpaces)] && +#endif + [NSScreen screensHaveSeparateSpaces]) { NSTRACE_MSG ("Screens have separate spaces"); frameRect = [super constrainFrameRect:frameRect toScreen:screen]; @@ -8118,6 +8164,7 @@ - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen } else #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 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). @@ -8323,12 +8370,21 @@ + (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]; +#if defined (NS_IMPL_COCOA) \ + && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#if MAC_OS_X_VERSION_MIN_ALLOWED < MAC_OS_X_VERSION_10_7 + if ([NSScroller respondsToSelector: + @selector(scrollerWidthForControlSize:scrollerStyle:)]) +#endif + r = [NSScroller scrollerWidthForControlSize: NSControlSizeRegular + scrollerStyle: NSScrollerStyleLegacy]; +#if MAC_OS_X_VERSION_MIN_ALLOWED < MAC_OS_X_VERSION_10_7 + else +#endif +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 */ +#if MAC_OS_X_VERSION_MIN_ALLOWED < MAC_OS_X_VERSION_10_7 \ + || defined (NS_IMPL_GNUSTEP) + r = [NSScroller scrollerWidth]; #endif return r; } -- 2.12.0 --wac7ysb48OaltWcw--