mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 12:18:51 -05:00
Cocoa: Fix macOS 10.12 deprecation warnings
This commit is contained in:
parent
cc3036860a
commit
7f9840cecf
4
deps/tinycthread.h
vendored
4
deps/tinycthread.h
vendored
|
@ -123,7 +123,9 @@ typedef int _tthread_clockid_t;
|
||||||
/* Emulate clock_gettime */
|
/* Emulate clock_gettime */
|
||||||
int _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts);
|
int _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts);
|
||||||
#define clock_gettime _tthread_clock_gettime
|
#define clock_gettime _tthread_clock_gettime
|
||||||
#define CLOCK_REALTIME 0
|
#ifndef CLOCK_REALTIME
|
||||||
|
#define CLOCK_REALTIME 0
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,14 +63,15 @@ static NSUInteger getStyleMask(_GLFWwindow* window)
|
||||||
NSUInteger styleMask = 0;
|
NSUInteger styleMask = 0;
|
||||||
|
|
||||||
if (window->monitor || !window->decorated)
|
if (window->monitor || !window->decorated)
|
||||||
styleMask |= NSBorderlessWindowMask;
|
styleMask |= NSWindowStyleMaskBorderless;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
styleMask |= NSTitledWindowMask | NSClosableWindowMask |
|
styleMask |= NSWindowStyleMaskTitled |
|
||||||
NSMiniaturizableWindowMask;
|
NSWindowStyleMaskClosable |
|
||||||
|
NSWindowStyleMaskMiniaturizable;
|
||||||
|
|
||||||
if (window->resizable)
|
if (window->resizable)
|
||||||
styleMask |= NSResizableWindowMask;
|
styleMask |= NSWindowStyleMaskResizable;
|
||||||
}
|
}
|
||||||
|
|
||||||
return styleMask;
|
return styleMask;
|
||||||
|
@ -150,13 +151,13 @@ static int translateFlags(NSUInteger flags)
|
||||||
{
|
{
|
||||||
int mods = 0;
|
int mods = 0;
|
||||||
|
|
||||||
if (flags & NSShiftKeyMask)
|
if (flags & NSEventModifierFlagShift)
|
||||||
mods |= GLFW_MOD_SHIFT;
|
mods |= GLFW_MOD_SHIFT;
|
||||||
if (flags & NSControlKeyMask)
|
if (flags & NSEventModifierFlagControl)
|
||||||
mods |= GLFW_MOD_CONTROL;
|
mods |= GLFW_MOD_CONTROL;
|
||||||
if (flags & NSAlternateKeyMask)
|
if (flags & NSEventModifierFlagOption)
|
||||||
mods |= GLFW_MOD_ALT;
|
mods |= GLFW_MOD_ALT;
|
||||||
if (flags & NSCommandKeyMask)
|
if (flags & NSEventModifierFlagCommand)
|
||||||
mods |= GLFW_MOD_SUPER;
|
mods |= GLFW_MOD_SUPER;
|
||||||
|
|
||||||
return mods;
|
return mods;
|
||||||
|
@ -180,16 +181,16 @@ static NSUInteger translateKeyToModifierFlag(int key)
|
||||||
{
|
{
|
||||||
case GLFW_KEY_LEFT_SHIFT:
|
case GLFW_KEY_LEFT_SHIFT:
|
||||||
case GLFW_KEY_RIGHT_SHIFT:
|
case GLFW_KEY_RIGHT_SHIFT:
|
||||||
return NSShiftKeyMask;
|
return NSEventModifierFlagShift;
|
||||||
case GLFW_KEY_LEFT_CONTROL:
|
case GLFW_KEY_LEFT_CONTROL:
|
||||||
case GLFW_KEY_RIGHT_CONTROL:
|
case GLFW_KEY_RIGHT_CONTROL:
|
||||||
return NSControlKeyMask;
|
return NSEventModifierFlagControl;
|
||||||
case GLFW_KEY_LEFT_ALT:
|
case GLFW_KEY_LEFT_ALT:
|
||||||
case GLFW_KEY_RIGHT_ALT:
|
case GLFW_KEY_RIGHT_ALT:
|
||||||
return NSAlternateKeyMask;
|
return NSEventModifierFlagOption;
|
||||||
case GLFW_KEY_LEFT_SUPER:
|
case GLFW_KEY_LEFT_SUPER:
|
||||||
case GLFW_KEY_RIGHT_SUPER:
|
case GLFW_KEY_RIGHT_SUPER:
|
||||||
return NSCommandKeyMask;
|
return NSEventModifierFlagCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -565,7 +566,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||||
{
|
{
|
||||||
int action;
|
int action;
|
||||||
const unsigned int modifierFlags =
|
const unsigned int modifierFlags =
|
||||||
[event modifierFlags] & NSDeviceIndependentModifierFlagsMask;
|
[event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
|
||||||
const int key = translateKey([event keyCode]);
|
const int key = translateKey([event keyCode]);
|
||||||
const int mods = translateFlags(modifierFlags);
|
const int mods = translateFlags(modifierFlags);
|
||||||
const NSUInteger keyFlag = translateKeyToModifierFlag(key);
|
const NSUInteger keyFlag = translateKeyToModifierFlag(key);
|
||||||
|
@ -760,7 +761,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||||
|
|
||||||
- (BOOL)canBecomeKeyWindow
|
- (BOOL)canBecomeKeyWindow
|
||||||
{
|
{
|
||||||
// Required for NSBorderlessWindowMask windows
|
// Required for NSWindowStyleMaskBorderless windows
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,8 +782,11 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||||
// down the command key don't get sent to the key window.
|
// down the command key don't get sent to the key window.
|
||||||
- (void)sendEvent:(NSEvent *)event
|
- (void)sendEvent:(NSEvent *)event
|
||||||
{
|
{
|
||||||
if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
|
if ([event type] == NSEventTypeKeyUp &&
|
||||||
|
([event modifierFlags] & NSEventModifierFlagCommand))
|
||||||
|
{
|
||||||
[[self keyWindow] sendEvent:event];
|
[[self keyWindow] sendEvent:event];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
[super sendEvent:event];
|
[super sendEvent:event];
|
||||||
}
|
}
|
||||||
|
@ -866,7 +870,7 @@ static void createMenuBar(void)
|
||||||
[[appMenu addItemWithTitle:@"Hide Others"
|
[[appMenu addItemWithTitle:@"Hide Others"
|
||||||
action:@selector(hideOtherApplications:)
|
action:@selector(hideOtherApplications:)
|
||||||
keyEquivalent:@"h"]
|
keyEquivalent:@"h"]
|
||||||
setKeyEquivalentModifierMask:NSAlternateKeyMask | NSCommandKeyMask];
|
setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
|
||||||
[appMenu addItemWithTitle:@"Show All"
|
[appMenu addItemWithTitle:@"Show All"
|
||||||
action:@selector(unhideAllApplications:)
|
action:@selector(unhideAllApplications:)
|
||||||
keyEquivalent:@""];
|
keyEquivalent:@""];
|
||||||
|
@ -898,7 +902,7 @@ static void createMenuBar(void)
|
||||||
[[windowMenu addItemWithTitle:@"Enter Full Screen"
|
[[windowMenu addItemWithTitle:@"Enter Full Screen"
|
||||||
action:@selector(toggleFullScreen:)
|
action:@selector(toggleFullScreen:)
|
||||||
keyEquivalent:@"f"]
|
keyEquivalent:@"f"]
|
||||||
setKeyEquivalentModifierMask:NSControlKeyMask | NSCommandKeyMask];
|
setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
||||||
|
|
||||||
// Prior to Snow Leopard, we need to use this oddly-named semi-private API
|
// Prior to Snow Leopard, we need to use this oddly-named semi-private API
|
||||||
// to get the application menu working properly.
|
// to get the application menu working properly.
|
||||||
|
@ -1358,7 +1362,7 @@ void _glfwPlatformPollEvents(void)
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
|
||||||
untilDate:[NSDate distantPast]
|
untilDate:[NSDate distantPast]
|
||||||
inMode:NSDefaultRunLoopMode
|
inMode:NSDefaultRunLoopMode
|
||||||
dequeue:YES];
|
dequeue:YES];
|
||||||
|
@ -1377,7 +1381,7 @@ void _glfwPlatformWaitEvents(void)
|
||||||
// I wanted to pass NO to dequeue:, and rely on PollEvents to
|
// I wanted to pass NO to dequeue:, and rely on PollEvents to
|
||||||
// dequeue and send. For reasons not at all clear to me, passing
|
// dequeue and send. For reasons not at all clear to me, passing
|
||||||
// NO to dequeue: causes this method never to return.
|
// NO to dequeue: causes this method never to return.
|
||||||
NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny
|
||||||
untilDate:[NSDate distantFuture]
|
untilDate:[NSDate distantFuture]
|
||||||
inMode:NSDefaultRunLoopMode
|
inMode:NSDefaultRunLoopMode
|
||||||
dequeue:YES];
|
dequeue:YES];
|
||||||
|
@ -1389,7 +1393,7 @@ void _glfwPlatformWaitEvents(void)
|
||||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||||
{
|
{
|
||||||
NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout];
|
NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout];
|
||||||
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
|
||||||
untilDate:date
|
untilDate:date
|
||||||
inMode:NSDefaultRunLoopMode
|
inMode:NSDefaultRunLoopMode
|
||||||
dequeue:YES];
|
dequeue:YES];
|
||||||
|
@ -1402,7 +1406,7 @@ void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||||
void _glfwPlatformPostEmptyEvent(void)
|
void _glfwPlatformPostEmptyEvent(void)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSEvent* event = [NSEvent otherEventWithType:NSApplicationDefined
|
NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
|
||||||
location:NSMakePoint(0, 0)
|
location:NSMakePoint(0, 0)
|
||||||
modifierFlags:0
|
modifierFlags:0
|
||||||
timestamp:0
|
timestamp:0
|
||||||
|
|
|
@ -225,7 +225,15 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||||
ADD_ATTR2(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
|
ADD_ATTR2(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
|
||||||
|
|
||||||
if (fbconfig->stereo)
|
if (fbconfig->stereo)
|
||||||
|
{
|
||||||
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
|
||||||
|
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
||||||
|
"NSGL: Stereo rendering is deprecated");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
#else
|
||||||
ADD_ATTR(NSOpenGLPFAStereo);
|
ADD_ATTR(NSOpenGLPFAStereo);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (fbconfig->doublebuffer)
|
if (fbconfig->doublebuffer)
|
||||||
ADD_ATTR(NSOpenGLPFADoubleBuffer);
|
ADD_ATTR(NSOpenGLPFADoubleBuffer);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user