Skip to content

Commit

Permalink
Cocoa: Fix deprecation warning for kUTTypeURL
Browse files Browse the repository at this point in the history
We switched to kUTTypeURL when NSURLPboardType was deprecated, as the
official replacement symbol NSPasteboardTypeURL was not available on
every version of macOS supported by GLFW.

kUTTypeURL has now also been deprecated.

This commit moves to a compile-time choice between NSURLPboardType and
NSPasteboardTypeURL depending on the minimum targeted macOS version.

Fixes glfw#2003
  • Loading branch information
elmindreda committed Feb 2, 2022
1 parent df8d7bc commit 7f6aa58
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ video tutorials.
- Ali Sherief
- Yoshiki Shibukawa
- Dmitri Shuralyov
- Daniel Sieger
- Daniel Skorupski
- Anthony Smith
- Bradley Smith
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ information on what to include when reporting a bug.
- [Cocoa] Bugfix: Moving the cursor programmatically would freeze it for
a fraction of a second (#1962)
- [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980)
- [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003)
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
(#1462,#1528)
Expand Down
4 changes: 4 additions & 0 deletions src/cocoa_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ typedef void* id;
#define NSWindowStyleMaskTitled NSTitledWindowMask
#endif

#if MAC_OS_X_VERSION_MIN_REQUIRED < 101300
#define NSPasteboardTypeURL NSURLPboardType
#endif

typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;

Expand Down
4 changes: 1 addition & 3 deletions src/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,7 @@ - (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow
markedText = [[NSMutableAttributedString alloc] init];

[self updateTrackingAreas];
// NOTE: kUTTypeURL corresponds to NSPasteboardTypeURL but is available
// on 10.7 without having been deprecated yet
[self registerForDraggedTypes:@[(__bridge NSString*) kUTTypeURL]];
[self registerForDraggedTypes:@[NSPasteboardTypeURL]];
}

return self;
Expand Down

0 comments on commit 7f6aa58

Please sign in to comment.