diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6c8372ca3..bc88800ee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1301,7 +1301,7 @@ endif() if( APPLE ) set_target_properties(zdoom PROPERTIES - LINK_FLAGS "-framework Carbon -framework Cocoa -framework IOKit -framework OpenGL" + LINK_FLAGS "-framework Cocoa -framework IOKit -framework OpenGL" MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/zdoom-info.plist" ) endif() diff --git a/src/posix/cocoa/i_common.h b/src/posix/cocoa/i_common.h index 5b2d6f6cb..be395cf76 100644 --- a/src/posix/cocoa/i_common.h +++ b/src/posix/cocoa/i_common.h @@ -56,9 +56,6 @@ extern RenderBufferOptions rbOpts; // Version of AppKit framework we are interested in // The following values are needed to build with earlier SDKs -#define AppKit10_4 824 -#define AppKit10_5 949 -#define AppKit10_6 1038 #define AppKit10_7 1138 #define AppKit10_8 1187 #define AppKit10_9 1265 @@ -69,11 +66,6 @@ extern RenderBufferOptions rbOpts; @end -inline bool I_IsHiDPISupported() -{ - return NSAppKitVersionNumber >= AppKit10_7; -} - void I_ProcessEvent(NSEvent* event); void I_ProcessJoysticks(); @@ -82,124 +74,4 @@ NSSize I_GetContentViewSize(const NSWindow* window); void I_SetMainWindowVisible(bool visible); void I_SetNativeMouse(bool wantNative); - -// The following definitions are required to build with older OS X SDKs - -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 - -typedef unsigned int NSUInteger; -typedef int NSInteger; - -typedef float CGFloat; - -// From HIToolbox/Events.h -enum -{ - kVK_ANSI_F = 0x03, - kVK_Return = 0x24, - kVK_Tab = 0x30, - kVK_Space = 0x31, - kVK_Delete = 0x33, - kVK_Escape = 0x35, - kVK_Command = 0x37, - kVK_Shift = 0x38, - kVK_CapsLock = 0x39, - kVK_Option = 0x3A, - kVK_Control = 0x3B, - kVK_RightShift = 0x3C, - kVK_RightOption = 0x3D, - kVK_RightControl = 0x3E, - kVK_Function = 0x3F, - kVK_F17 = 0x40, - kVK_VolumeUp = 0x48, - kVK_VolumeDown = 0x49, - kVK_Mute = 0x4A, - kVK_F18 = 0x4F, - kVK_F19 = 0x50, - kVK_F20 = 0x5A, - kVK_F5 = 0x60, - kVK_F6 = 0x61, - kVK_F7 = 0x62, - kVK_F3 = 0x63, - kVK_F8 = 0x64, - kVK_F9 = 0x65, - kVK_F11 = 0x67, - kVK_F13 = 0x69, - kVK_F16 = 0x6A, - kVK_F14 = 0x6B, - kVK_F10 = 0x6D, - kVK_F12 = 0x6F, - kVK_F15 = 0x71, - kVK_Help = 0x72, - kVK_Home = 0x73, - kVK_PageUp = 0x74, - kVK_ForwardDelete = 0x75, - kVK_F4 = 0x76, - kVK_End = 0x77, - kVK_F2 = 0x78, - kVK_PageDown = 0x79, - kVK_F1 = 0x7A, - kVK_LeftArrow = 0x7B, - kVK_RightArrow = 0x7C, - kVK_DownArrow = 0x7D, - kVK_UpArrow = 0x7E -}; - -static const NSOpenGLPixelFormatAttribute NSOpenGLPFAAllowOfflineRenderers = NSOpenGLPixelFormatAttribute(96); - -@interface NSWindow(SetCollectionBehavior) -- (void)setCollectionBehavior:(NSUInteger)collectionBehavior; -@end - -typedef NSUInteger NSWindowCollectionBehavior; - -#endif // prior to 10.5 - - -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 - -enum -{ - NSApplicationActivationPolicyRegular -}; - -typedef NSInteger NSApplicationActivationPolicy; - -@interface NSApplication(ActivationPolicy) -- (BOOL)setActivationPolicy:(NSApplicationActivationPolicy)activationPolicy; -@end - -@interface NSWindow(SetStyleMask) -- (void)setStyleMask:(NSUInteger)styleMask; -@end - -#endif // prior to 10.6 - - -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 - -@interface NSView(HiDPIStubs) -- (NSPoint)convertPointToBacking:(NSPoint)aPoint; -- (NSSize)convertSizeToBacking:(NSSize)aSize; -- (NSSize)convertSizeFromBacking:(NSSize)aSize; - -- (void)setWantsBestResolutionOpenGLSurface:(BOOL)flag; -@end - -@interface NSView(Compatibility) -- (NSRect)convertRectToBacking:(NSRect)aRect; -@end - -@interface NSScreen(HiDPIStubs) -- (NSRect)convertRectToBacking:(NSRect)aRect; -@end - -static const NSWindowCollectionBehavior NSWindowCollectionBehaviorFullScreenAuxiliary = NSWindowCollectionBehavior(1 << 8); - -static const auto NSOpenGLPFAOpenGLProfile = NSOpenGLPixelFormatAttribute(96); -static const auto NSOpenGLProfileVersionLegacy = NSOpenGLPixelFormatAttribute(0x1000); -static const auto NSOpenGLProfileVersion3_2Core = NSOpenGLPixelFormatAttribute(0x3200); - -#endif // prior to 10.7 - #endif // COCOA_I_COMMON_INCLUDED diff --git a/src/posix/cocoa/i_input.mm b/src/posix/cocoa/i_input.mm index 4f0aa25d5..eff9640be 100644 --- a/src/posix/cocoa/i_input.mm +++ b/src/posix/cocoa/i_input.mm @@ -480,11 +480,7 @@ void NSEventToGameMousePosition(NSEvent* inEvent, event_t* outEvent) const NSPoint screenPos = [NSEvent mouseLocation]; const NSPoint windowPos = [window convertScreenToBase:screenPos]; - - const NSPoint viewPos = I_IsHiDPISupported() - ? [view convertPointToBacking:windowPos] - : [view convertPoint:windowPos fromView:nil]; - + const NSPoint viewPos = [view convertPointToBacking:windowPos]; const CGFloat frameHeight = I_GetContentViewSize(window).height; const CGFloat posX = ( viewPos.x - rbOpts.shiftX) / rbOpts.pixelScale; diff --git a/src/posix/cocoa/i_main.mm b/src/posix/cocoa/i_main.mm index 0b49a6d21..4ac42261a 100644 --- a/src/posix/cocoa/i_main.mm +++ b/src/posix/cocoa/i_main.mm @@ -273,10 +273,7 @@ int OriginalMain(int argc, char** argv) // --------------------------------------------------------------------------- -@interface ApplicationController : NSResponder -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 - -#endif +@interface ApplicationController : NSResponder { } diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index e0f1e6c68..393ca6a89 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -35,8 +35,6 @@ #include "i_common.h" -#import - // Avoid collision between DObject class and Objective-C #define Class ObjectClass @@ -69,19 +67,6 @@ #undef Class -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 - -@implementation NSView(Compatibility) - -- (NSRect)convertRectToBacking:(NSRect)aRect -{ - return [self convertRect:aRect toView:[self superview]]; -} - -@end - -#endif // prior to 10.7 - @implementation NSWindow(ExitAppOnClose) - (void)exitAppOnClose @@ -304,7 +289,6 @@ private: bool m_fullscreen; bool m_hiDPI; - void SetStyleMask(NSUInteger styleMask); void SetFullscreenMode(int width, int height); void SetWindowedMode(int width, int height); void SetMode(int width, int height, bool fullscreen, bool hiDPI); @@ -510,18 +494,14 @@ NSOpenGLPixelFormat* CreatePixelFormat(const NSOpenGLPixelFormatAttribute profil attributes[i++] = NSOpenGLPixelFormatAttribute(24); attributes[i++] = NSOpenGLPFAStencilSize; attributes[i++] = NSOpenGLPixelFormatAttribute(8); - - if (NSAppKitVersionNumber >= AppKit10_5 && !vid_autoswitch) + attributes[i++] = NSOpenGLPFAOpenGLProfile; + attributes[i++] = profile; + + if (!vid_autoswitch) { attributes[i++] = NSOpenGLPFAAllowOfflineRenderers; } - if (NSAppKitVersionNumber >= AppKit10_7) - { - attributes[i++] = NSOpenGLPFAOpenGLProfile; - attributes[i++] = profile; - } - attributes[i] = NSOpenGLPixelFormatAttribute(0); return [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; @@ -553,11 +533,6 @@ CocoaVideo::CocoaVideo() // There is no support for OpenGL 3.3 before Mavericks defaultProfile = NSOpenGLProfileVersionLegacy; } - else if (0 == vid_renderer && vid_glswfb && NSAppKitVersionNumber < AppKit10_7) - { - // There is no support for OpenGL 3.x before Lion - defaultProfile = NSOpenGLProfileVersionLegacy; - } else if (const char* const glversion = Args->CheckValue("-glversion")) { // Check for explicit version specified in command line @@ -738,26 +713,6 @@ void CocoaVideo::SetWindowVisible(bool visible) } -static bool HasModernFullscreenAPI() -{ - return NSAppKitVersionNumber >= AppKit10_6; -} - -void CocoaVideo::SetStyleMask(const NSUInteger styleMask) -{ - // Before 10.6 it's impossible to change window's style mask - // To workaround this new window should be created with required style mask - // This method should not be called when running on Snow Leopard or newer - - assert(!HasModernFullscreenAPI()); - - CocoaWindow* tempWindow = CreateCocoaWindow(styleMask); - [tempWindow setContentView:[m_window contentView]]; - - [m_window close]; - m_window = tempWindow; -} - void CocoaVideo::SetFullscreenMode(const int width, const int height) { NSScreen* screen = [m_window screen]; @@ -783,20 +738,8 @@ void CocoaVideo::SetFullscreenMode(const int width, const int height) if (!m_fullscreen) { - if (HasModernFullscreenAPI()) - { - [m_window setLevel:LEVEL_FULLSCREEN]; - [m_window setStyleMask:STYLE_MASK_FULLSCREEN]; - } - else - { - // Old Carbon-based way to make fullscreen window above dock and menu - // It's supported on 64-bit, but on 10.6 and later the following is preferred: - // [NSWindow setLevel:NSMainMenuWindowLevel + 1] - - SetSystemUIMode(kUIModeAllHidden, 0); - SetStyleMask(STYLE_MASK_FULLSCREEN); - } + [m_window setLevel:LEVEL_FULLSCREEN]; + [m_window setStyleMask:STYLE_MASK_FULLSCREEN]; [m_window setHidesOnDeactivate:YES]; } @@ -821,16 +764,8 @@ void CocoaVideo::SetWindowedMode(const int width, const int height) if (m_fullscreen) { - if (HasModernFullscreenAPI()) - { - [m_window setLevel:LEVEL_WINDOWED]; - [m_window setStyleMask:STYLE_MASK_WINDOWED]; - } - else - { - SetSystemUIMode(kUIModeNormal, 0); - SetStyleMask(STYLE_MASK_WINDOWED); - } + [m_window setLevel:LEVEL_WINDOWED]; + [m_window setStyleMask:STYLE_MASK_WINDOWED]; [m_window setHidesOnDeactivate:NO]; } @@ -851,11 +786,8 @@ void CocoaVideo::SetMode(const int width, const int height, const bool fullscree return; } - if (I_IsHiDPISupported()) - { - NSOpenGLView* const glView = [m_window contentView]; - [glView setWantsBestResolutionOpenGLSurface:hiDPI]; - } + NSOpenGLView* const glView = [m_window contentView]; + [glView setWantsBestResolutionOpenGLSurface:hiDPI]; if (fullscreen) { @@ -1115,11 +1047,7 @@ bool CocoaFrameBuffer::IsFullscreen() void CocoaFrameBuffer::SetVSync(bool vsync) { -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 - const long value = vsync ? 1 : 0; -#else // 10.5 or newer const GLint value = vsync ? 1 : 0; -#endif // prior to 10.5 [[NSOpenGLContext currentContext] setValues:&value forParameter:NSOpenGLCPSwapInterval]; @@ -1237,11 +1165,7 @@ bool SDLGLFB::IsFullscreen() void SDLGLFB::SetVSync(bool vsync) { -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 - const long value = vsync ? 1 : 0; -#else // 10.5 or newer const GLint value = vsync ? 1 : 0; -#endif // prior to 10.5 [[NSOpenGLContext currentContext] setValues:&value forParameter:NSOpenGLCPSwapInterval]; @@ -1473,14 +1397,7 @@ CUSTOM_CVAR(Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CUSTOM_CVAR(Bool, vid_hidpi, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { - if (I_IsHiDPISupported()) - { - CocoaVideo::UseHiDPI(self); - } - else if (0 != self) - { - self = 0; - } + CocoaVideo::UseHiDPI(self); } diff --git a/src/posix/cocoa/st_console.mm b/src/posix/cocoa/st_console.mm index 67f906c69..87d93038f 100644 --- a/src/posix/cocoa/st_console.mm +++ b/src/posix/cocoa/st_console.mm @@ -113,11 +113,8 @@ FConsoleWindow::FConsoleWindow() [m_window center]; [m_window exitAppOnClose]; - if (NSAppKitVersionNumber >= AppKit10_7) - { - // Do not allow fullscreen mode for this window - [m_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary]; - } + // Do not allow fullscreen mode for this window + [m_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary]; [[m_window contentView] addSubview:m_scrollView]; diff --git a/src/posix/osx/iwadpicker_cocoa.mm b/src/posix/osx/iwadpicker_cocoa.mm index 9367dc53f..6b8a10b6a 100644 --- a/src/posix/osx/iwadpicker_cocoa.mm +++ b/src/posix/osx/iwadpicker_cocoa.mm @@ -50,10 +50,6 @@ #include #include -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 -// Missing type definition for 10.4 and earlier -typedef unsigned int NSUInteger; -#endif // prior to 10.5 CVAR(String, osx_additional_parameters, "", CVAR_ARCHIVE | CVAR_NOSET | CVAR_GLOBALCONFIG); @@ -68,10 +64,7 @@ enum static const char* const tableHeaders[NUM_COLUMNS] = { "IWAD", "Game" }; // Class to convert the IWAD data into a form that Cocoa can use. -@interface IWADTableData : NSObject -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 - -#endif +@interface IWADTableData : NSObject { NSMutableArray *data; } diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index 905e2de78..c1d830659 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -501,14 +501,6 @@ void SDLFB::SetVSync (bool vsync) if (CGLContextObj context = CGLGetCurrentContext()) { // Apply vsync for native backend only (where OpenGL context is set) - -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 - // Inconsistency between 10.4 and 10.5 SDKs: - // third argument of CGLSetParameter() is const long* on 10.4 and const GLint* on 10.5 - // So, GLint typedef'ed to long instead of int to workaround this issue - typedef long GLint; -#endif // prior to 10.5 - const GLint value = vsync ? 1 : 0; CGLSetParameter(context, kCGLCPSwapInterval, &value); }