emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 9624f60: Fix some deprecation notices on macOS 10.1


From: Alan Third
Subject: [Emacs-diffs] master 9624f60: Fix some deprecation notices on macOS 10.14
Date: Tue, 21 May 2019 15:59:35 -0400 (EDT)

branch: master
commit 9624f609493da7c08016ba00d6895bad0fe26a0e
Author: Alan Third <address@hidden>
Commit: Alan Third <address@hidden>

    Fix some deprecation notices on macOS 10.14
    
    * src/nsimage.m ([EmacsImage setXBMColor:]): Replace colorSpaceName
    code.
    * src/nsmenu.m ([EmacsDialogPanel initWithContentRect:styleMask:]):
    Remove reference to oneShot.
    * src/nsterm.h (ns_enable_screen_updates): Remove function prototype.
    (NSPasteboardTypeString):
    (NSPasteboardTypeTabularText):
    (NSControlStateValueOn):
    (NSControlStateValueOff):
    (NSBezelStyleRounded):
    (NSPasteboardTypeURL): Define new names and replace all callers.
    * src/nsterm.m ([EmacsColor colorUsingDefaultColorSpace]): Replace
    calls to colorUsingColorSpaceName on macOS > 10.7.
    ([EmacsView performDragOperation:]): Add FIXME about deprecation.
    (ns_disable_screen_updates):
    (ns_enable_screen_updates): Remove functions and all callers.
    (disable_screen_updates_count): Remove variable.
    * src/macfont.m (macfont_draw): Use CGContext instead of graphicsPort
    on macOS >= 10.10
---
 src/macfont.m  | 13 ++++++++-
 src/nsimage.m  |  4 +--
 src/nsmenu.m   |  7 ++---
 src/nsselect.m | 14 ++++-----
 src/nsterm.h   | 14 ++++++---
 src/nsterm.m   | 91 +++++++++++++++++++---------------------------------------
 src/xdisp.c    | 12 --------
 7 files changed, 63 insertions(+), 92 deletions(-)

diff --git a/src/macfont.m b/src/macfont.m
index d69af67..f825e62 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2818,7 +2818,18 @@ macfont_draw (struct glyph_string *s, int from, int to, 
int x, int y,
       }
   }
 
-  context = [[NSGraphicsContext currentContext] graphicsPort];
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+  if ([[NSGraphicsContext currentContext] 
respondsToSelector:@selector(CGContext)])
+#endif
+    context = [[NSGraphicsContext currentContext] CGContext];
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+  else
+#endif
+#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+    context = [[NSGraphicsContext currentContext] graphicsPort];
+#endif
   CGContextSaveGState (context);
 
   if (!CGRectIsNull (background_rect))
diff --git a/src/nsimage.m b/src/nsimage.m
index 33236c4..0249d22 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -313,8 +313,8 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
   if (bmRep == nil || color == nil)
     return self;
 
-  if ([color colorSpaceName] != NSCalibratedRGBColorSpace)
-    rgbColor = [color colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
+  if ([color colorSpace] != [NSColorSpace deviceRGBColorSpace])
+    rgbColor = [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
   else
     rgbColor = color;
 
diff --git a/src/nsmenu.m b/src/nsmenu.m
index fd13233..3fe06cd 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -668,9 +668,9 @@ ns_activate_menubar (struct frame *f)
       /* Draw radio buttons and tickboxes.  */
       if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE ||
                            wv->button_type == BUTTON_TYPE_RADIO))
-        [item setState: NSOnState];
+        [item setState: NSControlStateValueOn];
       else
-        [item setState: NSOffState];
+        [item setState: NSControlStateValueOff];
 
       [item setTag: (NSInteger)wv->call_data];
     }
@@ -1594,7 +1594,7 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, 
Lisp_Object contents)
   [cell setBordered: NO];
   [cell setEnabled: NO];
   [cell setCellAttribute: NSCellIsInsetButton to: 8];
