examples: fix macOS 9.12 deprecation warnings

Add #defines to allow older versions of macOS to use the new constant names.
This commit is contained in:
Josep Torra 2017-05-20 12:34:27 +02:00
parent f805608075
commit 2c9b513695
2 changed files with 16 additions and 3 deletions

View file

@ -25,6 +25,10 @@
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include <CoreMedia/CoreMedia.h> #include <CoreMedia/CoreMedia.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
#define NSWindowStyleMaskBorderless NSBorderlessWindowMask
#endif
static NSRunLoop *loop; static NSRunLoop *loop;
static int quit = 0; static int quit = 0;
@ -97,7 +101,7 @@ gint main (gint argc, gchar *argv[])
g_object_get (videosink, "layer", &layer, NULL); g_object_get (videosink, "layer", &layer, NULL);
NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect (0, 0, 320, 240) NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect (0, 0, 320, 240)
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO];
[window setOpaque:NO]; [window setOpaque:NO];
[window.contentView setWantsLayer:YES]; [window.contentView setWantsLayer:YES];

View file

@ -22,6 +22,14 @@
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/video/videooverlay.h> #include <gst/video/videooverlay.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
#define NSEventMaskAny NSAnyEventMask
#define NSWindowStyleMaskTitled NSTitledWindowMask
#define NSWindowStyleMaskClosable NSClosableWindowMask
#define NSWindowStyleMaskResizable NSResizableWindowMask
#define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
#endif
/* ============================================================= */ /* ============================================================= */
/* */ /* */
/* MainWindow */ /* MainWindow */
@ -48,7 +56,8 @@
m_isClosed = FALSE; m_isClosed = FALSE;
self = [super initWithContentRect: contentRect self = [super initWithContentRect: contentRect
styleMask: (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask) styleMask: (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable)
backing: NSBackingStoreBuffered defer: NO screen: nil]; backing: NSBackingStoreBuffered defer: NO screen: nil];
[self setReleasedWhenClosed:NO]; [self setReleasedWhenClosed:NO];
@ -211,7 +220,7 @@ int main(int argc, char **argv)
[window orderFront:window]; [window orderFront:window];
while (![window isClosed]) { while (![window isClosed]) {
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny
untilDate:[NSDate dateWithTimeIntervalSinceNow:1] untilDate:[NSDate dateWithTimeIntervalSinceNow:1]
inMode:NSDefaultRunLoopMode dequeue:YES]; inMode:NSDefaultRunLoopMode dequeue:YES];
if (event) if (event)