unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Mac OS Sierra tab feature breaks C-x 5 2
@ 2017-07-06 11:29 Paul Michael Reilly
  2017-07-06 12:14 ` Jean-Christophe Helary
  2017-07-06 12:53 ` Alan Third
  0 siblings, 2 replies; 27+ messages in thread
From: Paul Michael Reilly @ 2017-07-06 11:29 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 872 bytes --]

I have recently switched to macOS Sierra and discovered that using C-x 5 2
to create a new frame works just fine, i.e. no different than OS X, if you
do not enter full screen mode (via the green window decoration button).  If
you are in full screen mode C-x 5 2 is ignored, but if you then exit full
screen mode it is clear that the second frame is now a tab (macOS Sierra
tab feature).

I have not seen this behavior mentioned but then I haven't been paying that
close attention.

Prior to macOS Sierra, in full screen mode, C-x 5 2 would create the new
Emacs frame in a new OS X window.

Seems to me that this behavior in macOS Sierra is an Emacs bug to the
extent that it will take Emacs code changes to achieve OS X behavior.  Is
anyone aware of a fix for this issue that has not been released yet?  Or is
it work not yet taken on?  Or am I completely wrong?
-- 
-pmr

[-- Attachment #2: Type: text/html, Size: 1062 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-06 11:29 Mac OS Sierra tab feature breaks C-x 5 2 Paul Michael Reilly
@ 2017-07-06 12:14 ` Jean-Christophe Helary
  2017-07-06 12:46   ` Sebastian Christ
  2017-07-06 12:53 ` Alan Third
  1 sibling, 1 reply; 27+ messages in thread
From: Jean-Christophe Helary @ 2017-07-06 12:14 UTC (permalink / raw)
  To: Paul Michael Reilly; +Cc: emacs-devel


> On Jul 6, 2017, at 20:29, Paul Michael Reilly <pmr@pajato.com> wrote:
> 
> I have recently switched to macOS Sierra and discovered that using C-x 5 2 to create a new frame works just fine, i.e. no different than OS X, if you do not enter full screen mode (via the green window decoration button).  If you are in full screen mode C-x 5 2 is ignored, but if you then exit full screen mode it is clear that the second frame is now a tab (macOS Sierra tab feature).

I work with Sierra and Emacs master and I'm not seeing this. When I am in fullscreen mode (by pressing the green thing at the top left) and I create new frames with C-x 5 2, I get new frames in full screen.

Jean-Christophe 




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-06 12:14 ` Jean-Christophe Helary
@ 2017-07-06 12:46   ` Sebastian Christ
  0 siblings, 0 replies; 27+ messages in thread
From: Sebastian Christ @ 2017-07-06 12:46 UTC (permalink / raw)
  To: emacs-devel

>>>>> "JH" == Jean-Christophe Helary <jean.christophe.helary@gmail.com> writes:

    >> On Jul 6, 2017, at 20:29, Paul Michael Reilly <pmr@pajato.com> wrote:
    >> 
    >> I have recently switched to macOS Sierra and discovered that using
    >> C-x 5 2 to create a new frame works just fine, i.e. no different
    >> than OS X, if you do not enter full screen mode (via the green
    >> window decoration button).  If you are in full screen mode C-x 5 2
    >> is ignored, but if you then exit full screen mode it is clear that
    >> the second frame is now a tab (macOS Sierra tab feature).

    JH> I work with Sierra and Emacs master and I'm not seeing this. When I am
    JH> in fullscreen mode (by pressing the green thing at the top left) and I
    JH> create new frames with C-x 5 2, I get new frames in full screen.

I'm experiencing the same. New tab instead of a new Frame. When I close
one tab (by clicking on the X on the left side of the tab) then Emacs
quits completely. I'm unsure if there is a connection between those two
behaviours.

Regards,

Sebastian


-- 
Sebastian (Rudolfo) Christ
http://rudolfochrist.github.io
GPG Fingerprint: 306D 8FD3 DFB6 4E44 5061
                 CE71 6407 D6F8 2AC5 55DD




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-06 11:29 Mac OS Sierra tab feature breaks C-x 5 2 Paul Michael Reilly
  2017-07-06 12:14 ` Jean-Christophe Helary
@ 2017-07-06 12:53 ` Alan Third
  2017-07-06 14:35   ` Alan Third
  1 sibling, 1 reply; 27+ messages in thread
From: Alan Third @ 2017-07-06 12:53 UTC (permalink / raw)
  To: Paul Michael Reilly; +Cc: Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 594 bytes --]

On 6 Jul 2017 12:29 p.m., "Paul Michael Reilly" <pmr@pajato.com> wrote:

I have recently switched to macOS Sierra and discovered that using C-x 5 2
to create a new frame works just fine, i.e. no different than OS X, if you
do not enter full screen mode (via the green window decoration button).  If
you are in full screen mode C-x 5 2 is ignored, but if you then exit full
screen mode it is clear that the second frame is now a tab (macOS Sierra
tab feature).


