unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: FYI: Deprecations and Warnings for nsterm.m on Sierra
       [not found] <315BE3C4-D984-470E-A4B4-20C8148FBA5A@play-bow.org>
@ 2016-08-08 20:04 ` Alan Third
  2016-08-18 19:04 ` [PATCH] Fix macOS 12 deprecation notices Alan Third
  1 sibling, 0 replies; 5+ messages in thread
From: Alan Third @ 2016-08-08 20:04 UTC (permalink / raw)
  To: Bob Halley; +Cc: emacs-devel

Hi Bob, it’s generally a good idea to send this stuff to emacs-devel
rather than direct to myself. That way more people will get to see it.

On Sat, Aug 06, 2016 at 08:47:35AM -0700, Bob Halley wrote:
> I don't want to have to file papers, so I'm not submitting a patch,
> but a bunch of constants have been renamed and the old forms now
> cause deprecation warnings. E.g. "NSLeftMouseUp" becomes
> "NSEventTypeLeftMouseUp". It makes for an ugly compile as there are
> like 147 quite verbose warnings, but everything still works.
> 
> A possible approach to fixing this is to use the new names, and
> #define the new names to the old values on systems older than 10.12
> (or on NextStep).

That would be my preferred solution, I think.

> The affected symbols are:
> 
> NSEventModifierFlagCommand was NSCommandKeyMask
> NSEventModifierFlagControl was NSControlKeyMask
> NSEventModifierFlagHelp was NSHelpKeyMask
> NSEventModifierFlagNumericPad was NSNumericPadKeyMask
> NSEventModifierFlagOption was NSAlternateKeyMask
> NSEventModifierFlagShift was NSShiftKeyMask
> NSCompositingOperationSourceOver was NSCompositeSourceOver
> NSEventMaskApplicationDefined was NSApplicationDefinedMask
> NSEventTypeApplicationDefined was NSApplicationDefined
> NSEventTypeCursorUpdate was NSCursorUpdate
> NSEventTypeMouseMoved was NSMouseMoved
> NSEventTypeLeftMouseDown was NSLeftMouseDown
> NSEventTypeRightMouseDown was NSRightMouseDown
> NSEventTypeOtherMouseDown was NSOtherMouseDown
> NSEventTypeLeftMouseUp was NSLeftMouseUp
> NSEventTypeRightMouseUp was NSRightMouseUp
> NSEventTypeOtherMouseUp was NSOtherMouseUp
> NSEventTypeLeftMouseDragged was NSLeftMouseDragged
> NSEventTypeRightMouseDragged was NSRightMouseDragged
> NSEventTypeOtherMouseDragged was NSOtherMouseDragged
> NSEventTypeScrollWheel was NSScrollWheel
> NSEventTypeKeyDown was NSKeyDown
> NSEventTypeKeyUp was NSKeyUp
> NSEventTypeFlagsChanged was NSFlagsChanged
> NSEventMaskAny was NSAnyEventMask
> NSWindowStyleMaskBorderless was NSBorderlessWindowMask
> NSWindowStyleMaskClosable was NSClosableWindowMask
> NSWindowStyleMaskFullScreen was NSFullScreenWindowMask
> NSWindowStyleMaskMiniaturizable was NSMiniaturizableWindowMask
> NSWindowStyleMaskResizable was NSResizableWindowMask
> NSWindowStyleMaskTitled was NSTitledWindowMask
> NSAlertStyleCritical was NSCriticalAlertStyle
> NSControlSizeRegular was NSRegularControlSize
> 
> In the code making a "fake event" at nsterm.m:8470, it says that [e
> context] is always nil. Probably just replacing this with nil is
> safe, but I don't know enough to be sure. Otherwise I suppose you
> could just call [e context] on older stuff, and say nil on 10.12 and
> later.
> 
> In the invocation of [NSApp registerServicesMenuSendTypes:
> ns_send_types returnTypes: nil] at nsterm.m:6941, it complains that
> returnTypes is being set to nil but is supposed to be never-nil. My
> guess here is to pass ns_return_types, which the code creates but
> does not seem to use, but again I don't know enough to be sure!

I think I’ve looked at both of these and came to the same conclusion,
but also didn’t feel entirely confident so just left them. I’ll maybe
make the change and try running it myself for a while to see how it
goes.
-- 
Alan Third



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Fix macOS 12 deprecation notices
       [not found] <315BE3C4-D984-470E-A4B4-20C8148FBA5A@play-bow.org>
  2016-08-08 20:04 ` FYI: Deprecations and Warnings for nsterm.m on Sierra Alan Third
@ 2016-08-18 19:04 ` Alan Third
  2016-08-20 23:15   ` Bob Halley
  2016-08-21  6:59   ` Kalle Olavi Niemitalo
  1 sibling, 2 replies; 5+ messages in thread
From: Alan Third @ 2016-08-18 19:04 UTC (permalink / raw)
  To: Bob Halley; +Cc: emacs-devel

* src/nsterm.h: Add #defines to allow older versions of macOS to use the
new constant names.
* src/nsmenu.m: Replace old constant names with new.
* src/nsterm.m: Replace old constant names with new.
* src/nsfns.m: Replace old constant names with new.
---
 src/nsfns.m  |  12 ++---
 src/nsmenu.m |  10 ++--
 src/nsterm.h |  41 ++++++++++++++++
 src/nsterm.m | 152 +++++++++++++++++++++++++++++------------------------------
 4 files changed, 127 insertions(+), 88 deletions(-)

