From 03dda56c9840a1c54a2e5b82d1c482c261a6c646 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Thu, 29 May 2025 05:22:01 +0800 Subject: [PATCH] Cocoa: adjustments to fix build --- src/video/cocoa/SDL_cocoaclipboard.m | 5 ++- src/video/cocoa/SDL_cocoaevents.m | 3 ++ src/video/cocoa/SDL_cocoakeyboard.h | 2 +- src/video/cocoa/SDL_cocoakeyboard.m | 14 ++++--- src/video/cocoa/SDL_cocoamessagebox.m | 2 +- src/video/cocoa/SDL_cocoamodes.m | 16 +++++++- src/video/cocoa/SDL_cocoamouse.h | 4 ++ src/video/cocoa/SDL_cocoamouse.m | 4 +- src/video/cocoa/SDL_cocoaopengl.h | 2 +- src/video/cocoa/SDL_cocoaopengl.m | 9 +++-- src/video/cocoa/SDL_cocoashape.m | 4 ++ src/video/cocoa/SDL_cocoavideo.h | 11 +++++ src/video/cocoa/SDL_cocoavideo.m | 13 +++--- src/video/cocoa/SDL_cocoawindow.h | 6 +++ src/video/cocoa/SDL_cocoawindow.m | 58 ++++++++++++++++++++++----- 15 files changed, 122 insertions(+), 31 deletions(-) diff --git src/video/cocoa/SDL_cocoaclipboard.m src/video/cocoa/SDL_cocoaclipboard.m index 495c934c0..e4838651b 100644 --- src/video/cocoa/SDL_cocoaclipboard.m +++ src/video/cocoa/SDL_cocoaclipboard.m @@ -28,13 +28,16 @@ static NSString * GetTextFormat(_THIS) { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - if (data->osversion >= 0x1060) { return NSPasteboardTypeString; } else { +#endif return NSStringPboardType; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 } +#endif } int diff --git src/video/cocoa/SDL_cocoaevents.m src/video/cocoa/SDL_cocoaevents.m index 438385c37..b85214d3c 100644 --- src/video/cocoa/SDL_cocoaevents.m +++ src/video/cocoa/SDL_cocoaevents.m @@ -126,7 +126,10 @@ - (void)focusSomeWindow:(NSNotification *)aNotification - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename { + /* FIXME: original code: return (BOOL)SDL_SendDropFile([filename UTF8String]); + */ + return false; // LAULAND } @end diff --git src/video/cocoa/SDL_cocoakeyboard.h src/video/cocoa/SDL_cocoakeyboard.h index a85f9b7b0..836654d15 100644 --- src/video/cocoa/SDL_cocoakeyboard.h +++ src/video/cocoa/SDL_cocoakeyboard.h @@ -29,7 +29,7 @@ extern void Cocoa_QuitKeyboard(_THIS); extern void Cocoa_StartTextInput(_THIS); extern void Cocoa_StopTextInput(_THIS); -extern void Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect); +extern void Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect); #endif /* _SDL_cocoakeyboard_h */ diff --git src/video/cocoa/SDL_cocoakeyboard.m src/video/cocoa/SDL_cocoakeyboard.m index 85bf9a067..e828b7f79 100644 --- src/video/cocoa/SDL_cocoakeyboard.m +++ src/video/cocoa/SDL_cocoakeyboard.m @@ -424,8 +424,9 @@ - (NSArray *) validAttributesForMarkedText } static void -UpdateKeymap(SDL_VideoData *data) +UpdateKeymap(SDL_VideoData *data, SDL_bool send_event) { +#if defined(MAC_OS_X_VERSION_10_5) TISInputSourceRef key_layout; const void *chr_data; int i; @@ -477,12 +478,13 @@ - (NSArray *) validAttributesForMarkedText keymap[scancode] = s[0]; } } - SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES); + SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES, send_event); return; } cleanup: CFRelease(key_layout); +#endif } void @@ -490,7 +492,7 @@ - (NSArray *) validAttributesForMarkedText { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - UpdateKeymap(data); + UpdateKeymap(data, SDL_FALSE); /* Set our own names for the platform-dependent but layout-independent keys */ /* This key is NumLock on the MacBook keyboard. :) */ @@ -549,7 +551,7 @@ - (NSArray *) validAttributesForMarkedText } void -Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect) +Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; @@ -558,7 +560,7 @@ - (NSArray *) validAttributesForMarkedText return; } - [data->fieldEdit setInputRect: rect]; + [data->fieldEdit setInputRect: (SDL_Rect *)rect]; } void @@ -587,7 +589,7 @@ - (NSArray *) validAttributesForMarkedText case NSKeyDown: if (![event isARepeat]) { /* See if we need to rebuild the keyboard layout */ - UpdateKeymap(data); + UpdateKeymap(data, SDL_TRUE); } SDL_SendKeyboardKey(SDL_PRESSED, code); diff --git src/video/cocoa/SDL_cocoamessagebox.m src/video/cocoa/SDL_cocoamessagebox.m index 730d952ee..bfb491267 100644 --- src/video/cocoa/SDL_cocoamessagebox.m +++ src/video/cocoa/SDL_cocoamessagebox.m @@ -132,7 +132,7 @@ - (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextIn } else { - returnValue = SDL_SetError("Did not get a valid `clicked button' id: %d", clicked); + returnValue = SDL_SetError("Did not get a valid `clicked button' id: %d", (int)clicked); } [pool release]; diff --git src/video/cocoa/SDL_cocoamodes.m src/video/cocoa/SDL_cocoamodes.m index f41c34937..fd39bfd6a 100644 --- src/video/cocoa/SDL_cocoamodes.m +++ src/video/cocoa/SDL_cocoamodes.m @@ -127,6 +127,7 @@ } data->moderef = moderef; + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 if (IS_SNOW_LEOPARD_OR_LATER(_this)) { CGDisplayModeRef vidmode = (CGDisplayModeRef) moderef; CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode); @@ -146,6 +147,7 @@ CFRelease(fmt); } + #endif #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 if (!IS_SNOW_LEOPARD_OR_LATER(_this)) { @@ -184,17 +186,21 @@ static void Cocoa_ReleaseDisplayMode(_THIS, const void *moderef) { + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 if (IS_SNOW_LEOPARD_OR_LATER(_this)) { CGDisplayModeRelease((CGDisplayModeRef) moderef); /* NULL is ok */ } + #endif } static void Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist) { + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 if (IS_SNOW_LEOPARD_OR_LATER(_this)) { CFRelease(modelist); /* NULL is ok */ } + #endif } static const char * @@ -257,9 +263,11 @@ continue; } + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 if (IS_SNOW_LEOPARD_OR_LATER(_this)) { moderef = CGDisplayCopyDisplayMode(displays[i]); } + #endif #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 if (!IS_SNOW_LEOPARD_OR_LATER(_this)) { @@ -291,7 +299,7 @@ display.desktop_mode = mode; display.current_mode = mode; display.driverdata = displaydata; - SDL_AddVideoDisplay(&display); + SDL_AddVideoDisplay(&display,FALSE); SDL_free(display.name); } } @@ -319,9 +327,11 @@ SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; CFArrayRef modes = NULL; + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 if (IS_SNOW_LEOPARD_OR_LATER(_this)) { modes = CGDisplayCopyAllDisplayModes(data->display, NULL); } + #endif #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 if (!IS_SNOW_LEOPARD_OR_LATER(_this)) { @@ -337,9 +347,11 @@ const void *moderef = CFArrayGetValueAtIndex(modes, i); SDL_DisplayMode mode; if (GetDisplayMode(_this, moderef, &mode)) { + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 if (IS_SNOW_LEOPARD_OR_LATER(_this)) { CGDisplayModeRetain((CGDisplayModeRef) moderef); } + #endif SDL_AddDisplayMode(display, &mode); } } @@ -351,9 +363,11 @@ static CGError Cocoa_SwitchMode(_THIS, CGDirectDisplayID display, const void *mode) { + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 if (IS_SNOW_LEOPARD_OR_LATER(_this)) { return CGDisplaySetDisplayMode(display, (CGDisplayModeRef) mode, NULL); } + #endif #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 if (!IS_SNOW_LEOPARD_OR_LATER(_this)) { diff --git src/video/cocoa/SDL_cocoamouse.h src/video/cocoa/SDL_cocoamouse.h index 336b84044..03f1d50a7 100644 --- src/video/cocoa/SDL_cocoamouse.h +++ src/video/cocoa/SDL_cocoamouse.h @@ -25,6 +25,10 @@ #include "SDL_cocoavideo.h" +#if !defined(MAC_OS_X_VERSION_10_5) +typedef float CGFloat; +#endif + extern void Cocoa_InitMouse(_THIS); extern void Cocoa_HandleMouseEvent(_THIS, NSEvent * event); extern void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent * event); diff --git src/video/cocoa/SDL_cocoamouse.m src/video/cocoa/SDL_cocoamouse.m index f5b54ed38..737855e00 100644 --- src/video/cocoa/SDL_cocoamouse.m +++ src/video/cocoa/SDL_cocoamouse.m @@ -151,7 +151,9 @@ + (NSCursor *)invisibleCursor nscursor = [NSCursor closedHandCursor]; break; case SDL_SYSTEM_CURSOR_NO: +#if defined(MAC_OS_X_VERSION_10_5) nscursor = [NSCursor operationNotAllowedCursor]; +#endif break; case SDL_SYSTEM_CURSOR_HAND: nscursor = [NSCursor pointingHandCursor]; @@ -372,7 +374,7 @@ + (NSCursor *)invisibleCursor } else if (y < 0) { y -= 0.9f; } - SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y); + SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y, SDL_MOUSEWHEEL_NORMAL); } void diff --git src/video/cocoa/SDL_cocoaopengl.h src/video/cocoa/SDL_cocoaopengl.h index 14fd3ab4a..36ca66839 100644 --- src/video/cocoa/SDL_cocoaopengl.h +++ src/video/cocoa/SDL_cocoaopengl.h @@ -58,7 +58,7 @@ extern void Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h); extern int Cocoa_GL_SetSwapInterval(_THIS, int interval); extern int Cocoa_GL_GetSwapInterval(_THIS); -extern void Cocoa_GL_SwapWindow(_THIS, SDL_Window * window); +extern int Cocoa_GL_SwapWindow(_THIS, SDL_Window * window); extern void Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context); #endif /* SDL_VIDEO_OPENGL_CGL */ diff --git src/video/cocoa/SDL_cocoaopengl.m src/video/cocoa/SDL_cocoaopengl.m index d9fb24409..0a10d4a59 100644 --- src/video/cocoa/SDL_cocoaopengl.m +++ src/video/cocoa/SDL_cocoaopengl.m @@ -347,9 +347,11 @@ - (void)setWindow:(SDL_Window *)newWindow /* This gives us the correct viewport for a Retina-enabled view, only * supported on 10.7+. */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) { viewport = [contentView convertRectToBacking:viewport]; } +#endif if (w) { *w = viewport.size.width; @@ -365,7 +367,7 @@ - (void)setWindow:(SDL_Window *)newWindow { NSAutoreleasePool *pool; NSOpenGLContext *nscontext; - GLint value; + long value; int status; if (interval < 0) { /* no extension for this on Mac OS X at the moment. */ @@ -392,7 +394,7 @@ - (void)setWindow:(SDL_Window *)newWindow { NSAutoreleasePool *pool; NSOpenGLContext *nscontext; - GLint value; + long value; int status = 0; pool = [[NSAutoreleasePool alloc] init]; @@ -407,7 +409,7 @@ - (void)setWindow:(SDL_Window *)newWindow return status; } -void +int Cocoa_GL_SwapWindow(_THIS, SDL_Window * window) { NSAutoreleasePool *pool; @@ -419,6 +421,7 @@ - (void)setWindow:(SDL_Window *)newWindow [nscontext updateIfNeeded]; [pool release]; + return 0; } void diff --git src/video/cocoa/SDL_cocoashape.m src/video/cocoa/SDL_cocoashape.m index b3843ccb0..326010a80 100644 --- src/video/cocoa/SDL_cocoashape.m +++ src/video/cocoa/SDL_cocoashape.m @@ -35,7 +35,11 @@ [windata->nswindow setOpaque:NO]; if ([windata->nswindow respondsToSelector:@selector(setStyleMask:)]) { +/* This actually should work across the board, see: + https://developer.apple.com/documentation/appkit/nsborderlesswindowmask */ +#if defined(MAC_OS_X_VERSION_10_5) [windata->nswindow setStyleMask:NSBorderlessWindowMask]; +#endif } SDL_WindowShaper* result = result = malloc(sizeof(SDL_WindowShaper)); diff --git src/video/cocoa/SDL_cocoavideo.h src/video/cocoa/SDL_cocoavideo.h index f194e1f72..757d8e55a 100644 --- src/video/cocoa/SDL_cocoavideo.h +++ src/video/cocoa/SDL_cocoavideo.h @@ -25,6 +25,12 @@ #include "SDL_opengl.h" +#if defined(__ALTIVEC__) && !defined(MAC_OS_X_VERSION_10_5) +/* to cricumvent a bug in Mac OS X 10.4 SDK */ +#define vector __vector +#include +#undef vector +#endif #include #include @@ -39,6 +45,11 @@ #include "SDL_cocoaopengl.h" #include "SDL_cocoawindow.h" +#if !defined(MAC_OS_X_VERSION_10_5) +typedef long int NSInteger; +typedef unsigned int NSUInteger; +#endif + /* Private display data */ @class SDLTranslatorResponder; diff --git src/video/cocoa/SDL_cocoavideo.m src/video/cocoa/SDL_cocoavideo.m index 6766b71bb..812797e89 100644 --- src/video/cocoa/SDL_cocoavideo.m +++ src/video/cocoa/SDL_cocoavideo.m @@ -33,6 +33,7 @@ #include "SDL_endian.h" #include "SDL_cocoavideo.h" #include "SDL_cocoashape.h" +#include "SDL_cocoamessagebox.h" #include "SDL_assert.h" /* Initialization/Query functions */ @@ -41,11 +42,13 @@ /* Cocoa driver bootstrap functions */ +/* static int Cocoa_Available(void) { return (1); } +*/ static void Cocoa_DeleteDevice(SDL_VideoDevice * device) @@ -55,7 +58,7 @@ } static SDL_VideoDevice * -Cocoa_CreateDevice(int devindex) +Cocoa_CreateDevice(void/*int devindex*/) { SDL_VideoDevice *device; SDL_VideoData *data; @@ -87,8 +90,8 @@ device->SetDisplayMode = Cocoa_SetDisplayMode; device->PumpEvents = Cocoa_PumpEvents; - device->CreateWindow = Cocoa_CreateWindow; - device->CreateWindowFrom = Cocoa_CreateWindowFrom; + device->CreateSDLWindow = Cocoa_CreateWindow; + device->CreateSDLWindowFrom = Cocoa_CreateWindowFrom; device->SetWindowTitle = Cocoa_SetWindowTitle; device->SetWindowIcon = Cocoa_SetWindowIcon; device->SetWindowPosition = Cocoa_SetWindowPosition; @@ -105,7 +108,7 @@ device->SetWindowFullscreen = Cocoa_SetWindowFullscreen; device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp; device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp; - device->SetWindowGrab = Cocoa_SetWindowGrab; + device->SetWindowMouseGrab = Cocoa_SetWindowGrab; device->DestroyWindow = Cocoa_DestroyWindow; device->GetWindowWMInfo = Cocoa_GetWindowWMInfo; @@ -141,7 +144,7 @@ VideoBootStrap COCOA_bootstrap = { "cocoa", "SDL Cocoa video driver", - Cocoa_Available, Cocoa_CreateDevice + Cocoa_CreateDevice, Cocoa_ShowMessageBox }; diff --git src/video/cocoa/SDL_cocoawindow.h src/video/cocoa/SDL_cocoawindow.h index a4ec07d72..6c57c9563 100644 --- src/video/cocoa/SDL_cocoawindow.h +++ src/video/cocoa/SDL_cocoawindow.h @@ -35,7 +35,11 @@ typedef enum PENDING_OPERATION_MINIMIZE } PendingWindowOperation; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 @interface Cocoa_WindowListener : NSResponder { +#else +@interface Cocoa_WindowListener : NSResponder { +#endif SDL_WindowData *_data; BOOL observingVisible; BOOL wasCtrlLeft; @@ -73,7 +77,9 @@ typedef enum -(void) windowDidEnterFullScreen:(NSNotification *) aNotification; -(void) windowWillExitFullScreen:(NSNotification *) aNotification; -(void) windowDidExitFullScreen:(NSNotification *) aNotification; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 -(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; +#endif /* Window event handling */ -(void) mouseDown:(NSEvent *) theEvent; diff --git src/video/cocoa/SDL_cocoawindow.m src/video/cocoa/SDL_cocoawindow.m index a55ab4967..1c7cfbbff 100644 --- src/video/cocoa/SDL_cocoawindow.m +++ src/video/cocoa/SDL_cocoawindow.m @@ -22,10 +22,6 @@ #if SDL_VIDEO_DRIVER_COCOA -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 -# error SDL for Mac OS X must be built with a 10.7 SDK or above. -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1070 */ - #include "SDL_syswm.h" #include "SDL_timer.h" /* For SDL_GetTicks() */ #include "SDL_hints.h" @@ -100,7 +96,14 @@ static void ConvertNSRect(NSRect *r) NSOpenGLContext *currentContext = [NSOpenGLContext currentContext]; NSMutableArray *contexts = data->nscontexts; @synchronized (contexts) { +#if defined(MAC_OS_X_VERSION_10_5) for (SDLOpenGLContext *context in contexts) { +#else + /* old way to iterate */ + int i; + for (i = 0; i < [contexts count]; i++) { + SDLOpenGLContext *context = [contexts objectAtIndex:i]; +#endif if (context == currentContext) { [context update]; } else { @@ -190,10 +193,12 @@ - (void)listen:(SDL_WindowData *)data [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window]; [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window]; [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window]; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 [center addObserver:self selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window]; [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window]; [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window]; [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window]; +#endif } else { [window setDelegate:self]; } @@ -212,9 +217,11 @@ - (void)listen:(SDL_WindowData *)data [view setNextResponder:self]; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 if ([view respondsToSelector:@selector(setAcceptsTouchEvents:)]) { [view setAcceptsTouchEvents:YES]; } +#endif } - (void)observeValueForKeyPath:(NSString *)keyPath @@ -282,7 +289,9 @@ -(BOOL) setFullscreenSpace:(BOOL) state inFullscreenTransition = YES; /* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; +#endif [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO]; return YES; } @@ -319,10 +328,12 @@ - (void)close [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window]; [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window]; [center removeObserver:self name:NSWindowDidResignKeyNotification object:window]; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 [center removeObserver:self name:NSWindowWillEnterFullScreenNotification object:window]; [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window]; [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window]; [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window]; +#endif } else { [window setDelegate:nil]; } @@ -346,8 +357,14 @@ - (void)close !!! FIXME: http://bugzilla.libsdl.org/show_bug.cgi?id=1825 */ windows = [NSApp orderedWindows]; - for (NSWindow *win in windows) - { +#if defined(MAC_OS_X_VERSION_10_5) + for (NSWindow *win in windows) { +#else + /* old way to iterate */ + int i; + for (i = 0; i < [windows count]; i++) { + NSWindow *win = [windows objectAtIndex:i]; +#endif if (win == window) { continue; } @@ -597,12 +614,14 @@ - (void)windowDidExitFullScreen:(NSNotification *)aNotification [nswindow miniaturize:nil]; } else { /* Adjust the fullscreen toggle button and readd menu now that we're here. */ +#if MAC_OS_X_VERSION_MIN_REQUIRED > 1070 if (window->flags & SDL_WINDOW_RESIZABLE) { /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; } else { [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged]; } +#endif [NSMenu setMenuBarVisible:YES]; pendingWindowOperation = PENDING_OPERATION_NONE; @@ -620,6 +639,7 @@ - (void)windowDidExitFullScreen:(NSNotification *)aNotification } } +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 -(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { @@ -628,6 +648,7 @@ -(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPr return proposedOptions; } } +#endif /* We'll respond to key events by doing nothing so we don't beep. @@ -662,7 +683,7 @@ - (void)mouseDown:(NSEvent *)theEvent switch ([theEvent buttonNumber]) { case 0: if (([theEvent modifierFlags] & NSControlKeyMask) && - GetHintCtrlClickEmulateRightClick()) { + GetHintCtrlClickEmulateRightClick()) { wasCtrlLeft = YES; button = SDL_BUTTON_RIGHT; } else { @@ -822,6 +843,7 @@ - (void)touchesCancelledWithEvent:(NSEvent *) theEvent [self handleTouches:COCOA_TOUCH_CANCELLED withEvent:theEvent]; } +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event { NSSet *touches = 0; @@ -847,8 +869,10 @@ - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event touch = (NSTouch*)[enumerator nextObject]; while (touch) { const SDL_TouchID touchId = (SDL_TouchID)(intptr_t)[touch device]; + SDL_TouchDeviceType devtype = SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE; + SDL_Window *window = NULL; if (!SDL_GetTouch(touchId)) { - if (SDL_AddTouch(touchId, "") < 0) { + if (SDL_AddTouch(touchId, devtype, "") < 0) { return; } } @@ -861,20 +885,21 @@ - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event switch (type) { case COCOA_TOUCH_DOWN: - SDL_SendTouch(touchId, fingerId, SDL_TRUE, x, y, 1.0f); + SDL_SendTouch(touchId, fingerId, window, SDL_TRUE, x, y, 1.0f); break; case COCOA_TOUCH_UP: case COCOA_TOUCH_CANCELLED: - SDL_SendTouch(touchId, fingerId, SDL_FALSE, x, y, 1.0f); + SDL_SendTouch(touchId, fingerId, window, SDL_FALSE, x, y, 1.0f); break; case COCOA_TOUCH_MOVE: - SDL_SendTouchMotion(touchId, fingerId, x, y, 1.0f); + SDL_SendTouchMotion(touchId, fingerId, window, x, y, 1.0f); break; } touch = (NSTouch*)[enumerator nextObject]; } } +#endif @end @@ -1040,6 +1065,7 @@ - (void)resetCursorRects [nswindow setBackgroundColor:[NSColor blackColor]]; if (videodata->allow_spaces) { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 SDL_assert(videodata->osversion >= 0x1070); SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]); /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */ @@ -1047,6 +1073,7 @@ - (void)resetCursorRects /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; } +#endif } /* Create a default view for this window */ @@ -1055,7 +1082,9 @@ - (void)resetCursorRects if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { if ([contentView respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 [contentView setWantsBestResolutionOpenGLSurface:YES]; +#endif } } @@ -1490,7 +1519,14 @@ - (void)resetCursorRects } NSArray *contexts = [[data->nscontexts copy] autorelease]; +#if defined(MAC_OS_X_VERSION_10_5) for (SDLOpenGLContext *context in contexts) { +#else + /* old way to iterate */ + int i; + for (i = 0; i < [contexts count]; i++) { + SDLOpenGLContext *context = [contexts objectAtIndex:i]; +#endif /* Calling setWindow:NULL causes the context to remove itself from the context list. */ [context setWindow:NULL]; } -- 2.24.3 (Apple Git-128)