Cocoa: Fix some macOS 10.14 deprecation warnings
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 7cf4a59..308b5d8 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -32,7 +32,6 @@
// Needed for _NSGetProgname
#include <crt_externs.h>
-// HACK: The 10.12 SDK adds new symbols and immediately deprecates the old ones
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
#define NSWindowStyleMaskBorderless NSBorderlessWindowMask
#define NSWindowStyleMaskClosable NSClosableWindowMask
@@ -48,8 +47,13 @@
#define NSEventMaskAny NSAnyEventMask
#define NSEventTypeApplicationDefined NSApplicationDefined
#define NSEventTypeKeyUp NSKeyUp
+ #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
#endif
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 101300
+ #define NSPasteboardTypeFileURL NSFilenamesPboardType
+ #define NSPasteboardTypeString NSStringPboardType
+#endif
// Returns the style mask corresponding to the window settings
//
@@ -439,7 +443,7 @@
[self updateTrackingAreas];
[self registerForDraggedTypes:[NSArray arrayWithObjects:
- NSFilenamesPboardType, nil]];
+ NSPasteboardTypeFileURL, nil]];
}
return self;
@@ -720,7 +724,7 @@
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard* pasteboard = [sender draggingPasteboard];
- NSArray* files = [pasteboard propertyListForType:NSFilenamesPboardType];
+ NSArray* files = [pasteboard propertyListForType:NSPasteboardTypeFileURL];
const NSRect contentRect = [window->ns.view frame];
_glfwInputCursorPos(window,
@@ -1728,7 +1732,7 @@
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
- bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
+ bitmapFormat:NSBitmapFormatAlphaNonpremultiplied
bytesPerRow:image->width * 4
bitsPerPixel:32];
@@ -1795,26 +1799,26 @@
void _glfwPlatformSetClipboardString(const char* string)
{
- NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil];
+ NSArray* types = [NSArray arrayWithObjects:NSPasteboardTypeString, nil];
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
[pasteboard declareTypes:types owner:nil];
[pasteboard setString:[NSString stringWithUTF8String:string]
- forType:NSStringPboardType];
+ forType:NSPasteboardTypeString];
}
const char* _glfwPlatformGetClipboardString(void)
{
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
- if (![[pasteboard types] containsObject:NSStringPboardType])
+ if (![[pasteboard types] containsObject:NSPasteboardTypeString])
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"Cocoa: Failed to retrieve string from pasteboard");
return NULL;
}
- NSString* object = [pasteboard stringForType:NSStringPboardType];
+ NSString* object = [pasteboard stringForType:NSPasteboardTypeString];
if (!object)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
diff --git a/src/nsgl_context.m b/src/nsgl_context.m
index 82af906..ec1012e 100644
--- a/src/nsgl_context.m
+++ b/src/nsgl_context.m
@@ -26,6 +26,10 @@
#include "internal.h"
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
+ #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
+ #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
+#endif
static void makeContextCurrentNSGL(_GLFWwindow* window)
{
@@ -49,7 +53,7 @@
GLint sync = interval;
[window->context.nsgl.object setValues:&sync
- forParameter:NSOpenGLCPSwapInterval];
+ forParameter:NSOpenGLContextParameterSwapInterval];
}
static int extensionSupportedNSGL(const char* extension)
@@ -299,7 +303,8 @@
if (fbconfig->transparent)
{
GLint opaque = 0;
- [window->context.nsgl.object setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];
+ [window->context.nsgl.object setValues:&opaque
+ forParameter:NSOpenGLContextParameterSurfaceOpacity];
}
[window->context.nsgl.object setView:window->ns.view];