-  [cell setBezelStyle: NSRoundedBezelStyle];
+  [cell setBezelStyle: NSBezelStyleRounded];
 
   matrix = [[NSMatrix alloc] initWithFrame: contentRect
                                       mode: NSHighlightModeMatrix
@@ -1607,7 +1607,6 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, 
Lisp_Object contents)
   [matrix autorelease];
 
   [[self contentView] addSubview: matrix];
-  [self setOneShot: YES];
   [self setReleasedWhenClosed: YES];
   [self setHidesOnDeactivate: YES];
   return self;
diff --git a/src/nsselect.m b/src/nsselect.m
index cf36c86..b044fe6 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -57,7 +57,7 @@ symbol_to_nsstring (Lisp_Object sym)
   if (EQ (sym, QCLIPBOARD))   return NSPasteboardNameGeneral;
   if (EQ (sym, QPRIMARY))     return NXPrimaryPboard;
   if (EQ (sym, QSECONDARY))   return NXSecondaryPboard;
-  if (EQ (sym, QTEXT))        return NSStringPboardType;
+  if (EQ (sym, QTEXT))        return NSPasteboardTypeString;
   return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (sym))];
 }
 
@@ -76,11 +76,11 @@ ns_string_to_symbol (NSString *t)
     return QPRIMARY;
   if ([t isEqualToString: NXSecondaryPboard])
     return QSECONDARY;
-  if ([t isEqualToString: NSStringPboardType])
+  if ([t isEqualToString: NSPasteboardTypeString])
     return QTEXT;
   if ([t isEqualToString: NSFilenamesPboardType])
     return QFILE_NAME;
-  if ([t isEqualToString: NSTabularTextPboardType])
+  if ([t isEqualToString: NSPasteboardTypeTabularText])
     return QTEXT;
   return intern ([t UTF8String]);
 }
@@ -193,7 +193,7 @@ ns_string_to_pasteboard_internal (id pb, Lisp_Object str, 
NSString *gtype)
       else
         {
          // Used for ns-own-selection-internal.
-         eassert (gtype == NSStringPboardType);
+         eassert (gtype == NSPasteboardTypeString);
           [pb setString: nsStr forType: gtype];
         }
       [nsStr release];