diff --git a/src/nsfns.m b/src/nsfns.m
index 051e509..4566b7e 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1582,7 +1582,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
      The file dialog may pop up a confirm dialog after Ok has been pressed,
      so we can not simply pop down on the Ok/Cancel press.
    */
-  nxev = [NSEvent otherEventWithType: NSApplicationDefined
+  nxev = [NSEvent otherEventWithType: NSEventTypeApplicationDefined
                             location: NSMakePoint (0, 0)
                        modifierFlags: 0
                            timestamp: 0
@@ -2193,7 +2193,7 @@ and GNUstep implementations ("distributor-specific release
      errors aren't returned and executeAndReturnError hangs forever.
      Post an event that runs applescript and then start the event loop.
      The event loop is exited when the script is done.  */
-  nxev = [NSEvent otherEventWithType: NSApplicationDefined
+  nxev = [NSEvent otherEventWithType: NSEventTypeApplicationDefined
                             location: NSMakePoint (0, 0)
                        modifierFlags: 0
                            timestamp: 0
@@ -2987,7 +2987,7 @@ value is a list of the form (LEFT, TOP, RIGHT, BOTTOM).  All values are
   int i;
   BOOL ret = NO;
 
-  if ([theEvent type] != NSKeyDown) return NO;
+  if ([theEvent type] != NSEventTypeKeyDown) return NO;
   s = [theEvent characters];
 
   for (i = 0; i < [s length]; ++i)
@@ -3006,7 +3006,7 @@ value is a list of the form (LEFT, TOP, RIGHT, BOTTOM).  All values are
           /* Don't send command modified keys, as those are handled in the
              performKeyEquivalent method of the super class.
           */
-          if (! ([theEvent modifierFlags] & NSCommandKeyMask))
+          if (! ([theEvent modifierFlags] & NSEventModifierFlagCommand))
             {
               [panel sendEvent: theEvent];
               ret = YES;
@@ -3023,7 +3023,7 @@ value is a list of the form (LEFT, TOP, RIGHT, BOTTOM).  All values are
         case 'c': // Copy
         case 'v': // Paste
         case 'a': // Select all
-          if ([theEvent modifierFlags] & NSCommandKeyMask)
+          if ([theEvent modifierFlags] & NSEventModifierFlagCommand)
             {
               [NSApp sendAction:
                        (ch == 'x'
@@ -3039,7 +3039,7 @@ value is a list of the form (LEFT, TOP, RIGHT, BOTTOM).  All values are
         default:
           // Send all control keys, as the text field supports C-a, C-f, C-e
           // C-b and more.
-          if ([theEvent modifierFlags] & NSControlKeyMask)
+          if ([theEvent modifierFlags] & NSEventModifierFlagControl)
             {
               [panel sendEvent: theEvent];
               ret = YES;
diff --git a/src/nsmenu.m b/src/nsmenu.m
index d1f4b02..ea9f790 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -604,7 +604,7 @@ - (BOOL)performKeyEquivalent: (NSEvent *)theEvent
 -(NSString *)parseKeyEquiv: (const char *)key
 {
   const char *tpos = key;
-  keyEquivModMask = NSCommandKeyMask;
+  keyEquivModMask = NSEventModifierFlagCommand;
 
   if (!key || !strlen (key))
     return @"";
@@ -692,7 +692,6 @@ - (void)fillWithWidgetValue: (void *)wvptr frame: (struct frame *)f
   widget_value *wv = (widget_value *)wvptr;
 
   /* clear existing contents */
-  [self setMenuChangedMessagesEnabled: NO];
   [self clear];
 
   /* add new contents */
@@ -716,7 +715,6 @@ - (void)fillWithWidgetValue: (void *)wvptr frame: (struct frame *)f
         }
     }
 
-  [self setMenuChangedMessagesEnabled: YES];
 #ifdef NS_IMPL_GNUSTEP
   if ([[self window] isVisible])
     [self sizeToFit];
@@ -748,7 +746,7 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
 /*   p = [view convertPoint:p fromView: nil]; */
   p.y = NSHeight ([view frame]) - p.y;
   e = [[view window] currentEvent];
-   event = [NSEvent mouseEventWithType: NSRightMouseDown
+   event = [NSEvent mouseEventWithType: NSEventTypeRightMouseDown
                               location: p
                          modifierFlags: 0
                              timestamp: [e timestamp]
@@ -1534,7 +1532,7 @@ @implementation EmacsDialogPanel
   [img autorelease];
   [imgView autorelease];
 
-  aStyle = NSTitledWindowMask|NSClosableWindowMask|NSUtilityWindowMask;
+  aStyle = NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSUtilityWindowMask;
   flag = YES;
   rows = 0;
   cols = 1;
@@ -1792,7 +1790,7 @@ - (void)clicked: sender
 
 - (void)timeout_handler: (NSTimer *)timedEntry
 {
-  NSEvent *nxev = [NSEvent otherEventWithType: NSApplicationDefined
+  NSEvent *nxev = [NSEvent otherEventWithType: NSEventTypeApplicationDefined
                             location: NSMakePoint (0, 0)
                        modifierFlags: 0
                            timestamp: 0
diff --git a/src/nsterm.h b/src/nsterm.h
index 3d8b1a1..c12c791 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -39,6 +39,9 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #ifndef MAC_OS_X_VERSION_10_9
 #define MAC_OS_X_VERSION_10_9 1090
 #endif
+#ifndef MAC_OS_X_VERSION_10_12
+#define MAC_OS_X_VERSION_10_12 101200
+#endif
 
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
 #define HAVE_NATIVE_FS
@@ -1233,4 +1236,42 @@ extern char gnustep_base_version[];  /* version tracking */
                                 ? (min) : (((x)>(max)) ? (max) : (x)))
 #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
 
+/* macOS 10.12 deprecates a bunch of constants. */
+#if !defined (NS_IMPL_COCOA) || \
+  MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
+#define NSEventModifierFlagCommand         NSCommandKeyMask
+#define NSEventModifierFlagControl         NSControlKeyMask
+#define NSEventModifierFlagHelp            NSHelpKeyMask
+#define NSEventModifierFlagNumericPad      NSNumericPadKeyMask
+#define NSEventModifierFlagOption          NSAlternateKeyMask
+#define NSEventModifierFlagShift           NSShiftKeyMask
+#define NSCompositingOperationSourceOver   NSCompositeSourceOver
+#define NSEventMaskApplicationDefined      NSApplicationDefinedMask
+#define NSEventTypeApplicationDefined      NSApplicationDefined
+#define NSEventTypeCursorUpdate            NSCursorUpdate
+#define NSEventTypeMouseMoved              NSMouseMoved
+#define NSEventTypeLeftMouseDown           NSLeftMouseDown
+#define NSEventTypeRightMouseDown          NSRightMouseDown
+#define NSEventTypeOtherMouseDown          NSOtherMouseDown
+#define NSEventTypeLeftMouseUp             NSLeftMouseUp
+#define NSEventTypeRightMouseUp            NSRightMouseUp
+#define NSEventTypeOtherMouseUp            NSOtherMouseUp
+#define NSEventTypeLeftMouseDragged        NSLeftMouseDragged
+#define NSEventTypeRightMouseDragged       NSRightMouseDragged
+#define NSEventTypeOtherMouseDragged       NSOtherMouseDragged
+#define NSEventTypeScrollWheel             NSScrollWheel
+#define NSEventTypeKeyDown                 NSKeyDown
+#define NSEventTypeKeyUp                   NSKeyUp
+#define NSEventTypeFlagsChanged            NSFlagsChanged
+#define NSEventMaskAny                     NSAnyEventMask
+#define NSWindowStyleMaskBorderless        NSBorderlessWindowMask
+#define NSWindowStyleMaskClosable          NSClosableWindowMask
+#define NSWindowStyleMaskFullScreen        NSFullScreenWindowMask
+#define NSWindowStyleMaskMiniaturizable    NSMiniaturizableWindowMask
+#define NSWindowStyleMaskResizable         NSResizableWindowMask
+#define NSWindowStyleMaskTitled            NSTitledWindowMask
+#define NSAlertStyleCritical               NSCriticalAlertStyle
+#define NSControlSizeRegular               NSRegularControlSize
+#endif
+
 #endif	/* HAVE_NS */
diff --git a/src/nsterm.m b/src/nsterm.m
index dcc1e87..03bb011 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -230,22 +230,22 @@ - (NSColor *)colorUsingDefaultColorSpace
   NSNewlineCharacter,		0x0D,
   NSEnterCharacter,		0x8D,
 
-  0x41|NSNumericPadKeyMask,	0xAE,  /* KP_Decimal */
-  0x43|NSNumericPadKeyMask,	0xAA,  /* KP_Multiply */
-  0x45|NSNumericPadKeyMask,	0xAB,  /* KP_Add */
-  0x4B|NSNumericPadKeyMask,	0xAF,  /* KP_Divide */
-  0x4E|NSNumericPadKeyMask,	0xAD,  /* KP_Subtract */
-  0x51|NSNumericPadKeyMask,	0xBD,  /* KP_Equal */
-  0x52|NSNumericPadKeyMask,	0xB0,  /* KP_0 */
-  0x53|NSNumericPadKeyMask,	0xB1,  /* KP_1 */
-  0x54|NSNumericPadKeyMask,	0xB2,  /* KP_2 */
-  0x55|NSNumericPadKeyMask,	0xB3,  /* KP_3 */
-  0x56|NSNumericPadKeyMask,	0xB4,  /* KP_4 */
-  0x57|NSNumericPadKeyMask,	0xB5,  /* KP_5 */
-  0x58|NSNumericPadKeyMask,	0xB6,  /* KP_6 */
-  0x59|NSNumericPadKeyMask,	0xB7,  /* KP_7 */
-  0x5B|NSNumericPadKeyMask,	0xB8,  /* KP_8 */
-  0x5C|NSNumericPadKeyMask,	0xB9,  /* KP_9 */
+  0x41|NSEventModifierFlagNumericPad,	0xAE,  /* KP_Decimal */
+  0x43|NSEventModifierFlagNumericPad,	0xAA,  /* KP_Multiply */
+  0x45|NSEventModifierFlagNumericPad,	0xAB,  /* KP_Add */
+  0x4B|NSEventModifierFlagNumericPad,	0xAF,  /* KP_Divide */
+  0x4E|NSEventModifierFlagNumericPad,	0xAD,  /* KP_Subtract */
+  0x51|NSEventModifierFlagNumericPad,	0xBD,  /* KP_Equal */
+  0x52|NSEventModifierFlagNumericPad,	0xB0,  /* KP_0 */
+  0x53|NSEventModifierFlagNumericPad,	0xB1,  /* KP_1 */
+  0x54|NSEventModifierFlagNumericPad,	0xB2,  /* KP_2 */
+  0x55|NSEventModifierFlagNumericPad,	0xB3,  /* KP_3 */
+  0x56|NSEventModifierFlagNumericPad,	0xB4,  /* KP_4 */
+  0x57|NSEventModifierFlagNumericPad,	0xB5,  /* KP_5 */
+  0x58|NSEventModifierFlagNumericPad,	0xB6,  /* KP_6 */
+  0x59|NSEventModifierFlagNumericPad,	0xB7,  /* KP_7 */
+  0x5B|NSEventModifierFlagNumericPad,	0xB8,  /* KP_8 */
+  0x5C|NSEventModifierFlagNumericPad,	0xB9,  /* KP_9 */
 
   0x1B,				0x1B   /* escape */
 };
@@ -333,28 +333,28 @@ - (NSColor *)colorUsingDefaultColorSpace
 
 /* Convert modifiers in a NeXTstep event to emacs style modifiers.  */
 #define NS_FUNCTION_KEY_MASK 0x800000
-#define NSLeftControlKeyMask    (0x000001 | NSControlKeyMask)
-#define NSRightControlKeyMask   (0x002000 | NSControlKeyMask)
-#define NSLeftCommandKeyMask    (0x000008 | NSCommandKeyMask)
-#define NSRightCommandKeyMask   (0x000010 | NSCommandKeyMask)
-#define NSLeftAlternateKeyMask  (0x000020 | NSAlternateKeyMask)
-#define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask)
+#define NSLeftControlKeyMask    (0x000001 | NSEventModifierFlagControl)
+#define NSRightControlKeyMask   (0x002000 | NSEventModifierFlagControl)
+#define NSLeftCommandKeyMask    (0x000008 | NSEventModifierFlagCommand)
+#define NSRightCommandKeyMask   (0x000010 | NSEventModifierFlagCommand)
+#define NSLeftAlternateKeyMask  (0x000020 | NSEventModifierFlagOption)
+#define NSRightAlternateKeyMask (0x000040 | NSEventModifierFlagOption)
 #define EV_MODIFIERS2(flags)                          \
-    (((flags & NSHelpKeyMask) ?           \
+    (((flags & NSEventModifierFlagHelp) ?           \
            hyper_modifier : 0)                        \
      | (!EQ (ns_right_alternate_modifier, Qleft) && \
         ((flags & NSRightAlternateKeyMask) \
          == NSRightAlternateKeyMask) ? \
            parse_solitary_modifier (ns_right_alternate_modifier) : 0) \
-     | ((flags & NSAlternateKeyMask) ?                 \
+     | ((flags & NSEventModifierFlagOption) ?                 \
            parse_solitary_modifier (ns_alternate_modifier) : 0)   \
-     | ((flags & NSShiftKeyMask) ?     \
+     | ((flags & NSEventModifierFlagShift) ?     \
            shift_modifier : 0)                        \
      | (!EQ (ns_right_control_modifier, Qleft) && \
         ((flags & NSRightControlKeyMask) \
          == NSRightControlKeyMask) ? \
            parse_solitary_modifier (ns_right_control_modifier) : 0) \
-     | ((flags & NSControlKeyMask) ?      \
+     | ((flags & NSEventModifierFlagControl) ?      \
            parse_solitary_modifier (ns_control_modifier) : 0)     \
      | ((flags & NS_FUNCTION_KEY_MASK) ?  \
            parse_solitary_modifier (ns_function_modifier) : 0)    \
@@ -362,24 +362,24 @@ - (NSColor *)colorUsingDefaultColorSpace
         ((flags & NSRightCommandKeyMask) \
          == NSRightCommandKeyMask) ? \
            parse_solitary_modifier (ns_right_command_modifier) : 0) \
-     | ((flags & NSCommandKeyMask) ?      \
+     | ((flags & NSEventModifierFlagCommand) ?      \
            parse_solitary_modifier (ns_command_modifier):0))
 #define EV_MODIFIERS(e) EV_MODIFIERS2 ([e modifierFlags])
 
 #define EV_UDMODIFIERS(e)                                      \
-    ((([e type] == NSLeftMouseDown) ? down_modifier : 0)       \
-     | (([e type] == NSRightMouseDown) ? down_modifier : 0)    \
-     | (([e type] == NSOtherMouseDown) ? down_modifier : 0)    \
-     | (([e type] == NSLeftMouseDragged) ? down_modifier : 0)  \
-     | (([e type] == NSRightMouseDragged) ? down_modifier : 0) \
-     | (([e type] == NSOtherMouseDragged) ? down_modifier : 0) \
-     | (([e type] == NSLeftMouseUp)   ? up_modifier   : 0)     \
-     | (([e type] == NSRightMouseUp)   ? up_modifier   : 0)    \
-     | (([e type] == NSOtherMouseUp)   ? up_modifier   : 0))
+    ((([e type] == NSEventTypeLeftMouseDown) ? down_modifier : 0)       \
+     | (([e type] == NSEventTypeRightMouseDown) ? down_modifier : 0)    \
+     | (([e type] == NSEventTypeOtherMouseDown) ? down_modifier : 0)    \
+     | (([e type] == NSEventTypeLeftMouseDragged) ? down_modifier : 0)  \
+     | (([e type] == NSEventTypeRightMouseDragged) ? down_modifier : 0) \
+     | (([e type] == NSEventTypeOtherMouseDragged) ? down_modifier : 0) \
+     | (([e type] == NSEventTypeLeftMouseUp)   ? up_modifier   : 0)     \
+     | (([e type] == NSEventTypeRightMouseUp)   ? up_modifier   : 0)    \
+     | (([e type] == NSEventTypeOtherMouseUp)   ? up_modifier   : 0))
 
 #define EV_BUTTON(e)                                                         \
-    ((([e type] == NSLeftMouseDown) || ([e type] == NSLeftMouseUp)) ? 0 :    \
-      (([e type] == NSRightMouseDown) || ([e type] == NSRightMouseUp)) ? 2 : \
+    ((([e type] == NSEventTypeLeftMouseDown) || ([e type] == NSEventTypeLeftMouseUp)) ? 0 :    \
+      (([e type] == NSEventTypeRightMouseDown) || ([e type] == NSEventTypeRightMouseUp)) ? 2 : \
      [e buttonNumber] - 1)
 
 /* Convert the time field to a timestamp in milliseconds. */
@@ -2787,7 +2787,7 @@ static void hide_bell ()
 
       [img drawInRect: r
               fromRect: fromRect
-             operation: NSCompositeSourceOver
+             operation: NSCompositingOperationSourceOver
               fraction: 1.0
            respectFlipped: YES
                 hints: nil];
@@ -2795,7 +2795,7 @@ static void hide_bell ()
       {
         NSPoint pt = r.origin;
         pt.y += p->h;
-        [img compositeToPoint: pt operation: NSCompositeSourceOver];
+        [img compositeToPoint: pt operation: NSCompositingOperationSourceOver];
       }
 #endif
     }
@@ -3482,13 +3482,13 @@ Function modeled after x_draw_glyph_string_box ().
                               s->slice.width, s->slice.height);
       [img drawInRect: dr
              fromRect: ir
-             operation: NSCompositeSourceOver
+             operation: NSCompositingOperationSourceOver
               fraction: 1.0
            respectFlipped: YES
                 hints: nil];
 #else
       [img compositeToPoint: NSMakePoint (x, y + s->slice.height)
-                  operation: NSCompositeSourceOver];
+                  operation: NSCompositingOperationSourceOver];
 #endif
     }
 
@@ -3949,7 +3949,7 @@ overwriting cursor (usually when cursor on a tab) */
       /* OSX 10.10.1 swallows the AppDefined event we are sending ourselves
          in certain situations (rapid incoming events).
          So check if we have one, if not add one.  */
-      NSEvent *appev = [NSApp nextEventMatchingMask:NSApplicationDefinedMask
+      NSEvent *appev = [NSApp nextEventMatchingMask:NSEventMaskApplicationDefined
                                           untilDate:[NSDate distantPast]
                                              inMode:NSDefaultRunLoopMode
                                             dequeue:NO];
@@ -3972,7 +3972,7 @@ in certain situations (rapid incoming events).
           timed_entry = nil;
         }
 
-      nxev = [NSEvent otherEventWithType: NSApplicationDefined
+      nxev = [NSEvent otherEventWithType: NSEventTypeApplicationDefined
                                 location: NSMakePoint (0, 0)
                            modifierFlags: 0
                                timestamp: 0
@@ -4994,7 +4994,7 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes.
                           action: @selector (hideOtherApplications:)
                    keyEquivalent: @"h"
                          atIndex: 7];
-    [item setKeyEquivalentModifierMask: NSCommandKeyMask | NSAlternateKeyMask];
+    [item setKeyEquivalentModifierMask: NSEventModifierFlagCommand | NSEventModifierFlagOption];
     [appMenu insertItem: [NSMenuItem separatorItem] atIndex: 8];
     [appMenu insertItemWithTitle: @"Quit Emacs"
                           action: @selector (terminate:)
@@ -5138,7 +5138,7 @@ - (void)run
       pool = [[NSAutoreleasePool alloc] init];
 
       NSEvent *event =
-        [self nextEventMatchingMask:NSAnyEventMask
+        [self nextEventMatchingMask:NSEventMaskAny
                           untilDate:[NSDate distantFuture]
                              inMode:NSDefaultRunLoopMode
                             dequeue:YES];
@@ -5187,7 +5187,7 @@ - (void)sendEvent: (NSEvent *)theEvent
 #ifdef NS_IMPL_GNUSTEP
   // Keyboard events aren't propagated to file dialogs for some reason.
   if ([NSApp modalWindow] != nil &&
-      (type == NSKeyDown || type == NSKeyUp || type == NSFlagsChanged))
+      (type == NSEventTypeKeyDown || type == NSEventTypeKeyUp || type == NSEventTypeFlagsChanged))
     {
       [[NSApp modalWindow] sendEvent: theEvent];
       return;
@@ -5211,7 +5211,7 @@ - (void)sendEvent: (NSEvent *)theEvent
       represented_frame = NULL;
     }
 
-  if (type == NSApplicationDefined)
+  if (type == NSEventTypeApplicationDefined)
     {
       switch ([theEvent data2])
         {
@@ -5228,13 +5228,13 @@ - (void)sendEvent: (NSEvent *)theEvent
         }
     }
 
-  if (type == NSCursorUpdate && window == nil)
+  if (type == NSEventTypeCursorUpdate && window == nil)
     {
       fprintf (stderr, "Dropping external cursor update event.\n");
       return;
     }
 
-  if (type == NSApplicationDefined)
+  if (type == NSEventTypeApplicationDefined)
     {
       /* Events posted by ns_send_appdefined interrupt the run loop here.
          But, if a modal window is up, an appdefined can still come through,
@@ -5257,7 +5257,7 @@ - (void)sendEvent: (NSEvent *)theEvent
      It is a mouse move in an auxiliary menu, i.e. on the top right on OSX,
      such as Wifi, sound, date or similar.
      This prevents "spooky" highlighting in the frame under the menu.  */
-  if (type == NSMouseMoved && [NSApp modalWindow] == nil)
+  if (type == NSEventTypeMouseMoved && [NSApp modalWindow] == nil)
     {
       struct ns_display_info *di;
       BOOL has_focus = NO;
@@ -5412,7 +5412,7 @@ - (void) terminate: (id)sender
     == NSAlertDefaultReturn;
 #else
   NSAlert *alert = [[NSAlert alloc] init];
-  [alert setAlertStyle: NSCriticalAlertStyle];
+  [alert setAlertStyle: NSAlertStyleCritical];
   [alert setMessageText: msgFormat];
   [alert addButtonWithTitle: defaultButton];
   [alert addButtonWithTitle: alternateButton];
@@ -5796,7 +5796,7 @@ - (void)keyDown: (NSEvent *)theEvent
   /* Rhapsody and OS X give up and down events for the arrow keys */
   if (ns_fake_keydown == YES)
     ns_fake_keydown = NO;
-  else if ([theEvent type] != NSKeyDown)
+  else if ([theEvent type] != NSEventTypeKeyDown)
     return;
 
   if (!emacs_event)
@@ -5840,12 +5840,12 @@ most recently updated (I guess), which is not the correct one. */
       /* (Carbon way: [theEvent keyCode]) */
 
       /* is it a "function key"? */
-      /* Note: Sometimes a plain key will have the NSNumericPadKeyMask
+      /* Note: Sometimes a plain key will have the NSEventModifierFlagNumericPad
          flag set (this is probably a bug in the OS).
       */
-      if (code < 0x00ff && (flags&NSNumericPadKeyMask))
+      if (code < 0x00ff && (flags&NSEventModifierFlagNumericPad))
         {
-          fnKeysym = ns_convert_key ([theEvent keyCode] | NSNumericPadKeyMask);
+          fnKeysym = ns_convert_key ([theEvent keyCode] | NSEventModifierFlagNumericPad);
         }
       if (fnKeysym == 0)
         {
@@ -5874,15 +5874,15 @@ flag set (this is probably a bug in the OS).
       /* are there modifiers? */
       emacs_event->modifiers = 0;
 
-      if (flags & NSHelpKeyMask)
+      if (flags & NSEventModifierFlagHelp)
           emacs_event->modifiers |= hyper_modifier;
 
-      if (flags & NSShiftKeyMask)
+      if (flags & NSEventModifierFlagShift)
         emacs_event->modifiers |= shift_modifier;
 
       is_right_key = (flags & NSRightCommandKeyMask) == NSRightCommandKeyMask;
       is_left_key = (flags & NSLeftCommandKeyMask) == NSLeftCommandKeyMask
-        || (! is_right_key && (flags & NSCommandKeyMask) == NSCommandKeyMask);
+        || (! is_right_key && (flags & NSEventModifierFlagCommand) == NSEventModifierFlagCommand);
 
       if (is_right_key)
         emacs_event->modifiers |= parse_solitary_modifier
@@ -5903,7 +5903,7 @@ flag set (this is probably a bug in the OS).
             {
               /* XXX: the code we get will be unshifted, so if we have
                  a shift modifier, must convert ourselves */
-              if (!(flags & NSShiftKeyMask))
+              if (!(flags & NSEventModifierFlagShift))
                 code = [[theEvent characters] characterAtIndex: 0];
 #if 0
               /* this is ugly and also requires linking w/Carbon framework
@@ -5918,7 +5918,7 @@ flag set (this is probably a bug in the OS).
                   UCKeyTranslate ((UCKeyboardLayout*)*uchrHandle,
                                  [[theEvent characters] characterAtIndex: 0],
                                  kUCKeyActionDisplay,
-                                 (flags & ~NSCommandKeyMask) >> 8,
+                                 (flags & ~NSEventModifierFlagCommand) >> 8,
                                  LMGetKbdType (), kUCKeyTranslateNoDeadKeysMask,
                                  &dummy, 1, &dummy, &code);
                   code &= 0xFF;
@@ -5929,7 +5929,7 @@ flag set (this is probably a bug in the OS).
 
       is_right_key = (flags & NSRightControlKeyMask) == NSRightControlKeyMask;
       is_left_key = (flags & NSLeftControlKeyMask) == NSLeftControlKeyMask
-        || (! is_right_key && (flags & NSControlKeyMask) == NSControlKeyMask);
+        || (! is_right_key && (flags & NSEventModifierFlagControl) == NSEventModifierFlagControl);
 
       if (is_right_key)
           emacs_event->modifiers |= parse_solitary_modifier
@@ -5952,7 +5952,7 @@ flag set (this is probably a bug in the OS).
         == NSRightAlternateKeyMask;
       is_left_key = (flags & NSLeftAlternateKeyMask) == NSLeftAlternateKeyMask
         || (! is_right_key
-            && (flags & NSAlternateKeyMask) == NSAlternateKeyMask);
+            && (flags & NSEventModifierFlagOption) == NSEventModifierFlagOption);
 
       if (is_right_key)
         {
@@ -6040,7 +6040,7 @@ -(void)keyUp: (NSEvent *)theEvent
   NSTRACE ("[EmacsView keyUp:]");
 
   if (floor (NSAppKitVersionNumber) <= 824 /*NSAppKitVersionNumber10_4*/ &&
-      code == 0x30 && (flags & NSControlKeyMask) && !(flags & NSCommandKeyMask))
+      code == 0x30 && (flags & NSEventModifierFlagControl) && !(flags & NSEventModifierFlagCommand))
     {
       if (NS_KEYLOG)
         fprintf (stderr, "keyUp: passed test");
@@ -6293,7 +6293,7 @@ - (void)mouseDown: (NSEvent *)theEvent
      button clicks */
   emacsframe->mouse_moved = 0;
 
-  if ([theEvent type] == NSScrollWheel)
+  if ([theEvent type] == NSEventTypeScrollWheel)
     {
       CGFloat delta = [theEvent deltaY];
       /* Mac notebooks send wheel events w/delta =0 when trackpad scrolling */
@@ -6848,12 +6848,12 @@ - (BOOL)isOpaque
 
   win = [[EmacsWindow alloc]
             initWithContentRect: r
-                      styleMask: (NSResizableWindowMask |
+                      styleMask: (NSWindowStyleMaskResizable |
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
-                                  NSTitledWindowMask |
+                                  NSWindowStyleMaskTitled |
 #endif
-                                  NSMiniaturizableWindowMask |
-                                  NSClosableWindowMask)
+                                  NSWindowStyleMaskMiniaturizable |
+                                  NSWindowStyleMaskClosable)
                         backing: NSBackingStoreBuffered
                           defer: YES];
 
@@ -7276,7 +7276,7 @@ - (BOOL)isFullscreen
   else
     {
 #ifdef HAVE_NATIVE_FS
-      res = (([[self window] styleMask] & NSFullScreenWindowMask) != 0);
+      res = (([[self window] styleMask] & NSWindowStyleMaskFullScreen) != 0);
 #else
       res = NO;
 #endif
@@ -7360,7 +7360,7 @@ - (void)toggleFullScreen: (id)sender
 
       fw = [[EmacsFSWindow alloc]
                        initWithContentRect:[w contentRectForFrameRect:wr]
-                                 styleMask:NSBorderlessWindowMask
+                                 styleMask:NSWindowStyleMaskBorderless
                                    backing:NSBackingStoreBuffered
                                      defer:YES
                                     screen:screen];
@@ -7668,11 +7668,11 @@ -(BOOL)performDragOperation: (id <NSDraggingInfo>) sender
       (op & 0xf) != 0xf)
     {
       if (op & NSDragOperationLink)
-        modifiers |= NSControlKeyMask;
+        modifiers |= NSEventModifierFlagControl;
       if (op & NSDragOperationCopy)
-        modifiers |= NSAlternateKeyMask;
+        modifiers |= NSEventModifierFlagOption;
       if (op & NSDragOperationGeneric)
-        modifiers |= NSCommandKeyMask;
+        modifiers |= NSEventModifierFlagCommand;
     }
 
   modifiers = EV_MODIFIERS2 (modifiers);
@@ -8121,7 +8121,7 @@ + (CGFloat) scrollerWidth
   MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
   r = [NSScroller scrollerWidth];
 #else
-  r = [NSScroller scrollerWidthForControlSize: NSRegularControlSize
+  r = [NSScroller scrollerWidthForControlSize: NSControlSizeRegular
                                 scrollerStyle: NSScrollerStyleLegacy];
 #endif
   return r;
@@ -8467,7 +8467,7 @@ - (void)mouseDown: (NSEvent *)e
         pos = loc;
 
       /* send a fake mouse-up to super to preempt modal -trackKnob: mode */
-      fake_event = [NSEvent mouseEventWithType: NSLeftMouseUp
+      fake_event = [NSEvent mouseEventWithType: NSEventTypeLeftMouseUp
                                       location: [e locationInWindow]
                                  modifierFlags: [e modifierFlags]
                                      timestamp: [e timestamp]
-- 
Hi Bob, can you test this removes most of the deprecation notices?
There should still be some from macfont.m.
-- 
Alan Third



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix macOS 12 deprecation notices
  2016-08-18 19:04 ` [PATCH] Fix macOS 12 deprecation notices Alan Third
@ 2016-08-20 23:15   ` Bob Halley
  2016-08-21  6:59   ` Kalle Olavi Niemitalo
  1 sibling, 0 replies; 5+ messages in thread
From: Bob Halley @ 2016-08-20 23:15 UTC (permalink / raw)
  To: Alan Third; +Cc: emacs-devel

Yep, that removes most of them.  Here's what's left:

nsterm.m:6941:10: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
  [NSApp registerServicesMenuSendTypes: ns_send_types
         ^

For this one (above), my guess is to pass ns_return_types, which the code creates but does not seem to use, but again I don't know enough to be sure!

nsterm.m:8475:52: warning: 'context' is deprecated: first deprecated in macOS 10.12 - This method always returns nil. If you
      need access to the current drawing context, use [NSGraphicsContext currentContext] inside of a draw operation.
      [-Wdeprecated-declarations]
                                       context: [e context]

In the code making a "fake event" at nsterm.m:8470, it says that [e context] is always nil.  Probably just replacing this with nil is safe, but I don't know enough to be sure.  Otherwise I suppose you could just call [e context] on older stuff, and say nil on 10.12 and later.
                                                   
nsmenu.m:754:44: warning: 'context' is deprecated: first deprecated in macOS 10.12 - This method always returns nil. If you
      need access to the current drawing context, use [NSGraphicsContext currentContext] inside of a draw operation.
      [-Wdeprecated-declarations]
                               context: [e context]
                                           ^
nsmenu.m:1535:62: warning: 'NSUtilityWindowMask' is deprecated: first deprecated in macOS 10.12 [-Wdeprecated-declarations]
  aStyle = NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSUtilityWindowMask;
                                                             ^~~~~~~~~~~~~~~~~~~
                                                             NSWindowStyleMaskUtilityWindow
                               ^
nsmenu.m:1506:67: warning: conflicting parameter types in implementation of 'initWithContentRect:styleMask:backing:defer:':
      'NSWindowStyleMask' (aka 'enum NSWindowStyleMask') vs 'NSUInteger' (aka 'unsigned long') [-Wmismatched-parameter-types]
- initWithContentRect: (NSRect)contentRect styleMask: (NSUInteger)aStyle
                                                       ~~~~~~~~~~ ^
3 warnings generated.


macfont.m:222:23: warning: implicit conversion from enumeration type 'CTCharacterCollection' (aka 'enum CTCharacterCollection')
      to different enumeration type 'NSCharacterCollection' (aka 'enum NSCharacterCollection') [-Wenum-conversion]
                                       collection:collection
                                                  ^~~~~~~~~~
macfont.m:289:18: warning: 'setUsesScreenFonts:' is deprecated: first deprecated in macOS 10.11 [-Wdeprecated-declarations]
  [layoutManager setUsesScreenFonts:YES];
                 ^
macfont.m:344:18: warning: 'setUsesScreenFonts:' is deprecated: first deprecated in macOS 10.11 [-Wdeprecated-declarations]
  [layoutManager setUsesScreenFonts:screen_font_p];
                 ^
macfont.m:417:22: warning: 'getGlyphsInRange:glyphs:characterIndexes:glyphInscriptions:elasticBits:bidiLevels:' is deprecated:
      first deprecated in macOS 10.11 - Use -getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels: instead
      [-Wdeprecated-declarations]
      [layoutManager getGlyphsInRange:(NSMakeRange (glyphIndex, 1))
                     ^
4 warnings generated.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix macOS 12 deprecation notices
  2016-08-18 19:04 ` [PATCH] Fix macOS 12 deprecation notices Alan Third
  2016-08-20 23:15   ` Bob Halley
@ 2016-08-21  6:59   ` Kalle Olavi Niemitalo
  2016-08-24 18:21     ` Alan Third
  1 sibling, 1 reply; 5+ messages in thread
From: Kalle Olavi Niemitalo @ 2016-08-21  6:59 UTC (permalink / raw)
  To: Alan Third; +Cc: emacs-devel

Alan Third <alan@idiocy.org> writes:

> * src/nsterm.h: Add #defines to allow older versions of macOS to use the
> new constant names.
> * src/nsmenu.m: Replace old constant names with new.
> * src/nsterm.m: Replace old constant names with new.
> * src/nsfns.m: Replace old constant names with new.

Your patch also removes two setMenuChangedMessagesEnabled calls
from src/nsmenu.m.  That seems unrelated to constant names.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix macOS 12 deprecation notices
  2016-08-21  6:59   ` Kalle Olavi Niemitalo
@ 2016-08-24 18:21     ` Alan Third
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Third @ 2016-08-24 18:21 UTC (permalink / raw)
  To: Kalle Olavi Niemitalo; +Cc: emacs-devel

On Sun, Aug 21, 2016 at 09:59:23AM +0300, Kalle Olavi Niemitalo wrote:
> Alan Third <alan@idiocy.org> writes:
> 
> > * src/nsterm.h: Add #defines to allow older versions of macOS to use the
> > new constant names.
> > * src/nsmenu.m: Replace old constant names with new.
> > * src/nsterm.m: Replace old constant names with new.
> > * src/nsfns.m: Replace old constant names with new.
> 
> Your patch also removes two setMenuChangedMessagesEnabled calls
> from src/nsmenu.m.  That seems unrelated to constant names.

Well spotted, I forgot about them. I’ve amended the commit message,
and will push to master now.

-- 
Alan Third



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-24 18:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <315BE3C4-D984-470E-A4B4-20C8148FBA5A@play-bow.org>
2016-08-08 20:04 ` FYI: Deprecations and Warnings for nsterm.m on Sierra Alan Third
2016-08-18 19:04 ` [PATCH] Fix macOS 12 deprecation notices Alan Third
2016-08-20 23:15   ` Bob Halley
2016-08-21  6:59   ` Kalle Olavi Niemitalo
2016-08-24 18:21     ` Alan Third

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).