mirror of https://github.com/encounter/SDL.git
macOS: remove dead code for supporting 10.6 at runtime.
This commit is contained in:
parent
8ab3ae98f0
commit
f871c178b9
|
@ -1469,9 +1469,7 @@ extern "C" {
|
||||||
* SDL_WINDOW_RESIZABLE windows will offer the "fullscreen"
|
* SDL_WINDOW_RESIZABLE windows will offer the "fullscreen"
|
||||||
* button on their titlebars).
|
* button on their titlebars).
|
||||||
*
|
*
|
||||||
* The default value is "1". Spaces are disabled regardless of this hint if
|
* The default value is "1". This hint must be set before any windows are created.
|
||||||
* the OS isn't at least Mac OS X Lion (10.7). This hint must be set before
|
|
||||||
* any windows are created.
|
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES"
|
#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES"
|
||||||
|
|
||||||
|
|
|
@ -424,15 +424,13 @@ CreateApplicationMenus(void)
|
||||||
|
|
||||||
[windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
|
[windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
|
||||||
|
|
||||||
/* Add the fullscreen toggle menu option, if supported */
|
/* Add the fullscreen toggle menu option. */
|
||||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
|
/* Cocoa should update the title to Enter or Exit Full Screen automatically.
|
||||||
/* Cocoa should update the title to Enter or Exit Full Screen automatically.
|
* But if not, then just fallback to Toggle Full Screen.
|
||||||
* But if not, then just fallback to Toggle Full Screen.
|
*/
|
||||||
*/
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
|
||||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
|
[menuItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
||||||
[menuItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
[windowMenu addItem:menuItem];
|
||||||
[windowMenu addItem:menuItem];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Put menu into the menubar */
|
/* Put menu into the menubar */
|
||||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
||||||
|
@ -505,19 +503,6 @@ Cocoa_RegisterApp(void)
|
||||||
int
|
int
|
||||||
Cocoa_PumpEventsUntilDate(_THIS, NSDate *expiration, bool accumulate)
|
Cocoa_PumpEventsUntilDate(_THIS, NSDate *expiration, bool accumulate)
|
||||||
{
|
{
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
|
||||||
/* Update activity every 30 seconds to prevent screensaver */
|
|
||||||
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
|
||||||
if (_this->suspend_screensaver && !data->screensaver_use_iopm) {
|
|
||||||
Uint32 now = SDL_GetTicks();
|
|
||||||
if (!data->screensaver_activity ||
|
|
||||||
SDL_TICKS_PASSED(now, data->screensaver_activity + 30000)) {
|
|
||||||
UpdateSystemActivity(UsrActivity);
|
|
||||||
data->screensaver_activity = now;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for ( ; ; ) {
|
for ( ; ; ) {
|
||||||
NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:expiration inMode:NSDefaultRunLoopMode dequeue:YES ];
|
NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:expiration inMode:NSDefaultRunLoopMode dequeue:YES ];
|
||||||
if ( event == nil ) {
|
if ( event == nil ) {
|
||||||
|
@ -584,10 +569,6 @@ Cocoa_SuspendScreenSaver(_THIS)
|
||||||
{
|
{
|
||||||
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
|
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
|
||||||
|
|
||||||
if (!data.screensaver_use_iopm) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.screensaver_assertion) {
|
if (data.screensaver_assertion) {
|
||||||
IOPMAssertionRelease(data.screensaver_assertion);
|
IOPMAssertionRelease(data.screensaver_assertion);
|
||||||
data.screensaver_assertion = kIOPMNullAssertionID;
|
data.screensaver_assertion = kIOPMNullAssertionID;
|
||||||
|
|
|
@ -140,14 +140,7 @@
|
||||||
aRange.location, aRange.length, windowHeight,
|
aRange.location, aRange.length, windowHeight,
|
||||||
NSStringFromRect(rect));
|
NSStringFromRect(rect));
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
rect = [window convertRectToScreen:rect];
|
||||||
if (![window respondsToSelector:@selector(convertRectToScreen:)]) {
|
|
||||||
rect.origin = [window convertBaseToScreen:rect.origin];
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
rect = [window convertRectToScreen:rect];
|
|
||||||
}
|
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,11 +187,8 @@ Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||||
/* Fall back to the viewport size. */
|
/* Fall back to the viewport size. */
|
||||||
NSRect viewport = [contentView bounds];
|
NSRect viewport = [contentView bounds];
|
||||||
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||||
/* This gives us the correct viewport for a Retina-enabled view, only
|
/* This gives us the correct viewport for a Retina-enabled view. */
|
||||||
* supported on 10.7+. */
|
viewport = [contentView convertRectToBacking:viewport];
|
||||||
if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
|
|
||||||
viewport = [contentView convertRectToBacking:viewport];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (w) {
|
if (w) {
|
||||||
*w = viewport.size.width;
|
*w = viewport.size.width;
|
||||||
|
|
|
@ -31,9 +31,6 @@
|
||||||
#include <CoreVideo/CVBase.h>
|
#include <CoreVideo/CVBase.h>
|
||||||
#include <CoreVideo/CVDisplayLink.h>
|
#include <CoreVideo/CVDisplayLink.h>
|
||||||
|
|
||||||
/* we need this for ShowMenuBar() and HideMenuBar(). */
|
|
||||||
#include <Carbon/Carbon.h>
|
|
||||||
|
|
||||||
/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */
|
/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */
|
||||||
#include <AvailabilityMacros.h>
|
#include <AvailabilityMacros.h>
|
||||||
|
|
||||||
|
@ -45,23 +42,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
Cocoa_ToggleMenuBar(const BOOL show)
|
|
||||||
{
|
|
||||||
/* !!! FIXME: keep an eye on this.
|
|
||||||
* ShowMenuBar/HideMenuBar is officially unavailable for 64-bit binaries.
|
|
||||||
* It happens to work, as of 10.7, but we're going to see if
|
|
||||||
* we can just simply do without it on newer OSes...
|
|
||||||
*/
|
|
||||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070) && !defined(__LP64__)
|
|
||||||
if (show) {
|
|
||||||
ShowMenuBar();
|
|
||||||
} else {
|
|
||||||
HideMenuBar();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
CG_SetError(const char *prefix, CGDisplayErr result)
|
CG_SetError(const char *prefix, CGDisplayErr result)
|
||||||
{
|
{
|
||||||
|
@ -497,7 +477,7 @@ Cocoa_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdp
|
||||||
CFRelease(dmOptions);
|
CFRelease(dmOptions);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
|
{
|
||||||
// fallback for 10.7
|
// fallback for 10.7
|
||||||
scaleFactor = [screen backingScaleFactor];
|
scaleFactor = [screen backingScaleFactor];
|
||||||
displayNativeSize.width = displayNativeSize.width * scaleFactor;
|
displayNativeSize.width = displayNativeSize.width * scaleFactor;
|
||||||
|
@ -646,10 +626,6 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||||
} else {
|
} else {
|
||||||
CGDisplayRelease(displaydata->display);
|
CGDisplayRelease(displaydata->display);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CGDisplayIsMain(displaydata->display)) {
|
|
||||||
Cocoa_ToggleMenuBar(YES);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* Put up the blanking window (a window above all other windows) */
|
/* Put up the blanking window (a window above all other windows) */
|
||||||
if (CGDisplayIsMain(displaydata->display)) {
|
if (CGDisplayIsMain(displaydata->display)) {
|
||||||
|
@ -669,11 +645,6 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||||
CG_SetError("CGDisplaySwitchToMode()", result);
|
CG_SetError("CGDisplaySwitchToMode()", result);
|
||||||
goto ERR_NO_SWITCH;
|
goto ERR_NO_SWITCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hide the menu bar so it doesn't intercept events */
|
|
||||||
if (CGDisplayIsMain(displaydata->display)) {
|
|
||||||
Cocoa_ToggleMenuBar(NO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fade in again (asynchronously) */
|
/* Fade in again (asynchronously) */
|
||||||
|
@ -720,7 +691,6 @@ Cocoa_QuitModes(_THIS)
|
||||||
CFRelease(mode->modes);
|
CFRelease(mode->modes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cocoa_ToggleMenuBar(YES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||||
|
|
|
@ -461,15 +461,13 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
||||||
CGFloat y = [event deltaY];
|
CGFloat y = [event deltaY];
|
||||||
SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
|
SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
|
||||||
|
|
||||||
if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
|
if ([event isDirectionInvertedFromDevice] == YES) {
|
||||||
if ([event isDirectionInvertedFromDevice] == YES) {
|
direction = SDL_MOUSEWHEEL_FLIPPED;
|
||||||
direction = SDL_MOUSEWHEEL_FLIPPED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For discrete scroll events from conventional mice, always send a full tick.
|
/* For discrete scroll events from conventional mice, always send a full tick.
|
||||||
For continuous scroll events from trackpads, send fractional deltas for smoother scrolling. */
|
For continuous scroll events from trackpads, send fractional deltas for smoother scrolling. */
|
||||||
if (![event respondsToSelector:@selector(hasPreciseScrollingDeltas)] || ![event hasPreciseScrollingDeltas]) {
|
if (![event hasPreciseScrollingDeltas]) {
|
||||||
if (x > 0) {
|
if (x > 0) {
|
||||||
x = SDL_ceil(x);
|
x = SDL_ceil(x);
|
||||||
} else if (x < 0) {
|
} else if (x < 0) {
|
||||||
|
|
|
@ -180,7 +180,6 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||||
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
|
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
|
||||||
SDL_bool lion_or_later = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
|
|
||||||
NSOpenGLPixelFormatAttribute attr[32];
|
NSOpenGLPixelFormatAttribute attr[32];
|
||||||
NSOpenGLPixelFormat *fmt;
|
NSOpenGLPixelFormat *fmt;
|
||||||
SDLOpenGLContext *context;
|
SDLOpenGLContext *context;
|
||||||
|
@ -214,22 +213,15 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) && !lion_or_later) {
|
|
||||||
SDL_SetError ("OpenGL Core Profile is not supported on this platform version");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
attr[i++] = NSOpenGLPFAAllowOfflineRenderers;
|
attr[i++] = NSOpenGLPFAAllowOfflineRenderers;
|
||||||
|
|
||||||
/* specify a profile if we're on Lion (10.7) or later. */
|
NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
|
||||||
if (lion_or_later) {
|
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
|
||||||
NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
|
profile = NSOpenGLProfileVersion3_2Core;
|
||||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
|
|
||||||
profile = NSOpenGLProfileVersion3_2Core;
|
|
||||||
}
|
|
||||||
attr[i++] = NSOpenGLPFAOpenGLProfile;
|
|
||||||
attr[i++] = profile;
|
|
||||||
}
|
}
|
||||||
|
attr[i++] = NSOpenGLPFAOpenGLProfile;
|
||||||
|
attr[i++] = profile;
|
||||||
|
|
||||||
attr[i++] = NSOpenGLPFAColorSize;
|
attr[i++] = NSOpenGLPFAColorSize;
|
||||||
attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
|
attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
|
||||||
|
@ -377,11 +369,8 @@ Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||||
NSRect viewport = [contentView bounds];
|
NSRect viewport = [contentView bounds];
|
||||||
|
|
||||||
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||||
/* This gives us the correct viewport for a Retina-enabled view, only
|
/* This gives us the correct viewport for a Retina-enabled view. */
|
||||||
* supported on 10.7+. */
|
viewport = [contentView convertRectToBacking:viewport];
|
||||||
if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
|
|
||||||
viewport = [contentView convertRectToBacking:viewport];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w) {
|
if (w) {
|
||||||
|
|
|
@ -103,8 +103,6 @@ DECLARE_ALERT_STYLE(Critical);
|
||||||
@property (nonatomic) void *key_layout;
|
@property (nonatomic) void *key_layout;
|
||||||
@property (nonatomic) SDLTranslatorResponder *fieldEdit;
|
@property (nonatomic) SDLTranslatorResponder *fieldEdit;
|
||||||
@property (nonatomic) NSInteger clipboard_count;
|
@property (nonatomic) NSInteger clipboard_count;
|
||||||
@property (nonatomic) Uint32 screensaver_activity;
|
|
||||||
@property (nonatomic) BOOL screensaver_use_iopm;
|
|
||||||
@property (nonatomic) IOPMAssertionID screensaver_assertion;
|
@property (nonatomic) IOPMAssertionID screensaver_assertion;
|
||||||
@property (nonatomic) SDL_mutex *swaplock;
|
@property (nonatomic) SDL_mutex *swaplock;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -196,10 +196,7 @@ Cocoa_VideoInit(_THIS)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE));
|
data.allow_spaces = SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE);
|
||||||
|
|
||||||
/* The IOPM assertion API can disable the screensaver as of 10.7. */
|
|
||||||
data.screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
|
|
||||||
|
|
||||||
data.swaplock = SDL_CreateMutex();
|
data.swaplock = SDL_CreateMutex();
|
||||||
if (!data.swaplock) {
|
if (!data.swaplock) {
|
||||||
|
|
|
@ -1713,8 +1713,6 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (videodata.allow_spaces) {
|
if (videodata.allow_spaces) {
|
||||||
SDL_assert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6);
|
|
||||||
SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]);
|
|
||||||
/* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
|
/* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
|
||||||
if (window->flags & SDL_WINDOW_RESIZABLE) {
|
if (window->flags & SDL_WINDOW_RESIZABLE) {
|
||||||
/* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
|
/* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
|
||||||
|
@ -1738,10 +1736,8 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
||||||
#endif
|
#endif
|
||||||
/* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when
|
/* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when
|
||||||
* the NSHighResolutionCapable boolean is set in Info.plist. */
|
* the NSHighResolutionCapable boolean is set in Info.plist. */
|
||||||
if ([contentView respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
|
BOOL highdpi = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
|
||||||
BOOL highdpi = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
|
[contentView setWantsBestResolutionOpenGLSurface:highdpi];
|
||||||
[contentView setWantsBestResolutionOpenGLSurface:highdpi];
|
|
||||||
}
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
@ -1813,10 +1809,8 @@ Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
||||||
#endif
|
#endif
|
||||||
/* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when
|
/* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when
|
||||||
* the NSHighResolutionCapable boolean is set in Info.plist. */
|
* the NSHighResolutionCapable boolean is set in Info.plist. */
|
||||||
if ([nsview respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
|
BOOL highdpi = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
|
||||||
BOOL highdpi = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
|
[nsview setWantsBestResolutionOpenGLSurface:highdpi];
|
||||||
[nsview setWantsBestResolutionOpenGLSurface:highdpi];
|
|
||||||
}
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue