Subject: bug#27059: Can't compile master branch on Mac OS X

From: Alan Third <[email-masked]>
Date: Tue, 30 May 2017 20:01:17 +0100

On Tue, May 30, 2017 at 11:36:43AM -0700, David Caldwell wrote:
> nsfns.m: In function 'compute_tip_xy':
> nsfns.m:2756: error: conversion to non-scalar type requested
> nsfns.m:2756: error: conversion to non-scalar type requested
> make[1]: *** [nsfns.o] Error 1
> make: *** [src] Error 2
> 
> This was the best I could come up with for this compiler:
> 
>     NSRect r = [screen frame];
>     if (CGRectContainsPoint (*(CGRect*)&r, *(CGPoint*)&pt))
> 
> (yuck).

Indeed.

> Maybe it would be better to fall back to the GNUStep else clause in
> these cases?

That’s exactly what I was thinking as I read through this. There’s no
reason not to, afaict it is exactly equivalent.

I’ve attached a patch that reverts to the GNUstep code in all cases
and explains why.

-- 
Alan Third
>From 1936a82c889ee6c11c7b19f126afd06e6c950565 Mon Sep 17 00:00:00 2001
From: Alan Third <[email-masked]>
Date: Tue, 30 May 2017 19:48:17 +0100
Subject: [PATCH] Fix build errors on macOS 10.6

* src/nsfns.m (compute_tip_xy): Don't use CGRectContainsPoint.
---
 src/nsfns.m | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/nsfns.m b/src/nsfns.m
index 7bac2836fe..0c865070fb 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -2752,16 +2752,19 @@ and GNUstep implementations ("distributor-specific release
 
   /* Find the screen that pt is on. */
   for (screen in [NSScreen screens])
-#ifdef NS_IMPL_COCOA
-    if (CGRectContainsPoint ((CGRect)[screen frame], (CGPoint)pt))
-#else
     if (pt.x >= screen.frame.origin.x
         && pt.x < screen.frame.origin.x + screen.frame.size.width
         && pt.y >= screen.frame.origin.y
         && pt.y < screen.frame.origin.y + screen.frame.size.height)
-#endif
       break;
 
+  /* We could use this instead of the if above:
+
+         if (CGRectContainsPoint ([screen frame], pt))
+
+     which would be neater, but it causes problems building on old
+     versions of macOS and in GNUstep. */
+
   /* Ensure in bounds.  (Note, screen origin = lower left.) */
   if (INTEGERP (left) || INTEGERP (right))
     *root_x = pt.x;
-- 
2.12.0