Subject: bug#29643: [PATCH] Silence macOS 10.13 deprecation notices (Bug#29643)

From: Alan Third <[email-masked]>
Date: Sun, 10 Dec 2017 20:27:37 +0000

* src/nsfns.m (Fx_display_backing_store):
(Fx_display_save_under): Don't use NSBackingStoreRetained or
NSBackingStoreNonretained on macOS 10.13+.
* src/nsselect.m (symbol_to_nsstring):
(ns_string_to_symbol):
(nxatoms_of_nsselect): Replace NSGeneralPboard with
NSPasteboardNameGeneral.
* src/nsterm.h: #define NSPasteboardNameGeneral to NSGeneralPboard on
GNUstep and macOS < 10.13.
* src/nsterm.m (EmacsView::resetCursorRects):
(EmacsScroller::resetCursorRects): Don't use setOnMouseEntered on
macOS 10.13+.
---
 src/nsfns.m    |  4 ++++
 src/nsselect.m |  8 ++++----
 src/nsterm.h   |  5 +++++
 src/nsterm.m   | 17 +++++++++++++++--
 4 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/nsfns.m b/src/nsfns.m
index 8172268167..064b476fb4 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1896,10 +1896,12 @@ and GNUstep implementations ("distributor-specific release
     {
     case NSBackingStoreBuffered:
       return intern ("buffered");
+#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     case NSBackingStoreRetained:
       return intern ("retained");
     case NSBackingStoreNonretained:
       return intern ("non-retained");
+#endif
     default:
       error ("Strange value for backingType parameter of frame");
     }
@@ -1953,9 +1955,11 @@ and GNUstep implementations ("distributor-specific release
     case NSBackingStoreBuffered:
       return Qt;
 
+#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     case NSBackingStoreRetained:
     case NSBackingStoreNonretained:
       return Qnil;
+#endif
 
     default:
       error ("Strange value for backingType parameter of frame");
diff --git a/src/nsselect.m b/src/nsselect.m
index 067c7788e8..d1ce9437a7 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -36,7 +36,7 @@ Updated by Christian Limpach ([email-masked])
 
 static Lisp_Object Vselection_alist;
 
-/* NSGeneralPboard is pretty much analogous to X11 CLIPBOARD */
+/* NSPasteboardNameGeneral is pretty much analogous to X11 CLIPBOARD */
 static NSString *NXPrimaryPboard;
 static NSString *NXSecondaryPboard;
 
@@ -54,7 +54,7 @@ Updated by Christian Limpach ([email-masked])
 symbol_to_nsstring (Lisp_Object sym)
 {
   CHECK_SYMBOL (sym);
-  if (EQ (sym, QCLIPBOARD))   return NSGeneralPboard;
+  if (EQ (sym, QCLIPBOARD))   return NSPasteboardNameGeneral;
   if (EQ (sym, QPRIMARY))     return NXPrimaryPboard;
   if (EQ (sym, QSECONDARY))   return NXSecondaryPboard;
   if (EQ (sym, QTEXT))        return NSStringPboardType;
@@ -70,7 +70,7 @@ Updated by Christian Limpach ([email-masked])
 static Lisp_Object
 ns_string_to_symbol (NSString *t)
 {
-  if ([t isEqualToString: NSGeneralPboard])
+  if ([t isEqualToString: NSPasteboardNameGeneral])
     return QCLIPBOARD;
   if ([t isEqualToString: NXPrimaryPboard])
     return QPRIMARY;
@@ -469,7 +469,7 @@ Updated by Christian Limpach ([email-masked])
   pasteboard_changecount
     = [[NSMutableDictionary
 	 dictionaryWithObjectsAndKeys:
-	     [NSNumber numberWithLong:0], NSGeneralPboard,
+	     [NSNumber numberWithLong:0], NSPasteboardNameGeneral,
 	     [NSNumber numberWithLong:0], NXPrimaryPboard,
 	     [NSNumber numberWithLong:0], NXSecondaryPboard,
 	     [NSNumber numberWithLong:0], NSStringPboardType,
diff --git a/src/nsterm.h b/src/nsterm.h
index c81bf5fb63..e669c95931 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1322,5 +1322,10 @@ enum NSWindowTabbingMode
     NSWindowTabbingModePreferred,
     NSWindowTabbingModeDisallowed
   };
+#endif /* !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_12)  */
+
+#if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_13)
+/* Deprecated in macOS 10.13.  */
+#define NSPasteboardNameGeneral NSGeneralPboard
 #endif
 #endif	/* HAVE_NS */
diff --git a/src/nsterm.m b/src/nsterm.m
index 50e06c94d4..07ac8f978f 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6016,7 +6016,13 @@ - (void)resetCursorRects
 
   if (!NSIsEmptyRect (visible))
     [self addCursorRect: visible cursor: currentCursor];
-  [currentCursor setOnMouseEntered: YES];
+
+#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 101300
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
+  if ([currentCursor respondsToSelector: @selector(setOnMouseEntered)])
+#endif
+    [currentCursor setOnMouseEntered: YES];
+#endif
 }

@@ -8746,7 +8752,14 @@ - (void)resetCursorRects
 
   if (!NSIsEmptyRect (visible))
     [self addCursorRect: visible cursor: [NSCursor arrowCursor]];
-  [[NSCursor arrowCursor] setOnMouseEntered: YES];
+
+#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 101300
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
+  if ([[NSCursor arrowCursor] respondsToSelector:
+                                @selector(setOnMouseEntered)])
+#endif
+    [[NSCursor arrowCursor] setOnMouseEntered: YES];
+#endif
 }

-- 

Hi Philipp, can you please check whether this patch silences the
deprecation notices?

I’m still on 10.12, so I can’t check myself.

-- 
Alan Third