summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2016-09-20 23:30:54 +0200
committerwm4 <wm4@nowhere>2016-09-22 13:46:27 +0200
commit9df797575fc771f87dc6bedf89b46aab3236a21f (patch)
tree2a011c2ee32d34030973144f259398120e69dd2b
parent78b3852f7ec7b4c8df72646e313535acacae1fd9 (diff)
downloadmpv-9df797575fc771f87dc6bedf89b46aab3236a21f.tar.bz2
mpv-9df797575fc771f87dc6bedf89b46aab3236a21f.tar.xz
cocoa: fix macOS 10.12 deprecation warnings
-rw-r--r--osdep/macosx_compat.h25
-rw-r--r--osdep/macosx_events.m18
-rw-r--r--osdep/macosx_versions.h8
-rw-r--r--video/out/cocoa_common.m6
4 files changed, 45 insertions, 12 deletions
diff --git a/osdep/macosx_compat.h b/osdep/macosx_compat.h
index 9775529bc6..76308c6f98 100644
--- a/osdep/macosx_compat.h
+++ b/osdep/macosx_compat.h
@@ -24,6 +24,31 @@
#import <Cocoa/Cocoa.h>
#include "osdep/macosx_versions.h"
+#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12)
+typedef NSUInteger NSWindowStyleMask;
+static const NSWindowStyleMask NSWindowStyleMaskClosable = NSClosableWindowMask;
+static const NSWindowStyleMask NSWindowStyleMaskTitled = NSTitledWindowMask;
+static const NSWindowStyleMask NSWindowStyleMaskMiniaturizable = NSMiniaturizableWindowMask;
+static const NSWindowStyleMask NSWindowStyleMaskResizable = NSResizableWindowMask;
+static const NSWindowStyleMask NSWindowStyleMaskBorderless = NSBorderlessWindowMask;
+
+static const NSEventType NSEventTypeSystemDefined = NSSystemDefined;
+static const NSEventType NSEventTypeKeyDown = NSKeyDown;
+static const NSEventType NSEventTypeKeyUp = NSKeyUp;
+
+static const NSEventMask NSEventMaskKeyDown = NSKeyDownMask;
+static const NSEventMask NSEventMaskKeyUp = NSKeyUpMask;
+
+#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10)
+typedef NSUInteger NSEventModifierFlags;
+#endif
+
+static const NSEventModifierFlags NSEventModifierFlagShift = NSShiftKeyMask;
+static const NSEventModifierFlags NSEventModifierFlagControl = NSControlKeyMask;
+static const NSEventModifierFlags NSEventModifierFlagCommand = NSCommandKeyMask;
+static const NSEventModifierFlags NSEventModifierFlagOption = NSAlternateKeyMask;
+#endif
+
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8)
@interface NSArray (SubscriptingAdditions)
- (id)objectAtIndexedSubscript:(NSUInteger)index;
diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m
index 6090a1937e..6ad22584dc 100644
--- a/osdep/macosx_events.m
+++ b/osdep/macosx_events.m
@@ -60,8 +60,8 @@
@end
-#define NSLeftAlternateKeyMask (0x000020 | NSAlternateKeyMask)
-#define NSRightAlternateKeyMask (0x000040 | NSAlternateKeyMask)
+#define NSLeftAlternateKeyMask (0x000020 | NSEventModifierFlagOption)
+#define NSRightAlternateKeyMask (0x000040 | NSEventModifierFlagOption)
static bool LeftAltPressed(int mask)
{
@@ -163,7 +163,7 @@ static CGEventRef tap_event_callback(CGEventTapProxy proxy, CGEventType type,
NSEvent *nse = [NSEvent eventWithCGEvent:event];
- if ([nse type] != NSSystemDefined || [nse subtype] != 8)
+ if ([nse type] != NSEventTypeSystemDefined || [nse subtype] != 8)
// This is not a media key
return event;
@@ -285,7 +285,7 @@ void cocoa_set_input_context(struct input_ctx *input_context)
- (void)startEventMonitor
{
- [NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask|NSKeyUpMask
+ [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown|NSEventMaskKeyUp
handler:^(NSEvent *event) {
BOOL equivalent = [[NSApp mainMenu] performKeyEquivalent:event];
if (equivalent) {
@@ -395,14 +395,14 @@ void cocoa_set_input_context(struct input_ctx *input_context)
- (int)mapKeyModifiers:(int)cocoaModifiers
{
int mask = 0;
- if (cocoaModifiers & NSShiftKeyMask)
+ if (cocoaModifiers & NSEventModifierFlagShift)
mask |= MP_KEY_MODIFIER_SHIFT;
- if (cocoaModifiers & NSControlKeyMask)
+ if (cocoaModifiers & NSEventModifierFlagControl)
mask |= MP_KEY_MODIFIER_CTRL;
if (LeftAltPressed(cocoaModifiers) ||
(RightAltPressed(cocoaModifiers) && ![self useAltGr]))
mask |= MP_KEY_MODIFIER_ALT;
- if (cocoaModifiers & NSCommandKeyMask)
+ if (cocoaModifiers & NSEventModifierFlagCommand)
mask |= MP_KEY_MODIFIER_META;
return mask;
}
@@ -410,8 +410,8 @@ void cocoa_set_input_context(struct input_ctx *input_context)
- (int)mapTypeModifiers:(NSEventType)type
{
NSDictionary *map = @{
- @(NSKeyDown) : @(MP_KEY_STATE_DOWN),
- @(NSKeyUp) : @(MP_KEY_STATE_UP),
+ @(NSEventTypeKeyDown) : @(MP_KEY_STATE_DOWN),
+ @(NSEventTypeKeyUp) : @(MP_KEY_STATE_UP),
};
return [map[@(type)] intValue];
}
diff --git a/osdep/macosx_versions.h b/osdep/macosx_versions.h
index 83bcf5ddd7..f4c49ab4e3 100644
--- a/osdep/macosx_versions.h
+++ b/osdep/macosx_versions.h
@@ -26,4 +26,12 @@
# define MAC_OS_X_VERSION_10_9 1090
#endif
+#if !defined(MAC_OS_X_VERSION_10_10)
+# define MAC_OS_X_VERSION_10_10 101000
+#endif
+
+#if !defined(MAC_OS_X_VERSION_10_12)
+# define MAC_OS_X_VERSION_10_12 101200
+#endif
+
#endif /* MPV_MACOSX_VERSIONS */
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 18e6860e7d..9690ddb10f 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -458,10 +458,10 @@ static MpvVideoWindow *create_window(NSRect rect, NSScreen *s, bool border,
{
int window_mask = 0;
if (border) {
- window_mask = NSTitledWindowMask|NSClosableWindowMask|
- NSMiniaturizableWindowMask|NSResizableWindowMask;
+ window_mask = NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|
+ NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable;
} else {
- window_mask = NSBorderlessWindowMask|NSResizableWindowMask;
+ window_mask = NSWindowStyleMaskBorderless|NSWindowStyleMaskResizable;
}
MpvVideoWindow *w =