Removed Mac OS 10.5 support (bug #3137). Also fixed a warning about deprecated Carbon code when using SDL_audio (bug #3127, thanks Dominik!)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781
diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
index 9fc2a50..9d685da 100755
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
@@ -2774,7 +2774,7 @@
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_OPTIMIZATION_LEVEL = 3;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
SDKROOT = macosx;
STRIP_STYLE = "non-global";
};
@@ -2832,7 +2832,7 @@
GCC_ENABLE_SSE3_EXTENSIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
STRIP_INSTALLED_PRODUCT = NO;
diff --git a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
index 59cdd63..144d24c 100755
--- a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
+++ b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
@@ -3934,7 +3934,7 @@
);
GCC_OPTIMIZATION_LEVEL = 0;
HEADER_SEARCH_PATHS = ../../include;
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
};
name = Debug;
};
@@ -4060,7 +4060,7 @@
);
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
HEADER_SEARCH_PATHS = ../../include;
- MACOSX_DEPLOYMENT_TARGET = 10.5;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
};
name = Release;
};
diff --git a/build-scripts/g++-fat.sh b/build-scripts/g++-fat.sh
index 29b0430..0dbe990 100755
--- a/build-scripts/g++-fat.sh
+++ b/build-scripts/g++-fat.sh
@@ -6,11 +6,11 @@
DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
-# Intel 32-bit compiler flags (10.5 runtime compatibility)
-GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.5 \
+# Intel 32-bit compiler flags (10.6 runtime compatibility)
+GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.6 \
-I/usr/local/include"
-GCC_LINK_X86="-mmacosx-version-min=10.5"
+GCC_LINK_X86="-mmacosx-version-min=10.6"
# Intel 64-bit compiler flags (10.6 runtime compatibility)
GCC_COMPILE_X64="g++ -arch x86_64 -mmacosx-version-min=10.6 \
diff --git a/build-scripts/gcc-fat.sh b/build-scripts/gcc-fat.sh
index e556c1d..bfc72b8 100755
--- a/build-scripts/gcc-fat.sh
+++ b/build-scripts/gcc-fat.sh
@@ -6,11 +6,11 @@
DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
-# Intel 32-bit compiler flags (10.5 runtime compatibility)
-GCC_COMPILE_X86="gcc -arch i386 -mmacosx-version-min=10.5 \
+# Intel 32-bit compiler flags (10.6 runtime compatibility)
+GCC_COMPILE_X86="gcc -arch i386 -mmacosx-version-min=10.6 \
-I/usr/local/include"
-GCC_LINK_X86="-mmacosx-version-min=10.5"
+GCC_LINK_X86="-mmacosx-version-min=10.6"
# Intel 64-bit compiler flags (10.6 runtime compatibility)
GCC_COMPILE_X64="gcc -arch x86_64 -mmacosx-version-min=10.6 \
diff --git a/include/SDL_platform.h b/include/SDL_platform.h
index c6c2139..974cafc 100644
--- a/include/SDL_platform.h
+++ b/include/SDL_platform.h
@@ -79,9 +79,9 @@
/* if not compiling for iPhone */
#undef __MACOSX__
#define __MACOSX__ 1
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
-# error SDL for Mac OS X only supports deploying on 10.5 and above.
-#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+# error SDL for Mac OS X only supports deploying on 10.6 and above.
+#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */
#endif /* TARGET_OS_IPHONE */
#endif /* defined(__APPLE__) */
diff --git a/src/audio/coreaudio/SDL_coreaudio.c b/src/audio/coreaudio/SDL_coreaudio.c
index 46b617d..3641d53 100644
--- a/src/audio/coreaudio/SDL_coreaudio.c
+++ b/src/audio/coreaudio/SDL_coreaudio.c
@@ -406,13 +406,7 @@ COREAUDIO_CloseDevice(_THIS)
AudioUnitSetProperty(this->hidden->audioUnit,
kAudioUnitProperty_SetRenderCallback,
scope, bus, &callback, sizeof(callback));
-
- #if MACOSX_COREAUDIO
- CloseComponent(this->hidden->audioUnit);
- #else
AudioComponentInstanceDispose(this->hidden->audioUnit);
- #endif
-
this->hidden->audioUnitOpened = 0;
}
SDL_free(this->hidden->buffer);
@@ -482,13 +476,8 @@ prepare_audiounit(_THIS, void *handle, int iscapture,
{
OSStatus result = noErr;
AURenderCallbackStruct callback;
-#if MACOSX_COREAUDIO
- ComponentDescription desc;
- Component comp = NULL;
-#else
AudioComponentDescription desc;
AudioComponent comp = NULL;
-#endif
const AudioUnitElement output_bus = 0;
const AudioUnitElement input_bus = 1;
const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus);
@@ -507,11 +496,10 @@ prepare_audiounit(_THIS, void *handle, int iscapture,
#if MACOSX_COREAUDIO
desc.componentSubType = kAudioUnitSubType_DefaultOutput;
- comp = FindNextComponent(NULL, &desc);
#else
desc.componentSubType = kAudioUnitSubType_RemoteIO;
- comp = AudioComponentFindNext(NULL, &desc);
#endif
+ comp = AudioComponentFindNext(NULL, &desc);
if (comp == NULL) {
SDL_SetError("Couldn't find requested CoreAudio component");
@@ -519,17 +507,8 @@ prepare_audiounit(_THIS, void *handle, int iscapture,
}
/* Open & initialize the audio unit */
-#if MACOSX_COREAUDIO
- result = OpenAComponent(comp, &this->hidden->audioUnit);
- CHECK_RESULT("OpenAComponent");
-#else
- /*
- AudioComponentInstanceNew only available on iPhone OS 2.0 and Mac OS X 10.6
- We can't use OpenAComponent on iPhone because it is not present
- */
result = AudioComponentInstanceNew(comp, &this->hidden->audioUnit);
CHECK_RESULT("AudioComponentInstanceNew");
-#endif
this->hidden->audioUnitOpened = 1;
diff --git a/src/joystick/darwin/SDL_sysjoystick.c b/src/joystick/darwin/SDL_sysjoystick.c
index 6dd306a..65cd2fc 100644
--- a/src/joystick/darwin/SDL_sysjoystick.c
+++ b/src/joystick/darwin/SDL_sysjoystick.c
@@ -422,6 +422,7 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic
{
recDevice *device;
int device_index = 0;
+ io_service_t ioservice;
if (res != kIOReturnSuccess) {
return;
@@ -451,20 +452,11 @@ JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDevic
device->instance_id = ++s_joystick_instance_id;
/* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- if (IOHIDDeviceGetService != NULL) { /* weak reference: available in 10.6 and later. */
-#endif
-
- const io_service_t ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
+ ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
#if SDL_HAPTIC_IOKIT
- if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) {
- device->ffservice = ioservice;
- MacHaptic_MaybeAddDevice(ioservice);
- }
-#endif
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+ if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) {
+ device->ffservice = ioservice;
+ MacHaptic_MaybeAddDevice(ioservice);
}
#endif
diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m
index 015d771..f97dd28 100644
--- a/src/video/cocoa/SDL_cocoaclipboard.m
+++ b/src/video/cocoa/SDL_cocoaclipboard.m
@@ -25,23 +25,13 @@
#include "SDL_cocoavideo.h"
#include "../../events/SDL_clipboardevents_c.h"
-static NSString *
-GetTextFormat(_THIS)
-{
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
- return NSPasteboardTypeString;
- } else {
- return NSStringPboardType;
- }
-}
-
int
Cocoa_SetClipboardText(_THIS, const char *text)
{ @autoreleasepool
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
NSPasteboard *pasteboard;
- NSString *format = GetTextFormat(_this);
+ NSString *format = NSPasteboardTypeString;
pasteboard = [NSPasteboard generalPasteboard];
data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
@@ -55,7 +45,7 @@ Cocoa_GetClipboardText(_THIS)
{ @autoreleasepool
{
NSPasteboard *pasteboard;
- NSString *format = GetTextFormat(_this);
+ NSString *format = NSPasteboardTypeString;
NSString *available;
char *text;
diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m
index c0916fe..a6c9745 100644
--- a/src/video/cocoa/SDL_cocoaevents.m
+++ b/src/video/cocoa/SDL_cocoaevents.m
@@ -114,28 +114,23 @@
*/
for (NSWindow *window in [NSApp orderedWindows]) {
if (window != win && [window canBecomeKeyWindow]) {
- if ([window respondsToSelector:@selector(isOnActiveSpace)]) {
- if (![window isOnActiveSpace]) {
- continue;
- }
+ if (![window isOnActiveSpace]) {
+ continue;
}
[window makeKeyAndOrderFront:self];
return;
}
}
- /* If a window wasn't found above, iterate through all visible windows
- * (including the 'About' window, if it's shown) and make the first one key.
- * Note that +[NSWindow windowNumbersWithOptions:] was added in 10.6.
+ /* If a window wasn't found above, iterate through all visible windows in
+ * the active Space in z-order (including the 'About' window, if it's shown)
+ * and make the first one key.
*/
- if ([NSWindow respondsToSelector:@selector(windowNumbersWithOptions:)]) {
- /* Get all visible windows in the active Space, in z-order. */
- for (NSNumber *num in [NSWindow windowNumbersWithOptions:0]) {
- NSWindow *window = [NSApp windowWithWindowNumber:[num integerValue]];
- if (window && window != win && [window canBecomeKeyWindow]) {
- [window makeKeyAndOrderFront:self];
- return;
- }
+ for (NSNumber *num in [NSWindow windowNumbersWithOptions:0]) {
+ NSWindow *window = [NSApp windowWithWindowNumber:[num integerValue]];
+ if (window && window != win && [window canBecomeKeyWindow]) {
+ [window makeKeyAndOrderFront:self];
+ return;
}
}
}
@@ -291,7 +286,7 @@ CreateApplicationMenus(void)
/* Add the fullscreen view toggle menu option, if supported */
- if ([NSApp respondsToSelector:@selector(setPresentationOptions:)]) {
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
/* Create the view menu */
viewMenu = [[NSMenu alloc] initWithTitle:@"View"];
@@ -321,16 +316,7 @@ Cocoa_RegisterApp(void)
const char *hint = SDL_GetHint(SDL_HINT_MAC_BACKGROUND_APP);
if (!hint || *hint == '0') {
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
- if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
-#endif
- [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
- } else {
- ProcessSerialNumber psn = {0, kCurrentProcess};
- TransformProcessType(&psn, kProcessTransformToForegroundApplication);
- }
-#endif
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
[NSApp activateIgnoringOtherApps:YES];
}
diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m
index 7f1d230..8c6f177 100644
--- a/src/video/cocoa/SDL_cocoakeyboard.m
+++ b/src/video/cocoa/SDL_cocoakeyboard.m
@@ -69,14 +69,6 @@
SDL_SendKeyboardText(str);
}
-- (void)insertText:(id)insertString
-{
- /* This method is part of NSTextInput and not NSTextInputClient, but
- * apparently it still might be called in OS X 10.5 and can cause beeps if
- * the implementation is missing: http://crbug.com/47890 */
- [self insertText:insertString replacementRange:NSMakeRange(0, 0)];
-}
-
- (void)doCommandBySelector:(SEL)myselector
{
/* No need to do anything since we are not using Cocoa
@@ -498,11 +490,8 @@ Cocoa_InitKeyboard(_THIS)
SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");
- /* On pre-10.6, you might have the initial capslock key state wrong. */
- if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
- data->modifierFlags = [NSEvent modifierFlags];
- SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSAlphaShiftKeyMask) != 0);
- }
+ data->modifierFlags = [NSEvent modifierFlags];
+ SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSAlphaShiftKeyMask) != 0);
}
void
diff --git a/src/video/cocoa/SDL_cocoamodes.h b/src/video/cocoa/SDL_cocoamodes.h
index 13a9620..ce8601c 100644
--- a/src/video/cocoa/SDL_cocoamodes.h
+++ b/src/video/cocoa/SDL_cocoamodes.h
@@ -30,7 +30,7 @@ typedef struct
typedef struct
{
- const void *moderef;
+ CGDisplayModeRef moderef;
} SDL_DisplayModeData;
extern void Cocoa_InitModes(_THIS);
diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m
index 2fa619d..6d29c6b 100644
--- a/src/video/cocoa/SDL_cocoamodes.m
+++ b/src/video/cocoa/SDL_cocoamodes.m
@@ -56,25 +56,6 @@ Cocoa_ToggleMenuBar(const BOOL show)
#endif
}
-
-/* !!! FIXME: clean out the pre-10.6 code when it makes sense to do so. */
-#define FORCE_OLD_API 0
-
-#if FORCE_OLD_API
-#undef MAC_OS_X_VERSION_MIN_REQUIRED
-#define MAC_OS_X_VERSION_MIN_REQUIRED 1050
-#endif
-
-static BOOL
-IS_SNOW_LEOPARD_OR_LATER()
-{
-#if FORCE_OLD_API
- return NO;
-#else
- return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5;
-#endif
-}
-
static int
CG_SetError(const char *prefix, CGDisplayErr result)
{
@@ -119,59 +100,40 @@ CG_SetError(const char *prefix, CGDisplayErr result)
}
static SDL_bool
-GetDisplayMode(_THIS, const void *moderef, CVDisplayLinkRef link, SDL_DisplayMode *mode)
+GetDisplayMode(_THIS, CGDisplayModeRef vidmode, CVDisplayLinkRef link, SDL_DisplayMode *mode)
{
SDL_DisplayModeData *data;
long width = 0;
long height = 0;
long bpp = 0;
long refreshRate = 0;
+ CFStringRef fmt;
data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data));
if (!data) {
return SDL_FALSE;
}
- data->moderef = moderef;
-
- if (IS_SNOW_LEOPARD_OR_LATER()) {
- CGDisplayModeRef vidmode = (CGDisplayModeRef) moderef;
- CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode);
- width = (long) CGDisplayModeGetWidth(vidmode);
- height = (long) CGDisplayModeGetHeight(vidmode);
- refreshRate = (long) (CGDisplayModeGetRefreshRate(vidmode) + 0.5);
-
- if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels),
- kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
- bpp = 32;
- } else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels),
- kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
- bpp = 16;
- } else if (CFStringCompare(fmt, CFSTR(kIO30BitDirectPixels),
- kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
- bpp = 30;
- } else {
- bpp = 0; /* ignore 8-bit and such for now. */
- }
-
- CFRelease(fmt);
+ data->moderef = vidmode;
+
+ fmt = CGDisplayModeCopyPixelEncoding(vidmode);
+ width = (long) CGDisplayModeGetWidth(vidmode);
+ height = (long) CGDisplayModeGetHeight(vidmode);
+ refreshRate = (long) (CGDisplayModeGetRefreshRate(vidmode) + 0.5);
+
+ if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels),
+ kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ bpp = 32;
+ } else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels),
+ kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ bpp = 16;
+ } else if (CFStringCompare(fmt, CFSTR(kIO30BitDirectPixels),
+ kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ bpp = 30;
+ } else {
+ bpp = 0; /* ignore 8-bit and such for now. */
}
- #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- if (!IS_SNOW_LEOPARD_OR_LATER()) {
- CFNumberRef number;
- double refresh;
- CFDictionaryRef vidmode = (CFDictionaryRef) moderef;
- number = CFDictionaryGetValue(vidmode, kCGDisplayWidth);
- CFNumberGetValue(number, kCFNumberLongType, &width);
- number = CFDictionaryGetValue(vidmode, kCGDisplayHeight);
- CFNumberGetValue(number, kCFNumberLongType, &height);
- number = CFDictionaryGetValue(vidmode, kCGDisplayBitsPerPixel);
- CFNumberGetValue(number, kCFNumberLongType, &bpp);
- number = CFDictionaryGetValue(vidmode, kCGDisplayRefreshRate);
- CFNumberGetValue(number, kCFNumberDoubleType, &refresh);
- refreshRate = (long) (refresh + 0.5);
- }
- #endif
+ CFRelease(fmt);
/* CGDisplayModeGetRefreshRate returns 0 for many non-CRT displays. */
if (refreshRate == 0 && link != NULL) {
@@ -204,22 +166,6 @@ GetDisplayMode(_THIS, const void *moderef, CVDisplayLinkRef link, SDL_DisplayMod
return SDL_TRUE;
}
-static void
-Cocoa_ReleaseDisplayMode(_THIS, const void *moderef)
-{
- if (IS_SNOW_LEOPARD_OR_LATER()) {
- CGDisplayModeRelease((CGDisplayModeRef) moderef); /* NULL is ok */
- }
-}
-
-static void
-Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist)
-{
- if (IS_SNOW_LEOPARD_OR_LATER()) {
- CFRelease(modelist); /* NULL is ok */
- }
-}
-
static const char *
Cocoa_GetDisplayName(CGDirectDisplayID displayID)
{
@@ -262,7 +208,7 @@ Cocoa_InitModes(_THIS)
SDL_VideoDisplay display;
SDL_DisplayData *displaydata;
SDL_DisplayMode mode;
- const void *moderef = NULL;
+ CGDisplayModeRef moderef = NULL;
CVDisplayLinkRef link = NULL;
if (pass == 0) {
@@ -279,15 +225,7 @@ Cocoa_InitModes(_THIS)
continue;
}
- if (IS_SNOW_LEOPARD_OR_LATER()) {
- moderef = CGDisplayCopyDisplayMode(displays[i]);
- }
-
- #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- if (!IS_SNOW_LEOPARD_OR_LATER()) {
- moderef = CGDisplayCurrentMode(displays[i]);
- }
- #endif
+ moderef = CGDisplayCopyDisplayMode(displays[i]);
if (!moderef) {
continue;
@@ -295,7 +233,7 @@ Cocoa_InitModes(_THIS)
displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
if (!displaydata) {
- Cocoa_ReleaseDisplayMode(_this, moderef);
+ CGDisplayModeRelease(moderef);
continue;
}
displaydata->display = displays[i];
@@ -307,7 +245,7 @@ Cocoa_InitModes(_THIS)
display.name = (char *)Cocoa_GetDisplayName(displays[i]);
if (!GetDisplayMode(_this, moderef, link, &mode)) {
CVDisplayLinkRelease(link);
- Cocoa_ReleaseDisplayMode(_this, moderef);
+ CGDisplayModeRelease(moderef);
SDL_free(display.name);
SDL_free(displaydata);
continue;
@@ -396,17 +334,7 @@ void
Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
- CFArrayRef modes = NULL;
-
- if (IS_SNOW_LEOPARD_OR_LATER()) {
- modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
- }
-
- #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- if (!IS_SNOW_LEOPARD_OR_LATER()) {
- modes = CGDisplayAvailableModes(data->display);
- }
- #endif
+ CFArrayRef modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
if (modes) {
CVDisplayLinkRef link = NULL;
@@ -416,37 +344,19 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
CVDisplayLinkCreateWithCGDisplay(data->display, &link);
for (i = 0; i < count; i++) {
- const void *moderef = CFArrayGetValueAtIndex(modes, i);
+ CGDisplayModeRef moderef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
SDL_DisplayMode mode;
if (GetDisplayMode(_this, moderef, link, &mode)) {
- if (IS_SNOW_LEOPARD_OR_LATER()) {
- CGDisplayModeRetain((CGDisplayModeRef) moderef);
- }
+ CGDisplayModeRetain(moderef);
SDL_AddDisplayMode(display, &mode);
}
}
CVDisplayLinkRelease(link);
- Cocoa_ReleaseDisplayModeList(_this, modes);
+ CFRelease(modes);
}
}
-static CGError
-Cocoa_SwitchMode(_THIS, CGDirectDisplayID display, const void *mode)
-{
- if (IS_SNOW_LEOPARD_OR_LATER()) {
- return CGDisplaySetDisplayMode(display, (CGDisplayModeRef) mode, NULL);
- }
-
- #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- if (!IS_SNOW_LEOPARD_OR_LATER()) {
- return CGDisplaySwitchToMode(display, (CFDictionaryRef) mode);
- }
- #endif
-
- return kCGErrorFailure;
-}
-
int
Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
@@ -462,7 +372,7 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
if (data == display->desktop_mode.driverdata) {
/* Restoring desktop mode */
- Cocoa_SwitchMode(_this, displaydata->display, data->moderef);
+ CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
if (CGDisplayIsMain(displaydata->display)) {
CGReleaseAllDisplays();
@@ -487,7 +397,7 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
}
/* Do the physical switch */
- result = Cocoa_SwitchMode(_this, displaydata->display, data->moderef);
+ result = CGDisplaySetDisplayMode(displaydata->display, data->moderef, NULL);
if (result != kCGErrorSuccess) {
CG_SetError("CGDisplaySwitchToMode()", result);
goto ERR_NO_SWITCH;
@@ -532,11 +442,11 @@ Cocoa_QuitModes(_THIS)
}
mode = (SDL_DisplayModeData *) display->desktop_mode.driverdata;
- Cocoa_ReleaseDisplayMode(_this, mode->moderef);
+ CGDisplayModeRelease(mode->moderef);
for (j = 0; j < display->num_display_modes; j++) {
mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata;
- Cocoa_ReleaseDisplayMode(_this, mode->moderef);
+ CGDisplayModeRelease(mode->moderef);
}
}
diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m
index cd5d97b..fc8a277 100644
--- a/src/video/cocoa/SDL_cocoashape.m
+++ b/src/video/cocoa/SDL_cocoashape.m
@@ -35,9 +35,7 @@ Cocoa_CreateShaper(SDL_Window* window)
SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
[windata->nswindow setOpaque:NO];
- if ([windata->nswindow respondsToSelector:@selector(setStyleMask:)]) {
- [windata->nswindow setStyleMask:NSBorderlessWindowMask];
- }
+ [windata->nswindow setStyleMask:NSBorderlessWindowMask];
SDL_WindowShaper* result = result = malloc(sizeof(SDL_WindowShaper));
result->window = window;
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 4435d8d..e98eebc 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -138,10 +138,7 @@
NSURL *fileURL = [[NSURL fileURLWithPath:path] autorelease];
NSNumber *isAlias = nil;
- /* Functionality for resolving URL aliases was added with OS X 10.6. */
- if ([fileURL respondsToSelector:@selector(getResourceValue:forKey:error:)]) {
- [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
- }
+ [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil];
/* If the URL is an alias, resolve it. */
if ([isAlias boolValue]) {
@@ -218,10 +215,10 @@ GetHintCtrlClickEmulateRightClick()
return hint != NULL && *hint != '0';
}
-static unsigned int
+static NSUInteger
GetWindowStyle(SDL_Window * window)
{
- unsigned int style;
+ NSUInteger style = 0;
if (window->flags & SDL_WINDOW_FULLSCREEN) {
style = NSBorderlessWindowMask;
@@ -239,21 +236,17 @@ GetWindowStyle(SDL_Window * window)
}
static SDL_bool
-SetWindowStyle(SDL_Window * window, unsigned int style)
+SetWindowStyle(SDL_Window * window, NSUInteger style)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
NSWindow *nswindow = data->nswindow;
- if (![nswindow respondsToSelector: @selector(setStyleMask:)]) {
- return SDL_FALSE;
- }
-
/* The view responder chain gets messed with during setStyleMask */
if ([[nswindow contentView] nextResponder] == data->listener) {
[[nswindow contentView] setNextResponder:nil];
}
- [nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)style];
+ [nswindow setStyleMask:style];
/* The view responder chain gets messed with during setStyleMask */
if ([[nswindow contentView] nextResponder] != data->listener) {
@@ -317,9 +310,7 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
[view setNextResponder:self];
- if ([view respondsToSelector:@selector(setAcceptsTouchEvents:)]) {
- [view setAcceptsTouchEvents:YES];
- }
+ [view setAcceptsTouchEvents:YES];
}
- (void)observeValueForKeyPath:(NSString *)keyPath
@@ -604,12 +595,9 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
[NSMenu setMenuBarVisible:NO];
}
- /* On pre-10.6, you might have the capslock key state wrong now because we can't check here. */
- if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_6) {
- const unsigned int newflags = [NSEvent modifierFlags] & NSAlphaShiftKeyMask;
- _data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSAlphaShiftKeyMask) | newflags;
- SDL_ToggleModState(KMOD_CAPS, newflags != 0);
- }
+ const unsigned int newflags = [NSEvent modifierFlags] & NSAlphaShiftKeyMask;
+ _data->videodata->modifierFlags = (_data->videodata->modifierFlags & ~NSAlphaShiftKeyMask) | newflags;
+ SDL_ToggleModState(KMOD_CAPS, newflags != 0);
}
- (void)windowDidResignKey:(NSNotification *)aNotification
@@ -1483,27 +1471,6 @@ Cocoa_RestoreWindow(_THIS, SDL_Window * window)
}
}}
-static NSWindow *
-Cocoa_RebuildWindow(SDL_WindowData * data, NSWindow * nswindow, unsigned style)
-{
- if (!data->created) {
- /* Don't mess with other people's windows... */
- return nswindow;
- }
-
- [data->listener close];
- data->nswindow = [[SDLWindow alloc] initWithContentRect:[[nswindow contentView] frame] styleMask:style backing:NSBackingStoreBuffered defer:NO screen:[nswindow screen]];
- [data->nswindow setContentView:[nswindow contentView]];
- [data->nswindow registerForDraggedTypes:[NSArray arrayWithObject:(NSString *)kUTTypeFileURL]];
- /* See comment in SetupWindowData. */
- [data->nswindow setOneShot:NO];
- [data->listener listen:data];
-
- [nswindow close];
-
- return data->nswindow;
-}
-
void
Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
{ @autoreleasepool
@@ -1545,11 +1512,7 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
rect.origin.y += (screenRect.size.height - rect.size.height);
}
- if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
- [nswindow performSelector: @selector(setStyleMask:) withObject: (id)NSBorderlessWindowMask];
- } else {
- nswindow = Cocoa_RebuildWindow(data, nswindow, NSBorderlessWindowMask);
- }
+ [nswindow setStyleMask:NSBorderlessWindowMask];
} else {
rect.origin.x = window->windowed.x;
rect.origin.y = window->windowed.y;
@@ -1557,16 +1520,12 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
rect.size.height = window->windowed.h;
ConvertNSRect([nswindow screen], fullscreen, &rect);
- if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
- [nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];
+ [nswindow setStyleMask:GetWindowStyle(window)];
- /* Hack to restore window decorations on Mac OS X 10.10 */
- NSRect frameRect = [nswindow frame];
- [nswindow setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
- [nswindow setFrame:frameRect display:NO];
- } else {
- nswindow = Cocoa_RebuildWindow(data, nswindow, GetWindowStyle(window));
- }
+ /* Hack to restore window decorations on Mac OS X 10.10 */
+ NSRect frameRect = [nswindow frame];
+ [nswindow setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
+ [nswindow setFrame:frameRect display:NO];
}
/* The view responder chain gets messed with during setStyleMask */