emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e5e474baae: Fix compiler warnings on Mac OS X 10.12


From: Po Lu
Subject: master e5e474baae: Fix compiler warnings on Mac OS X 10.12
Date: Sat, 21 May 2022 23:02:38 -0400 (EDT)

branch: master
commit e5e474baaec391fe2a84fab1ebae978d9355dc2f
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix compiler warnings on Mac OS X 10.12
    
    * configure.ac: Check for Mac OS X 12 and link with
    UniformTypeIdentifiers.framework.
    
    * src/nsfns.m (IOMasterPort): Define to `IOMainPort' on Mac OS X
    12.
    (ns_implicitly_set_icon_type, Fns_read_file_name):
    * src/nsxwidget.m: ([XwWebView
    initWithFrame:configuration:xwidget:]): Fix uses of obsolete
    things.
---
 configure.ac    | 13 +++++++++++++
 src/nsfns.m     | 38 ++++++++++++++++++++++++++++++++++++--
 src/nsxwidget.m |  3 +++
 3 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3d5eb7f9c4..1d2d1f190b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2081,6 +2081,16 @@ Either fix this, or re-configure with the option 
'--without-ns'.])])
     fi
   fi
 
+  AC_CACHE_CHECK([for Mac OS X 12.0 or later],
+                 [emacs_cv_macosx_12_0],
+                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <AvailabilityMacros.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
+Mac OS X 12.x or later.
+#endif
+                 ]])], [emacs_cv_macosx_12_0=no],
+                 [emacs_cv_macosx_12_0=yes]))
+
   if test "${with_native_image_api}" = yes; then
      AC_DEFINE(HAVE_NATIVE_IMAGE_API, 1, [Define to use native OS APIs for 
images.])
      NATIVE_IMAGE_API="yes (ns)"
@@ -6216,6 +6226,9 @@ case "$opsys" in
      if test "$NS_IMPL_COCOA" = "yes"; then
         libs_nsgui="$libs_nsgui -framework IOKit -framework Carbon \
                     -framework IOSurface -framework QuartzCore"
+        if test "$emacs_cv_macosx_12_0" = "yes"; then
+         libs_nsgui="$libs_nsgui -framework UniformTypeIdentifiers"
+       fi
      fi
    else
      libs_nsgui=
diff --git a/src/nsfns.m b/src/nsfns.m
index f82665a300..a2f9c26b55 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -47,6 +47,13 @@ GNUstep port and post-20 update by Adrian Robert 
(arobert@cogsci.ucsd.edu)
 #ifdef NS_IMPL_COCOA
 #include <IOKit/graphics/IOGraphicsLib.h>
 #include "macfont.h"
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
+#include <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
+#define IOMasterPort IOMainPort
+#endif
+#endif
 #endif
 
 #ifdef HAVE_NS
@@ -789,11 +796,13 @@ ns_implicitly_set_icon_type (struct frame *f)
   Lisp_Object chain, elt;
   NSAutoreleasePool *pool;
   BOOL setMini = YES;
+  NSWorkspace *workspace;
 
   NSTRACE ("ns_implicitly_set_icon_type");
 
   block_input ();
   pool = [[NSAutoreleasePool alloc] init];
+  workspace = [NSWorkspace sharedWorkspace];
   if (f->output_data.ns->miniimage
       && [[NSString stringWithLispString:f->name]
                isEqualToString: [(NSImage *)f->output_data.ns->miniimage 
name]])
@@ -838,7 +847,19 @@ ns_implicitly_set_icon_type (struct frame *f)
 
   if (image == nil)
     {
-      image = [[[NSWorkspace sharedWorkspace] iconForFileType: @"text"] 
retain];
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000
+      if ([workspace respondsToSelector: @selector (iconForContentType:)])
+#endif
+       image = [[workspace iconForContentType:
+                             [UTType typeWithIdentifier: @"text"]] retain];
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000
+      else
+#endif
+#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000
+       image = [[workspace iconForFileType: @"text"] retain];
+#endif
       setMini = NO;
     }
 
@@ -1757,7 +1778,20 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only 
directories.  */)
   ns_fd_data.ret = NO;
 #ifdef NS_IMPL_COCOA
   if (! NILP (mustmatch) || ! NILP (dir_only_p))
-    [panel setAllowedFileTypes: nil];
+    {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000
+      if ([panel respondsToSelector: @selector (setAllowedContentTypes:)])
+#endif
+       [panel setAllowedContentTypes: [NSArray array]];
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000
+      else
+#endif
+#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 120000
+       [panel setAllowedFileTypes: nil];
+#endif
+    }
   if (dirS) [panel setDirectoryURL: [NSURL fileURLWithPath: dirS]];
   if (initS && NILP (Ffile_directory_p (init)))
     [panel setNameFieldStringValue: [initS lastPathComponent]];
diff --git a/src/nsxwidget.m b/src/nsxwidget.m
index f79873235c..be0eba0bcb 100644
--- a/src/nsxwidget.m
+++ b/src/nsxwidget.m
@@ -69,10 +69,13 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
   [configuration.preferences setValue:@YES
                                forKey:@"developerExtrasEnabled"];
 
+#if 0 /* Plugins are not supported by Mac OS X anymore.  */
   Lisp_Object enablePlugins =
     Fintern (build_string ("xwidget-webkit-enable-plugins"), Qnil);
+
   if (!EQ (Fsymbol_value (enablePlugins), Qnil))
     configuration.preferences.plugInsEnabled = YES;
+#endif
 
   self = [super initWithFrame:frame configuration:configuration];
   if (self)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]