]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix compiler warnings on Mac OS X 10.12
authorPo Lu <luangruo@yahoo.com>
Sun, 22 May 2022 03:02:24 +0000 (11:02 +0800)
committerPo Lu <luangruo@yahoo.com>
Sun, 22 May 2022 03:02:24 +0000 (11:02 +0800)
* 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
src/nsfns.m
src/nsxwidget.m

index 3d5eb7f9c44e1215015d62dc919a2f42ab9a7d5d..1d2d1f190bfac8c6972bb4764cd91cad0d97a6f6 100644 (file)
@@ -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=
index f82665a3000ba96fdb1332088a8876fd297e3771..a2f9c26b550988ef192f763ad1fd3196d953483b 100644 (file)
@@ -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]];
index f79873235cb5d52875d34375bc040c479742b9bc..be0eba0bcb16ec05b8b3d63b55cc447020f0a0ed 100644 (file)
@@ -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)