@@ -345,7 +345,7 @@ anything that the functions on `selection-converter-alist' 
know about.  */)
   }
 
   /* We only support copy of text.  */
-  type = NSStringPboardType;
+  type = NSPasteboardTypeString;
   target_symbol = ns_string_to_symbol (type);
   if (STRINGP (value))
     {
@@ -472,9 +472,9 @@ nxatoms_of_nsselect (void)
             [NSNumber numberWithLong:0], NSPasteboardNameGeneral,
             [NSNumber numberWithLong:0], NXPrimaryPboard,
             [NSNumber numberWithLong:0], NXSecondaryPboard,
-            [NSNumber numberWithLong:0], NSStringPboardType,
+            [NSNumber numberWithLong:0], NSPasteboardTypeString,
             [NSNumber numberWithLong:0], NSFilenamesPboardType,
-            [NSNumber numberWithLong:0], NSTabularTextPboardType,
+            [NSNumber numberWithLong:0], NSPasteboardTypeTabularText,
         nil] retain];
 }
 
diff --git a/src/nsterm.h b/src/nsterm.h
index 66e1272..1e56276 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1165,10 +1165,6 @@ extern void ns_release_autorelease_pool (void *);
 extern const char *ns_get_defaults_value (const char *key);
 extern void ns_init_locale (void);
 
-#ifdef NS_IMPL_COCOA
-extern void ns_enable_screen_updates (void);
-#endif
-
 /* in nsmenu */
 extern void update_frame_tool_bar (struct frame *f);
 extern void free_frame_tool_bar (struct frame *f);
@@ -1336,4 +1332,14 @@ enum NSWindowTabbingMode
 /* Deprecated in macOS 10.13.  */
 #define NSPasteboardNameGeneral NSGeneralPboard
 #endif
+
+#if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_14)
+/* Deprecated in macOS 10.14.  */
+#define NSPasteboardTypeString NSStringPboardType
+#define NSPasteboardTypeTabularText NSTabularTextPboardType
+#define NSPasteboardTypeURL NSURLPboardType
+#define NSControlStateValueOn NSOnState
+#define NSControlStateValueOff NSOffState
+#define NSBezelStyleRounded NSRoundedBezelStyle
+#endif
 #endif /* HAVE_NS */
diff --git a/src/nsterm.m b/src/nsterm.m
index a927c5f..0cae5e9 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -160,20 +160,28 @@ char const * nstrace_fullscreen_type_name (int fs_type)
 
 - (NSColor *)colorUsingDefaultColorSpace
 {
-  /* 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.  */
+  /* FIXME: 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 defined (NS_IMPL_COCOA) \
   && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
-  if (ns_use_srgb_colorspace
 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
-      && [NSColor respondsToSelector:
-                    @selector(colorWithSRGBRed:green:blue:alpha:)]
+  if ([NSColor respondsToSelector:
+                 @selector(colorWithSRGBRed:green:blue:alpha:)])
 #endif
-      )
-    return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]];
+    {
+      if (ns_use_srgb_colorspace)
+        return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]];
+      else
+        return [self colorUsingColorSpace: [NSColorSpace deviceRGBColorSpace]];
+    }
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+  else
 #endif
+#endif /* NS_IMPL_COCOA && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070  */
+#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
   return [self colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
+#endif
 }
 
 @end
@@ -283,9 +291,6 @@ static int ns_window_num = 0;
 static BOOL ns_fake_keydown = NO;
 #ifdef NS_IMPL_COCOA
 static BOOL ns_menu_bar_is_hidden = NO;
-
-/* The number of times NSDisableScreenUpdates has been called.  */
-static int disable_screen_updates_count = 0;
 #endif
 /* static int debug_lock = 0; */
 
@@ -688,40 +693,6 @@ ns_release_autorelease_pool (void *pool)
 }
 
 
-#ifdef NS_IMPL_COCOA
-/* Disabling screen updates can be used to make several actions appear
-   "atomic" to the end user.  It seems some actions can still update
-   the display, though.
-
-   When we re-enable screen updates the number of calls to
-   NSEnableScreenUpdates should match the number to
-   NSDisableScreenUpdates.
-
-   We use these functions to prevent the user seeing a blank frame
-   after it has been resized.  ns_set_window_size disables updates and
-   when redisplay completes unwind_redisplay enables them again
-   (bug#30699).  */
-
-static void
-ns_disable_screen_updates (void)
-{
-  NSDisableScreenUpdates ();
-  disable_screen_updates_count++;
-}
-
-void
-ns_enable_screen_updates (void)
-/* Re-enable screen updates.  Called from unwind_redisplay.  */
-{
-  while (disable_screen_updates_count > 0)
-    {
-      NSEnableScreenUpdates ();
-      disable_screen_updates_count--;
-    }
-}
-#endif
-
-
 static BOOL
 ns_menu_bar_should_be_hidden (void)
 /* True, if the menu bar should be hidden.  */
@@ -1779,15 +1750,6 @@ ns_set_window_size (struct frame *f,
 
   block_input ();
 
-#ifdef NS_IMPL_COCOA
-  /* To prevent showing the user a blank frame, stop updates being
-     flushed to the screen until after redisplay has completed.  This
-     breaks live resize (resizing with a mouse), so don't do it if
-     we're in a live resize loop.  */
-  if (![view inLiveResize])
-    ns_disable_screen_updates ();
-#endif
-
   if (pixelwise)
     {
       pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
@@ -5459,14 +5421,14 @@ ns_term_init (Lisp_Object display_name)
 
   NSTRACE_MSG ("Input/output types");
 
-  ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain];
-  ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil]
+  ns_send_types = [[NSArray arrayWithObjects: NSPasteboardTypeString, nil] 
retain];
+  ns_return_types = [[NSArray arrayWithObjects: NSPasteboardTypeString, nil]
                       retain];
   ns_drag_types = [[NSArray arrayWithObjects:
-                            NSStringPboardType,
-                            NSTabularTextPboardType,
+                            NSPasteboardTypeString,
+                            NSPasteboardTypeTabularText,
                             NSFilenamesPboardType,
-                            NSURLPboardType, nil] retain];
+                            NSPasteboardTypeURL, nil] retain];
 
   /* If fullscreen is in init/default-frame-alist, focus isn't set
      right for fullscreen windows, so set this.  */
@@ -8276,6 +8238,9 @@ not_in_argv (NSString *arg)
     {
       return NO;
     }
+  /* FIXME: NSFilenamesPboardType is deprecated in 10.14, but the
+     NSURL method can only handle one file at a time.  Stick with the
+     existing code at the moment.  */
   else if ([type isEqualToString: NSFilenamesPboardType])
     {
       NSArray *files;
@@ -8370,8 +8335,8 @@ not_in_argv (NSString *arg)
 
   NSTRACE ("[EmacsView writeSelectionToPasteboard:types:]");
 
-  /* We only support NSStringPboardType.  */
-  if ([types containsObject:NSStringPboardType] == NO) {
+  /* We only support NSPasteboardTypeString.  */
+  if ([types containsObject:NSPasteboardTypeString] == NO) {
     return NO;
   }
 
@@ -8385,7 +8350,7 @@ not_in_argv (NSString *arg)
   if (! STRINGP (val))
     return NO;
 
-  typesDeclared = [NSArray arrayWithObject:NSStringPboardType];
+  typesDeclared = [NSArray arrayWithObject:NSPasteboardTypeString];
   [pb declareTypes:typesDeclared owner:nil];
   ns_string_to_pasteboard (pb, val);
   return YES;
@@ -9047,10 +9012,12 @@ not_in_argv (NSString *arg)
       last_hit_part = horizontal ? scroll_bar_before_handle : 
scroll_bar_above_handle; break;
     case NSScrollerIncrementPage:
       last_hit_part = horizontal ? scroll_bar_after_handle : 
scroll_bar_below_handle; break;
+#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
     case NSScrollerDecrementLine:
       last_hit_part = horizontal ? scroll_bar_left_arrow : 
scroll_bar_up_arrow; break;
     case NSScrollerIncrementLine:
       last_hit_part = horizontal ? scroll_bar_right_arrow : 
scroll_bar_down_arrow; break;
+#endif
     case NSScrollerKnob:
       last_hit_part = horizontal ? scroll_bar_horizontal_handle : 
scroll_bar_handle; break;
     case NSScrollerKnobSlot:  /* GNUstep-only */
diff --git a/src/xdisp.c b/src/xdisp.c
index c561ea9..9eed74c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13986,12 +13986,6 @@ redisplay_internal (void)
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS)
   if (popup_activated ())
     {
-#ifdef NS_IMPL_COCOA
-      /* On macOS we may have disabled screen updates due to window
-         resizing.  We should re-enable them so the popup can be
-         displayed.  */
-      ns_enable_screen_updates ();
-#endif
       return;
     }
 #endif
@@ -14794,12 +14788,6 @@ unwind_redisplay (void)
 {
   redisplaying_p = false;
   unblock_buffer_flips ();
-#ifdef NS_IMPL_COCOA
-  /* On macOS we may have disabled screen updates due to window
-     resizing.  When redisplay completes we want to re-enable
-     them.  */
-  ns_enable_screen_updates ();
-#endif
 }
 
 



reply via email to

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