This behaviour should be fixed in master. Can you please try it? (nightly
builds if you're using emacsformacos.com builds)

Thanks.

[-- Attachment #2: Type: text/html, Size: 1105 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-06 12:53 ` Alan Third
@ 2017-07-06 14:35   ` Alan Third
  2017-07-06 15:05     ` Jean-Christophe Helary
  0 siblings, 1 reply; 27+ messages in thread
From: Alan Third @ 2017-07-06 14:35 UTC (permalink / raw)
  To: Paul Michael Reilly; +Cc: Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 874 bytes --]

On 6 Jul 2017 1:53 p.m., "Alan Third" <athird@googlemail.com> wrote:



On 6 Jul 2017 12:29 p.m., "Paul Michael Reilly" <pmr@pajato.com> wrote:

I have recently switched to macOS Sierra and discovered that using C-x 5 2
to create a new frame works just fine, i.e. no different than OS X, if you
do not enter full screen mode (via the green window decoration button).  If
you are in full screen mode C-x 5 2 is ignored, but if you then exit full
screen mode it is clear that the second frame is now a tab (macOS Sierra
tab feature).


This behaviour should be fixed in master. Can you please try it? (nightly
builds if you're using emacsformacos.com builds)


I've just realised that we're using a build time version check, and the
Emacs for macOS releases are built on an older version of macOS... I'm not
sure what the best solution here is...

I'll have a think about it.

[-- Attachment #2: Type: text/html, Size: 1867 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-06 14:35   ` Alan Third
@ 2017-07-06 15:05     ` Jean-Christophe Helary
  2017-07-06 17:42       ` Alan Third
  0 siblings, 1 reply; 27+ messages in thread
From: Jean-Christophe Helary @ 2017-07-06 15:05 UTC (permalink / raw)
  To: Alan Third; +Cc: Paul Michael Reilly, Emacs-Devel devel


> On Jul 6, 2017, at 23:35, Alan Third <athird@googlemail.com> wrote:

> I've just realised that we're using a build time version check, and the Emacs for macOS releases are built on an older version of macOS... I'm not sure what the best solution here is...

Is the result very different depending on the version of macOS? What's the version you are building on?

Jean-Christophe 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-06 15:05     ` Jean-Christophe Helary
@ 2017-07-06 17:42       ` Alan Third
  2017-07-06 22:16         ` Alan Third
  0 siblings, 1 reply; 27+ messages in thread
From: Alan Third @ 2017-07-06 17:42 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: Paul Michael Reilly, Emacs-Devel devel

On Fri, Jul 07, 2017 at 12:05:32AM +0900, Jean-Christophe Helary wrote:
> 
> > On Jul 6, 2017, at 23:35, Alan Third <athird@googlemail.com> wrote:
> 
> > I've just realised that we're using a build time version check,
> > and the Emacs for macOS releases are built on an older version of
> > macOS... I'm not sure what the best solution here is...
> 
> Is the result very different depending on the version of macOS?
> What's the version you are building on?

I build on Sierra.

We have this code

    #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
      [win setTabbingMode: NSWindowTabbingModeDisallowed];
    #endif

in initFrameFromEmacs in nsterm.m. The idea being that since this code
only works in 10.12 and up, we only include it when Emacs is compiled
on 10.12. This might be why you’re not seeing the broken behaviour.

I believe that the emacsformacosx builds are built on 10.9 or 10.10 or
something? I can’t remember exactly. That means this code is not
included.

We can make it a run time check, which would look something like

    if ([win respondsToSelector: @selector(setTabbingMode)])
      [win setTabbingMode: NSWindowTabbingModeDisallowed];

but this will throw up compiler warnings on pre‐Sierra versions of
macOS. I guess that’s maybe just the price to be paid.
-- 
Alan Third



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-06 17:42       ` Alan Third
@ 2017-07-06 22:16         ` Alan Third
  2017-07-10 19:17           ` Anders Lindgren
  0 siblings, 1 reply; 27+ messages in thread
From: Alan Third @ 2017-07-06 22:16 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: Paul Michael Reilly, Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 536 bytes --]

On Thu, Jul 06, 2017 at 06:42:04PM +0100, Alan Third wrote:
> We can make it a run time check, which would look something like
> 
>     if ([win respondsToSelector: @selector(setTabbingMode)])
>       [win setTabbingMode: NSWindowTabbingModeDisallowed];
> 
> but this will throw up compiler warnings on pre‐Sierra versions of
> macOS. I guess that’s maybe just the price to be paid.

I’ve attached a patch to master for this. Can someone on macOS 10.11
or below give it a try and confirm that it compiles and runs?
-- 
Alan Third

[-- Attachment #2: 0001-Use-a-run-time-check-for-macOS-Sierra-tabbing-suppor.patch --]
[-- Type: text/plain, Size: 1120 bytes --]

From c22264617bf4d50116c4e55525935241931c2cf1 Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
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.m | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index bf83550b3d..f88b279987 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7073,9 +7073,9 @@ - (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
+  if ([win respondsToSelector: @selector(setTabbingMode:)])
+    [win setTabbingMode: NSWindowTabbingModeDisallowed];
 #endif
 
   ns_window_num++;
-- 
2.12.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-06 22:16         ` Alan Third
@ 2017-07-10 19:17           ` Anders Lindgren
  2017-07-10 19:52             ` Alan Third
  0 siblings, 1 reply; 27+ messages in thread
From: Anders Lindgren @ 2017-07-10 19:17 UTC (permalink / raw)
  To: Alan Third; +Cc: Paul Michael Reilly, Jean-Christophe Helary, Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]

Hi!

Unfortunately, it doesn't compile. I get the following error when I build
on 10.10.5:

nsterm.m:7078:26: error: use of undeclared identifier
'NSWindowTabbingModeDisallowed'
    [win setTabbingMode: NSWindowTabbingModeDisallowed];

Fortunately, the fix is simple. If we build on an older system, we can
define the NSWindowTabbingModeXxx constants ourselves.

    -- Anders


On Fri, Jul 7, 2017 at 12:16 AM, Alan Third <alan@idiocy.org> wrote:

> On Thu, Jul 06, 2017 at 06:42:04PM +0100, Alan Third wrote:
> > We can make it a run time check, which would look something like
> >
> >     if ([win respondsToSelector: @selector(setTabbingMode)])
> >       [win setTabbingMode: NSWindowTabbingModeDisallowed];
> >
> > but this will throw up compiler warnings on pre‐Sierra versions of
> > macOS. I guess that’s maybe just the price to be paid.
>
> I’ve attached a patch to master for this. Can someone on macOS 10.11
> or below give it a try and confirm that it compiles and runs?
> --
> Alan Third
>

[-- Attachment #2: Type: text/html, Size: 1596 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-10 19:17           ` Anders Lindgren
@ 2017-07-10 19:52             ` Alan Third
  2017-07-10 20:22               ` Anders Lindgren
  0 siblings, 1 reply; 27+ messages in thread
From: Alan Third @ 2017-07-10 19:52 UTC (permalink / raw)
  To: Anders Lindgren
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]

On Mon, Jul 10, 2017 at 09:17:58PM +0200, Anders Lindgren wrote:
> Unfortunately, it doesn't compile. I get the following error when I build
> on 10.10.5:
> 
> nsterm.m:7078:26: error: use of undeclared identifier
> 'NSWindowTabbingModeDisallowed'
>     [win setTabbingMode: NSWindowTabbingModeDisallowed];
> 
> Fortunately, the fix is simple. If we build on an older system, we can
> define the NSWindowTabbingModeXxx constants ourselves.

I think this should do it, then...
-- 
Alan Third

[-- Attachment #2: 0001-Use-a-run-time-check-for-macOS-Sierra-tabbing-suppor.patch --]
[-- Type: text/plain, Size: 1699 bytes --]

From 21e4a39eea0da07afd419456a2b6d2df972c622b Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
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.
---
 src/nsterm.h | 8 ++++++++
 src/nsterm.m | 6 +++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/nsterm.h b/src/nsterm.h
index 0f1b36db7b..da221605b4 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1317,6 +1317,14 @@ 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
 
 #endif	/* HAVE_NS */
diff --git a/src/nsterm.m b/src/nsterm.m
index bf83550b3d..f88b279987 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -7073,9 +7073,9 @@ - (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
+  if ([win respondsToSelector: @selector(setTabbingMode:)])
+    [win setTabbingMode: NSWindowTabbingModeDisallowed];
 #endif
 
   ns_window_num++;
-- 
2.12.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-10 19:52             ` Alan Third
@ 2017-07-10 20:22               ` Anders Lindgren
  2017-07-12 18:23                 ` Alan Third
  0 siblings, 1 reply; 27+ messages in thread
From: Anders Lindgren @ 2017-07-10 20:22 UTC (permalink / raw)
  To: Alan Third; +Cc: Paul Michael Reilly, Jean-Christophe Helary, Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 1306 bytes --]

Now it compiles, but with a warning:

----
nsterm.m:7078:10: warning: instance method '-setTabbingMode:' not found
(return type defaults to 'id') [-Wobjc-method-access]
    [win setTabbingMode: NSWindowTabbingModeDisallowed];
         ^~~~~~~~~~~~~~
/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:167:12:
note: receiver is instance of class declared here
@interface NSWindow : NSResponder <NSAnimatablePropertyContainer,
NSUserInterfaceValidations, NSUserInterfaceItemIdentifica...
-----


I've seen other packages declare methods in NSWindows, but I don't know how
"correct" that is. For example:

https://github.com/electron/electron/blob/master/atom/browser/native_window_mac.mm#L450

    -- Anders

On Mon, Jul 10, 2017 at 9:52 PM, Alan Third <alan@idiocy.org> wrote:

> On Mon, Jul 10, 2017 at 09:17:58PM +0200, Anders Lindgren wrote:
> > Unfortunately, it doesn't compile. I get the following error when I build
> > on 10.10.5:
> >
> > nsterm.m:7078:26: error: use of undeclared identifier
> > 'NSWindowTabbingModeDisallowed'
> >     [win setTabbingMode: NSWindowTabbingModeDisallowed];
> >
> > Fortunately, the fix is simple. If we build on an older system, we can
> > define the NSWindowTabbingModeXxx constants ourselves.
>
> I think this should do it, then...
> --
> Alan Third
>

[-- Attachment #2: Type: text/html, Size: 2101 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-10 20:22               ` Anders Lindgren
@ 2017-07-12 18:23                 ` Alan Third
  2017-07-12 21:20                   ` Anders Lindgren
  0 siblings, 1 reply; 27+ messages in thread
From: Alan Third @ 2017-07-12 18:23 UTC (permalink / raw)
  To: Anders Lindgren
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Emacs-Devel devel

On Mon, Jul 10, 2017 at 10:22:43PM +0200, Anders Lindgren wrote:
> Now it compiles, but with a warning:
> 
> ----
> nsterm.m:7078:10: warning: instance method '-setTabbingMode:' not found
> (return type defaults to 'id') [-Wobjc-method-access]
>     [win setTabbingMode: NSWindowTabbingModeDisallowed];
>          ^~~~~~~~~~~~~~
> /System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:167:12:
> note: receiver is instance of class declared here
> @interface NSWindow : NSResponder <NSAnimatablePropertyContainer,
> NSUserInterfaceValidations, NSUserInterfaceItemIdentifica...
> -----
> 
> 
> I've seen other packages declare methods in NSWindows, but I don't know how
> "correct" that is. For example:
> 
> https://github.com/electron/electron/blob/master/atom/browser/native_window_mac.mm#L450

Yeah, I’m not sure about this either. It strikes me as a bit suspect,
but I don’t know that the alternatives are going to be any better.

We could disable the warning:

    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wobjc-method-access"
      if ([win respondsToSelector: @selector(setTabbingMode:)])
        [win setTabbingMode: NSWindowTabbingModeDisallowed];
    #pragma clang diagnostic pop

which is, I think, the right thing to do, but that’s quite messy
looking, and I suspect we’ll have to do the same for the gcc warning.
I don’t know if we’d then have to do some #ifdef stuff to separate the
clang and gcc stuff. This has the potential to get REALLY messy.

Another possibility is to cast `win` to `id`, which I’d guess would
look like:

    [(id)win setTabbingMode: NSWindowTabbingModeDisallowed];

That compiles here, no idea if it gets rid of the warning. It’s short
and sweet, but The Internet seems to think this is generally a bad
idea. I think we’d be OK since we’re only casting it once here, and as
we already know whether or not the method is available, type‐checking
(which we’re bypassing) doesn’t really give us anything.

By the way, while digging around I came across a lot of stuff saying
`@selector(setTabbingMode)` should give a warning if `setTabbingMode`
doesn’t exist. Are you seeing one?
-- 
Alan Third



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-12 18:23                 ` Alan Third
@ 2017-07-12 21:20                   ` Anders Lindgren
  2017-07-13 20:22                     ` Alan Third
  0 siblings, 1 reply; 27+ messages in thread
From: Anders Lindgren @ 2017-07-12 21:20 UTC (permalink / raw)
  To: Alan Third; +Cc: Paul Michael Reilly, Jean-Christophe Helary, Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 2718 bytes --]

> Yeah, I’m not sure about this either. It strikes me as a bit suspect,
> but I don’t know that the alternatives are going to be any better.
>
> We could disable the warning:
>
>     #pragma clang diagnostic push
>     #pragma clang diagnostic ignored "-Wobjc-method-access"
>       if ([win respondsToSelector: @selector(setTabbingMode:)])
>         [win setTabbingMode: NSWindowTabbingModeDisallowed];
>     #pragma clang diagnostic pop
>
> which is, I think, the right thing to do, but that’s quite messy
> looking, and I suspect we’ll have to do the same for the gcc warning.
> I don’t know if we’d then have to do some #ifdef stuff to separate the
> clang and gcc stuff. This has the potential to get REALLY messy.
>

It's possible to encapsulate pragmas into preprocessor macros using the
_Pragma construct. In fact, config.h contains similar stuff, c.f.
_GL_INLINE_HEADER_BEGIN and _GL_INLINE_HEADER_END.


Another possibility is to cast `win` to `id`, which I’d guess would
> look like:
>
>     [(id)win setTabbingMode: NSWindowTabbingModeDisallowed];
>

I still get the same warning, so this is not a solution.


By the way, while digging around I came across a lot of stuff saying
> `@selector(setTabbingMode)` should give a warning if `setTabbingMode`
> doesn’t exist. Are you seeing one?
>

No, no warning is issued about that.

I believe that there are a number of #ifdef:s that could be rewritten in
this way, so we need something ergonomically. (If we could get rid of all
such ifdef:s there would not be a need for OS-version specific binaries.)


Given the options, I would say that a solution along the lines of
_GL_INLINE_HEADER_BEGIN would be best. The pros are:

* All the messy bits can be located in one place, and it can easily be
updated to match future compiler versions. (Should some compiler start to
warn about, say, `@selector(setTabbingMode)`, that too could be
incorporated in the macros.)
* There is a natural location to place documentation and to describe the
situation
* In the code that use the macros, there is a signal to the reader that
something special is going on
* It's possible to write formal tests, ensuring the macros work as intended.

Unlike _GL_INLINE_HEADER_BEGIN, we should not use a leading underscore, as
such identifiers are reserved for the compiler itself. Maybe
NS_SILENCE_MISSING_METHOD_WARNING_BEGIN and -_END? The end result would
look like:

      NS_SILENCE_MISSING_METHOD_WARNING_BEGIN
      if ([win respondsToSelector: @selector(setTabbingMode:)])
        [win setTabbingMode: NSWindowTabbingModeDisallowed];
      NS_SILENCE_MISSING_METHOD_WARNING_END

    -- Anders

[-- Attachment #2: Type: text/html, Size: 3640 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-12 21:20                   ` Anders Lindgren
@ 2017-07-13 20:22                     ` Alan Third
  2017-07-16 18:43                       ` Anders Lindgren
  0 siblings, 1 reply; 27+ messages in thread
From: Alan Third @ 2017-07-13 20:22 UTC (permalink / raw)
  To: Anders Lindgren
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Emacs-Devel devel

On Wed, Jul 12, 2017 at 11:20:57PM +0200, Anders Lindgren wrote:
> > We could disable the warning:
> >
> >     #pragma clang diagnostic push
> >     #pragma clang diagnostic ignored "-Wobjc-method-access"
> >       if ([win respondsToSelector: @selector(setTabbingMode:)])
> >         [win setTabbingMode: NSWindowTabbingModeDisallowed];
> >     #pragma clang diagnostic pop
> 
<snip>
> 
> The end result would look like:
> 
>       NS_SILENCE_MISSING_METHOD_WARNING_BEGIN
>       if ([win respondsToSelector: @selector(setTabbingMode:)])
>         [win setTabbingMode: NSWindowTabbingModeDisallowed];
>       NS_SILENCE_MISSING_METHOD_WARNING_END

I like this option, but after a lot of messing about I’m pretty sure
that gcc doesn’t let you silence this warning.

So, unless we don’t care about gcc warnings for the NS build, we could
try using performSelector:

    [win performSelector: @selector(setTabbingMode:)
              withObject: (id)NSWindowTabbingModeDisallowed];

Which only supports one parameter, so works here but not necessarily
anywhere else we might want to try this.

Or back to the first suggestion and fake the methods when they’re not
there. But that doesn’t help get rid of the need for multiple
binaries.
-- 
Alan Third



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-13 20:22                     ` Alan Third
@ 2017-07-16 18:43                       ` Anders Lindgren
  2017-07-16 23:01                         ` Alan Third
  0 siblings, 1 reply; 27+ messages in thread
From: Anders Lindgren @ 2017-07-16 18:43 UTC (permalink / raw)
  To: Alan Third; +Cc: Paul Michael Reilly, Jean-Christophe Helary, Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 2244 bytes --]

On Thu, Jul 13, 2017 at 10:22 PM, Alan Third <alan@idiocy.org> wrote:

> On Wed, Jul 12, 2017 at 11:20:57PM +0200, Anders Lindgren wrote:
> > The end result would look like:
> >
> >       NS_SILENCE_MISSING_METHOD_WARNING_BEGIN
> >       if ([win respondsToSelector: @selector(setTabbingMode:)])
> >         [win setTabbingMode: NSWindowTabbingModeDisallowed];
> >       NS_SILENCE_MISSING_METHOD_WARNING_END
>
> I like this option, but after a lot of messing about I’m pretty sure
> that gcc doesn’t let you silence this warning.
>

Unfortunately, I came to the same conclusion.


So, unless we don’t care about gcc warnings for the NS build, we could
> try using performSelector:
>
>     [win performSelector: @selector(setTabbingMode:)
>               withObject: (id)NSWindowTabbingModeDisallowed];
>
Which only supports one parameter, so works here but not necessarily
> anywhere else we might want to try this.
>


It doesn't feel right, as it bypasses all type checking even when building
on modern systems. And, as you mentioned, it only supports one parameter.

I tried to figure out if gcc or clang was used when building on 10.6.8, but
ran out of time (and won't have the chance to do it again anytime soon). I
did conclude that it comes with both a real "gcc" and a real "clang", so
presumably gcc is used. (Surprisingly, more modern versions of macOS seems
to map the command "gcc" to "clang".)

A warning-free build is a must on modern system (which use clang). It would
be nice on older system, I guess, but it would be hard to enforce. (We
could even lobby to add the option to future gcc versions, for the benefit
of GNUStep, but it would not help the situation on older macOS versions.)


Or back to the first suggestion and fake the methods when they’re not
> there. But that doesn’t help get rid of the need for multiple
> binaries.
>

Not an appealing solution.


My gut feeling is to go with the NS_SILENCE_MISSING_METHOD_WARNING_BEGIN
solution, as it work on modern macOS systems, it retains type checking, and
it give us a single location to describe the situation and to modify the
macro, if there should be a need for it in the future.

    -- Anders

[-- Attachment #2: Type: text/html, Size: 3425 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-16 18:43                       ` Anders Lindgren
@ 2017-07-16 23:01                         ` Alan Third
  2017-07-17 20:09                           ` Charles A. Roelli
  0 siblings, 1 reply; 27+ messages in thread
From: Alan Third @ 2017-07-16 23:01 UTC (permalink / raw)
  To: Anders Lindgren
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Charles A. Roelli,
	Emacs-Devel devel

On Sun, Jul 16, 2017 at 08:43:25PM +0200, Anders Lindgren wrote:
> I tried to figure out if gcc or clang was used when building on 10.6.8, but
> ran out of time (and won't have the chance to do it again anytime soon). I
> did conclude that it comes with both a real "gcc" and a real "clang", so
> presumably gcc is used. (Surprisingly, more modern versions of macOS seems
> to map the command "gcc" to "clang".)

Charles can maybe answer this for us, as he uses 10.6.

> A warning-free build is a must on modern system (which use clang). It would
> be nice on older system, I guess, but it would be hard to enforce. (We
> could even lobby to add the option to future gcc versions, for the benefit
> of GNUStep, but it would not help the situation on older macOS versions.)

> My gut feeling is to go with the NS_SILENCE_MISSING_METHOD_WARNING_BEGIN
> solution, as it work on modern macOS systems, it retains type checking, and
> it give us a single location to describe the situation and to modify the
> macro, if there should be a need for it in the future.

Agreed.

I think that a lot (if not most) of the code that we might want to use
this on won’t work on GNUstep at all, so we could still exclude it
from building there if the warnings are too much.

-- 
Alan Third



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-16 23:01                         ` Alan Third
@ 2017-07-17 20:09                           ` Charles A. Roelli
  2017-07-18  6:06                             ` Anders Lindgren
  0 siblings, 1 reply; 27+ messages in thread
From: Charles A. Roelli @ 2017-07-17 20:09 UTC (permalink / raw)
  To: Alan Third, Anders Lindgren
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Emacs-Devel devel

clang and gcc seem different on 10.6 (can't say for certain, though):


$ which gcc
/usr/bin/gcc
$ gcc --version
i686-apple-darwin10-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 
5658) (LLVM build 2335.15.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ which clang
/usr/bin/clang
$ clang --version
Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin10.8.0
Thread model: posix




On 17/07/2017 01:01, Alan Third wrote:
> On Sun, Jul 16, 2017 at 08:43:25PM +0200, Anders Lindgren wrote:
>> I tried to figure out if gcc or clang was used when building on 10.6.8, but
>> ran out of time (and won't have the chance to do it again anytime soon). I
>> did conclude that it comes with both a real "gcc" and a real "clang", so
>> presumably gcc is used. (Surprisingly, more modern versions of macOS seems
>> to map the command "gcc" to "clang".)
> Charles can maybe answer this for us, as he uses 10.6.
>
>> A warning-free build is a must on modern system (which use clang). It would
>> be nice on older system, I guess, but it would be hard to enforce. (We
>> could even lobby to add the option to future gcc versions, for the benefit
>> of GNUStep, but it would not help the situation on older macOS versions.)
>> My gut feeling is to go with the NS_SILENCE_MISSING_METHOD_WARNING_BEGIN
>> solution, as it work on modern macOS systems, it retains type checking, and
>> it give us a single location to describe the situation and to modify the
>> macro, if there should be a need for it in the future.
> Agreed.
>
> I think that a lot (if not most) of the code that we might want to use
> this on won’t work on GNUstep at all, so we could still exclude it
> from building there if the warnings are too much.
>




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-17 20:09                           ` Charles A. Roelli
@ 2017-07-18  6:06                             ` Anders Lindgren
  2017-07-18 18:33                               ` Charles A. Roelli
  0 siblings, 1 reply; 27+ messages in thread
From: Anders Lindgren @ 2017-07-18  6:06 UTC (permalink / raw)
  To: Charles A. Roelli
  Cc: Paul Michael Reilly, Alan Third, Jean-Christophe Helary,
	Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 2395 bytes --]

Hi Charles, thanks for replying!

Yes, that is what I saw as well. The question is which compiler is used (by
default) when building Emacs on 10.6. I guess it is "gcc", but I didn't
have time to verify this.

    -- Anders

On Mon, Jul 17, 2017 at 10:09 PM, Charles A. Roelli <charles@aurox.ch>
wrote:

> clang and gcc seem different on 10.6 (can't say for certain, though):
>
>
> $ which gcc
> /usr/bin/gcc
> $ gcc --version
> i686-apple-darwin10-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build
> 5658) (LLVM build 2335.15.00)
> Copyright (C) 2007 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> $ which clang
> /usr/bin/clang
> $ clang --version
> Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
> Target: x86_64-apple-darwin10.8.0
> Thread model: posix
>
>
>
>
>
> On 17/07/2017 01:01, Alan Third wrote:
>
>> On Sun, Jul 16, 2017 at 08:43:25PM +0200, Anders Lindgren wrote:
>>
>>> I tried to figure out if gcc or clang was used when building on 10.6.8,
>>> but
>>> ran out of time (and won't have the chance to do it again anytime soon).
>>> I
>>> did conclude that it comes with both a real "gcc" and a real "clang", so
>>> presumably gcc is used. (Surprisingly, more modern versions of macOS
>>> seems
>>> to map the command "gcc" to "clang".)
>>>
>> Charles can maybe answer this for us, as he uses 10.6.
>>
>> A warning-free build is a must on modern system (which use clang). It
>>> would
>>> be nice on older system, I guess, but it would be hard to enforce. (We
>>> could even lobby to add the option to future gcc versions, for the
>>> benefit
>>> of GNUStep, but it would not help the situation on older macOS versions.)
>>> My gut feeling is to go with the NS_SILENCE_MISSING_METHOD_WARNING_BEGIN
>>> solution, as it work on modern macOS systems, it retains type checking,
>>> and
>>> it give us a single location to describe the situation and to modify the
>>> macro, if there should be a need for it in the future.
>>>
>> Agreed.
>>
>> I think that a lot (if not most) of the code that we might want to use
>> this on won’t work on GNUstep at all, so we could still exclude it
>> from building there if the warnings are too much.
>>
>>
>

[-- Attachment #2: Type: text/html, Size: 3212 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-18  6:06                             ` Anders Lindgren
@ 2017-07-18 18:33                               ` Charles A. Roelli
  2017-07-18 22:16                                 ` Alan Third
  0 siblings, 1 reply; 27+ messages in thread
From: Charles A. Roelli @ 2017-07-18 18:33 UTC (permalink / raw)
  To: Anders Lindgren
  Cc: Paul Michael Reilly, Alan Third, Jean-Christophe Helary,
	Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 3171 bytes --]

It does seem to be gcc:

(snippet from output of 'make V=1' when compiling src/nsterm.m):
gcc -std=gnu99 -c -Demacs -I. -I. -I../lib -I../lib -D_REENTRANT -I
[...]  -MMD -MF deps/nsterm.d -MP -O0 -g3 nsterm.m


And IIRC 'gcc' is symlinked to 'clang' on later macOS versions.


On 18/07/2017 08:06, Anders Lindgren wrote:
> Hi Charles, thanks for replying!
>
> Yes, that is what I saw as well. The question is which compiler is 
> used (by default) when building Emacs on 10.6. I guess it is "gcc", 
> but I didn't have time to verify this.
>
>     -- Anders
>
> On Mon, Jul 17, 2017 at 10:09 PM, Charles A. Roelli <charles@aurox.ch 
> <mailto:charles@aurox.ch>> wrote:
>
>     clang and gcc seem different on 10.6 (can't say for certain, though):
>
>
>     $ which gcc
>     /usr/bin/gcc
>     $ gcc --version
>     i686-apple-darwin10-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc.
>     build 5658) (LLVM build 2335.15.00)
>     Copyright (C) 2007 Free Software Foundation, Inc.
>     This is free software; see the source for copying conditions.
>     There is NO
>     warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
>     PURPOSE.
>
>     $ which clang
>     /usr/bin/clang
>     $ clang --version
>     Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM
>     3.0svn)
>     Target: x86_64-apple-darwin10.8.0
>     Thread model: posix
>
>
>
>
>
>     On 17/07/2017 01:01, Alan Third wrote:
>
>         On Sun, Jul 16, 2017 at 08:43:25PM +0200, Anders Lindgren wrote:
>
>             I tried to figure out if gcc or clang was used when
>             building on 10.6.8, but
>             ran out of time (and won't have the chance to do it again
>             anytime soon). I
>             did conclude that it comes with both a real "gcc" and a
>             real "clang", so
>             presumably gcc is used. (Surprisingly, more modern
>             versions of macOS seems
>             to map the command "gcc" to "clang".)
>
>         Charles can maybe answer this for us, as he uses 10.6.
>
>             A warning-free build is a must on modern system (which use
>             clang). It would
>             be nice on older system, I guess, but it would be hard to
>             enforce. (We
>             could even lobby to add the option to future gcc versions,
>             for the benefit
>             of GNUStep, but it would not help the situation on older
>             macOS versions.)
>             My gut feeling is to go with the
>             NS_SILENCE_MISSING_METHOD_WARNING_BEGIN
>             solution, as it work on modern macOS systems, it retains
>             type checking, and
>             it give us a single location to describe the situation and
>             to modify the
>             macro, if there should be a need for it in the future.
>
>         Agreed.
>
>         I think that a lot (if not most) of the code that we might
>         want to use
>         this on won’t work on GNUstep at all, so we could still exclude it
>         from building there if the warnings are too much.
>
>
>


[-- Attachment #2: Type: text/html, Size: 5479 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-18 18:33                               ` Charles A. Roelli
@ 2017-07-18 22:16                                 ` Alan Third
  2017-07-19  4:57                                   ` Charles A. Roelli
  0 siblings, 1 reply; 27+ messages in thread
From: Alan Third @ 2017-07-18 22:16 UTC (permalink / raw)
  To: Charles A. Roelli
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Anders Lindgren,
	Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 408 bytes --]

On Tue, Jul 18, 2017 at 08:33:05PM +0200, Charles A. Roelli wrote:
> It does seem to be gcc:
> 
> (snippet from output of 'make V=1' when compiling src/nsterm.m):
> gcc -std=gnu99 -c -Demacs -I. -I. -I../lib -I../lib -D_REENTRANT -I
> [...]  -MMD -MF deps/nsterm.d -MP -O0 -g3 nsterm.m

Can you check whether the attached patch results in a compilation
warning from nsterm.m for you, please?

-- 
Alan Third

[-- Attachment #2: 0001-Use-a-run-time-check-for-macOS-Sierra-tabbing-suppor.patch --]
[-- Type: text/plain, Size: 3081 bytes --]

From dd73f985107937ee1c593f0878bdd5b01178af1c Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
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


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-18 22:16                                 ` Alan Third
@ 2017-07-19  4:57                                   ` Charles A. Roelli
  2017-07-21 20:31                                     ` Anders Lindgren
  0 siblings, 1 reply; 27+ messages in thread
From: Charles A. Roelli @ 2017-07-19  4:57 UTC (permalink / raw)
  To: Alan Third
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Anders Lindgren,
	Emacs-Devel devel

Yes:

   CC       nsterm.o
nsterm.m: In function ‘-[EmacsView initFrameFromEmacs:]’:
nsterm.m:7079: warning: ‘NSWindow’ may not respond to ‘-setTabbingMode:’
nsterm.m:7079: warning: (Messages without a matching method signature
nsterm.m:7079: warning: will be assumed to return ‘id’ and accept
nsterm.m:7079: warning: ‘...’ as arguments.)



On 19/07/2017 00:16, Alan Third wrote:
> On Tue, Jul 18, 2017 at 08:33:05PM +0200, Charles A. Roelli wrote:
>> It does seem to be gcc:
>>
>> (snippet from output of 'make V=1' when compiling src/nsterm.m):
>> gcc -std=gnu99 -c -Demacs -I. -I. -I../lib -I../lib -D_REENTRANT -I
>> [...]  -MMD -MF deps/nsterm.d -MP -O0 -g3 nsterm.m
> Can you check whether the attached patch results in a compilation
> warning from nsterm.m for you, please?
>




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-19  4:57                                   ` Charles A. Roelli
@ 2017-07-21 20:31                                     ` Anders Lindgren
  2017-07-22 11:22                                       ` Alan Third
  0 siblings, 1 reply; 27+ messages in thread
From: Anders Lindgren @ 2017-07-21 20:31 UTC (permalink / raw)
  To: Charles A. Roelli
  Cc: Paul Michael Reilly, Alan Third, Jean-Christophe Helary,
	Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 1902 bytes --]

Hi!

I just gave this matter another think-through. I don't think we ever will
be able to build an Emacs on an old system like 10.6.8 that will be able to
use all the bells and whistles when executed on a new system. However, the
other way around could, at some point in time, be possible.

In other words, one solution would be something like:

    #ifdef NS_IMPL_COCOA
    #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
    if ([win respondsToSelector: @selector(setTabbingMode)])
      [win setTabbingMode: NSWindowTabbingModeDisallowed];
    #endif
    #endif

This should not generate any warning in any context (gcc or clang, macOS or
GNUStep). The resulting code will run correctly on the system it was built
for, and it will run correctly on older systems. The only thing that
doesn't work is when Emacs is built on an old system, features provided by
newer OS versions aren't included.

    -- Anders

On Wed, Jul 19, 2017 at 6:57 AM, Charles A. Roelli <charles@aurox.ch> wrote:

> Yes:
>
>   CC       nsterm.o
> nsterm.m: In function ‘-[EmacsView initFrameFromEmacs:]’:
> nsterm.m:7079: warning: ‘NSWindow’ may not respond to ‘-setTabbingMode:’
> nsterm.m:7079: warning: (Messages without a matching method signature
> nsterm.m:7079: warning: will be assumed to return ‘id’ and accept
> nsterm.m:7079: warning: ‘...’ as arguments.)
>
>
>
>
> On 19/07/2017 00:16, Alan Third wrote:
>
>> On Tue, Jul 18, 2017 at 08:33:05PM +0200, Charles A. Roelli wrote:
>>
>>> It does seem to be gcc:
>>>
>>> (snippet from output of 'make V=1' when compiling src/nsterm.m):
>>> gcc -std=gnu99 -c -Demacs -I. -I. -I../lib -I../lib -D_REENTRANT -I
>>> [...]  -MMD -MF deps/nsterm.d -MP -O0 -g3 nsterm.m
>>>
>> Can you check whether the attached patch results in a compilation
>> warning from nsterm.m for you, please?
>>
>>
>

[-- Attachment #2: Type: text/html, Size: 3009 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-21 20:31                                     ` Anders Lindgren
@ 2017-07-22 11:22                                       ` Alan Third
  2017-07-23 12:17                                         ` NS runtime feature detection (was: Mac OS Sierra tab feature breaks C-x 5 2) Alan Third
  2017-07-23 22:35                                         ` Mac OS Sierra tab feature breaks C-x 5 2 Tim Cross
  0 siblings, 2 replies; 27+ messages in thread
From: Alan Third @ 2017-07-22 11:22 UTC (permalink / raw)
  To: Anders Lindgren
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Charles A. Roelli,
	Emacs-Devel devel

On Fri, Jul 21, 2017 at 10:31:27PM +0200, Anders Lindgren wrote:
> Hi!
> 
> I just gave this matter another think-through. I don't think we ever will
> be able to build an Emacs on an old system like 10.6.8 that will be able to
> use all the bells and whistles when executed on a new system. However, the
> other way around could, at some point in time, be possible.
> 
> In other words, one solution would be something like:
> 
>     #ifdef NS_IMPL_COCOA
>     #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
>     if ([win respondsToSelector: @selector(setTabbingMode)])
>       [win setTabbingMode: NSWindowTabbingModeDisallowed];
>     #endif
>     #endif
> 
> This should not generate any warning in any context (gcc or clang, macOS or
> GNUStep). The resulting code will run correctly on the system it was built
> for, and it will run correctly on older systems. The only thing that
> doesn't work is when Emacs is built on an old system, features provided by
> newer OS versions aren't included.

Unfortunately it doesn’t fix our immediate issue, which is that
setTabbingMode should be called on 10.12, but emacsformacosx.com
builds on 10.9.

I think you’re definitely right, though, that we’re not going to be
able to come up with a uniform solution. Something has to give
somewhere, and I’m tempted to say it should be 10.6. We could live
with build warnings on 10.6, or just say that code like the above
should be ifdef’d out on 10.6.

Or perhaps we provide a flag that enables a universal binary build
that doesn’t bother about hiding the warnings?

I suppose that would look like:

    ./configure --with-ns --universal-binary

    #ifdef NS_IMPL_COCOA
    #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12 \
        || defined (UNIVERSAL_BINARY)
    if ([win respondsToSelector: @selector(setTabbingMode)])
      [win setTabbingMode: NSWindowTabbingModeDisallowed];
    #endif
    #endif

-- 
Alan Third



^ permalink raw reply	[flat|nested] 27+ messages in thread

* NS runtime feature detection (was: Mac OS Sierra tab feature breaks C-x 5 2)
  2017-07-22 11:22                                       ` Alan Third
@ 2017-07-23 12:17                                         ` Alan Third
  2017-07-24 19:02                                           ` NS runtime feature detection Charles A. Roelli
  2017-07-23 22:35                                         ` Mac OS Sierra tab feature breaks C-x 5 2 Tim Cross
  1 sibling, 1 reply; 27+ messages in thread
From: Alan Third @ 2017-07-23 12:17 UTC (permalink / raw)
  To: Anders Lindgren
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Charles A. Roelli,
	Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

On Sat, Jul 22, 2017 at 12:22:30PM +0100, Alan Third wrote:
> Or perhaps we provide a flag that enables a universal binary build
> that doesn’t bother about hiding the warnings?

Attached is a first attempt at this in nsterm.m. I think I’ve got
everything, but there may be some new variables and things defined
that I’ve missed which will throw up errors in older macOS versions.

It seems ‘universal binary’ means something specific, so I went with a
different name.

Use:

    ./configure --with-ns --enable-macos-runtime-feature-detection

It will give a lot of deprecation and unknown method warnings, but
hopefully that’s all.

If you build normally there should be no (new) warnings or errors.
-- 
Alan Third

[-- Attachment #2: 0001-Use-a-run-time-check-for-macOS-Sierra-tabbing-suppor.patch --]
[-- Type: text/plain, Size: 11489 bytes --]

From 5e2c7950c404de6be42f257adf927d71ca59507d Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
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): Switch from compile-time to run-time checks.
---
 configure.ac |   6 ++++
 src/nsterm.h |  16 ++++++++-
 src/nsterm.m | 113 ++++++++++++++++++++++++++++++++++++-----------------------
 3 files changed, 91 insertions(+), 44 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/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 <http://www.gnu.org/licenses/>.  */
 
 #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..e57493afd4 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_6
+      /* 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


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: Mac OS Sierra tab feature breaks C-x 5 2
  2017-07-22 11:22                                       ` Alan Third
  2017-07-23 12:17                                         ` NS runtime feature detection (was: Mac OS Sierra tab feature breaks C-x 5 2) Alan Third
@ 2017-07-23 22:35                                         ` Tim Cross
  1 sibling, 0 replies; 27+ messages in thread
From: Tim Cross @ 2017-07-23 22:35 UTC (permalink / raw)
  To: Alan Third
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Charles A. Roelli,
	Anders Lindgren, Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 2575 bytes --]

I think we should not put too much effort into avoiding warning on 10.6.
This is a very old version, does not receive security fixes and for the
protection of users, should not be encouraging use of 10.6. IOW if your
running 10.6, expect you will see warnings for things which have been added
since and which are not supported on that platform.

Tim

On 22 July 2017 at 21:22, Alan Third <alan@idiocy.org> wrote:

> On Fri, Jul 21, 2017 at 10:31:27PM +0200, Anders Lindgren wrote:
> > Hi!
> >
> > I just gave this matter another think-through. I don't think we ever will
> > be able to build an Emacs on an old system like 10.6.8 that will be able
> to
> > use all the bells and whistles when executed on a new system. However,
> the
> > other way around could, at some point in time, be possible.
> >
> > In other words, one solution would be something like:
> >
> >     #ifdef NS_IMPL_COCOA
> >     #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
> >     if ([win respondsToSelector: @selector(setTabbingMode)])
> >       [win setTabbingMode: NSWindowTabbingModeDisallowed];
> >     #endif
> >     #endif
> >
> > This should not generate any warning in any context (gcc or clang, macOS
> or
> > GNUStep). The resulting code will run correctly on the system it was
> built
> > for, and it will run correctly on older systems. The only thing that
> > doesn't work is when Emacs is built on an old system, features provided
> by
> > newer OS versions aren't included.
>
> Unfortunately it doesn’t fix our immediate issue, which is that
> setTabbingMode should be called on 10.12, but emacsformacosx.com
> builds on 10.9.
>
> I think you’re definitely right, though, that we’re not going to be
> able to come up with a uniform solution. Something has to give
> somewhere, and I’m tempted to say it should be 10.6. We could live
> with build warnings on 10.6, or just say that code like the above
> should be ifdef’d out on 10.6.
>
> Or perhaps we provide a flag that enables a universal binary build
> that doesn’t bother about hiding the warnings?
>
> I suppose that would look like:
>
>     ./configure --with-ns --universal-binary
>
>     #ifdef NS_IMPL_COCOA
>     #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12 \
>         || defined (UNIVERSAL_BINARY)
>     if ([win respondsToSelector: @selector(setTabbingMode)])
>       [win setTabbingMode: NSWindowTabbingModeDisallowed];
>     #endif
>     #endif
>
> --
> Alan Third
>
>


-- 
regards,

Tim

--
Tim Cross

[-- Attachment #2: Type: text/html, Size: 3492 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: NS runtime feature detection
  2017-07-23 12:17                                         ` NS runtime feature detection (was: Mac OS Sierra tab feature breaks C-x 5 2) Alan Third
@ 2017-07-24 19:02                                           ` Charles A. Roelli
  2017-07-24 20:45                                             ` Alan Third
  0 siblings, 1 reply; 27+ messages in thread
From: Charles A. Roelli @ 2017-07-24 19:02 UTC (permalink / raw)
  To: Alan Third, Anders Lindgren
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Emacs-Devel devel

Thanks for taking the initiative with this.  Maybe it's time to open a bug?


When I try to compile with the patch applied, with this block:

@@ -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_6
+      /* 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];

while building with:

./configure --with-ns --enable-macos-runtime-feature-detection && make

I got these errors:

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)

(line numbers are off due to an intervening commit)

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...



On 23/07/2017 14:17, Alan Third wrote:
> On Sat, Jul 22, 2017 at 12:22:30PM +0100, Alan Third wrote:
>> Or perhaps we provide a flag that enables a universal binary build
>> that doesn’t bother about hiding the warnings?
> Attached is a first attempt at this in nsterm.m. I think I’ve got
> everything, but there may be some new variables and things defined
> that I’ve missed which will throw up errors in older macOS versions.
>
> It seems ‘universal binary’ means something specific, so I went with a
> different name.
>
> Use:
>
>      ./configure --with-ns --enable-macos-runtime-feature-detection
>
> It will give a lot of deprecation and unknown method warnings, but
> hopefully that’s all.
>
> If you build normally there should be no (new) warnings or errors.




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: NS runtime feature detection
  2017-07-24 19:02                                           ` NS runtime feature detection Charles A. Roelli
@ 2017-07-24 20:45                                             ` Alan Third
  0 siblings, 0 replies; 27+ messages in thread
From: Alan Third @ 2017-07-24 20:45 UTC (permalink / raw)
  To: Charles A. Roelli
  Cc: Paul Michael Reilly, Jean-Christophe Helary, Anders Lindgren,
	Emacs-Devel devel

On Mon, Jul 24, 2017 at 09:02:57PM +0200, Charles A. Roelli wrote:
> Thanks for taking the initiative with this.  Maybe it's time to open a bug?

Continued over in bug#27810.
-- 
Alan Third



^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2017-07-24 20:45 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-06 11:29 Mac OS Sierra tab feature breaks C-x 5 2 Paul Michael Reilly
2017-07-06 12:14 ` Jean-Christophe Helary
2017-07-06 12:46   ` Sebastian Christ
2017-07-06 12:53 ` Alan Third
2017-07-06 14:35   ` Alan Third
2017-07-06 15:05     ` Jean-Christophe Helary
2017-07-06 17:42       ` Alan Third
2017-07-06 22:16         ` Alan Third
2017-07-10 19:17           ` Anders Lindgren
2017-07-10 19:52             ` Alan Third
2017-07-10 20:22               ` Anders Lindgren
2017-07-12 18:23                 ` Alan Third
2017-07-12 21:20                   ` Anders Lindgren
2017-07-13 20:22                     ` Alan Third
2017-07-16 18:43                       ` Anders Lindgren
2017-07-16 23:01                         ` Alan Third
2017-07-17 20:09                           ` Charles A. Roelli
2017-07-18  6:06                             ` Anders Lindgren
2017-07-18 18:33                               ` Charles A. Roelli
2017-07-18 22:16                                 ` Alan Third
2017-07-19  4:57                                   ` Charles A. Roelli
2017-07-21 20:31                                     ` Anders Lindgren
2017-07-22 11:22                                       ` Alan Third
2017-07-23 12:17                                         ` NS runtime feature detection (was: Mac OS Sierra tab feature breaks C-x 5 2) Alan Third
2017-07-24 19:02                                           ` NS runtime feature detection Charles A. Roelli
2017-07-24 20:45                                             ` Alan Third
2017-07-23 22:35                                         ` Mac OS Sierra tab feature breaks C-x 5 2 Tim Cross

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).