Skip to content

Commit c49a525

Browse files
committed
dispserv_apple: replace Obj-C 2.0 dot-syntax with bracket calls
Apple GCC 4.0 (the default compiler in Xcode 3.1) only supports Objective-C 2.0 dot-syntax on explicitly declared @Property. On the 10.5-10.8 SDKs, NSWindow's isKeyWindow / alphaValue / styleMask are declared as plain getter methods, not @Property — Apple only added the @Property annotations in 10.10+. GCC 4.0 sees the dot-syntax, notices NSWindow* isn't a struct, and bails: dispserv_apple.m:62: error: request for member 'keyWindow' in something not a structure or union Convert every dot-syntax site in the OSX-only blocks to explicit bracket method calls (e.g. window.keyWindow -> [window isKeyWindow], window.alphaValue = x -> [window setAlphaValue:x]). Bracket syntax works on every Apple compiler back to GCC 3.3, and modern clang compiles it identically to the dot-syntax form. Three functions touched: - set_window_opacity: dot-syntax converted. No version gate needed; the underlying APIs are all 10.0-era. - set_window_progress: dot-syntax converted, AND gated on RARCH_HAS_CGDISPLAYMODE_API (10.6+). This function relies on dispatch_once and Obj-C blocks (^{}), neither of which exist in GCC 4.0 / pre-10.6 toolchains. The driver struct slot becomes NULL on pre-10.6, matching the existing iOS NULL. - set_window_decorations: dot-syntax converted. Also pulled in <defines/cocoa_defines.h> so that NSWindowStyleMaskTitled (10.12+) gets its existing pre-10.12 polyfill (it expands to the older NSTitledWindowMask). Modern clang builds are unaffected — bracket syntax compiles to the same code as dot-syntax there. Pre-10.6 builds lose the dock-tile progress indicator but keep window opacity and decorations.
1 parent 667256a commit c49a525

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

gfx/display_servers/dispserv_apple.m

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "../../ui/drivers/cocoa/apple_platform.h"
2626
#include "../../ui/drivers/cocoa/cocoa_common.h"
2727
#include "../../configuration.h"
28+
/* For NSWindowStyleMaskTitled polyfill on pre-10.12 SDKs */
29+
#include <defines/cocoa_defines.h>
2830

2931
#ifdef OSX
3032
#import <AppKit/AppKit.h>
@@ -58,13 +60,15 @@ static bool apple_display_server_set_window_opacity(void *data, unsigned opacity
5860
{
5961
settings_t *settings = config_get_ptr();
6062
bool windowed_full = settings->bools.video_windowed_fullscreen;
61-
NSWindow *window = ((RetroArch_OSX*)[[NSApplication sharedApplication] delegate]).window;
62-
if (windowed_full || !window.keyWindow)
63+
NSWindow *window = [((RetroArch_OSX*)[[NSApplication sharedApplication] delegate]) window];
64+
if (windowed_full || ![window isKeyWindow])
6365
return false;
64-
window.alphaValue = (CGFloat)opacity / (CGFloat)100.0f;
66+
[window setAlphaValue:(CGFloat)opacity / (CGFloat)100.0f];
6567
return true;
6668
}
6769

70+
#ifdef RARCH_HAS_CGDISPLAYMODE_API
71+
/* Uses GCD (dispatch_once) and Obj-C blocks, both 10.6+. */
6872
static bool apple_display_server_set_window_progress(void *data, int progress, bool finished)
6973
{
7074
static NSProgressIndicator *indicator;
@@ -75,35 +79,36 @@ static bool apple_display_server_set_window_progress(void *data, int progress, b
7579
[iv setImage:[[NSApplication sharedApplication] applicationIconImage]];
7680
[dockTile setContentView:iv];
7781

78-
indicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, dockTile.size.width, 20)];
79-
indicator.indeterminate = NO;
80-
indicator.minValue = 0;
81-
indicator.maxValue = 100;
82-
indicator.doubleValue = 0;
82+
indicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, [dockTile size].width, 20)];
83+
[indicator setIndeterminate:NO];
84+
[indicator setMinValue:0];
85+
[indicator setMaxValue:100];
86+
[indicator setDoubleValue:0];
8387

8488
// Create a custom view for the dock tile
8589
[iv addSubview:indicator];
8690
});
8791
if (finished)
88-
indicator.doubleValue = (double)-1;
92+
[indicator setDoubleValue:(double)-1];
8993
else
90-
indicator.doubleValue = (double)progress;
91-
indicator.hidden = finished;
94+
[indicator setDoubleValue:(double)progress];
95+
[indicator setHidden:finished];
9296
[[NSApp dockTile] display];
9397
return true;
9498
}
99+
#endif /* RARCH_HAS_CGDISPLAYMODE_API */
95100

96101
static bool apple_display_server_set_window_decorations(void *data, bool on)
97102
{
98103
settings_t *settings = config_get_ptr();
99104
bool windowed_full = settings->bools.video_windowed_fullscreen;
100-
NSWindow *window = ((RetroArch_OSX*)[[NSApplication sharedApplication] delegate]).window;
105+
NSWindow *window = [((RetroArch_OSX*)[[NSApplication sharedApplication] delegate]) window];
101106
if (windowed_full)
102107
return false;
103108
if (on)
104-
window.styleMask |= NSWindowStyleMaskTitled;
109+
[window setStyleMask:([window styleMask] | NSWindowStyleMaskTitled)];
105110
else
106-
window.styleMask &= ~NSWindowStyleMaskTitled;
111+
[window setStyleMask:([window styleMask] & ~NSWindowStyleMaskTitled)];
107112
return true;
108113
}
109114
#endif
@@ -578,7 +583,11 @@ static void apple_display_server_destroy(void *data)
578583
apple_display_server_destroy,
579584
#ifdef OSX
580585
apple_display_server_set_window_opacity,
586+
#ifdef RARCH_HAS_CGDISPLAYMODE_API
581587
apple_display_server_set_window_progress,
588+
#else
589+
NULL, /* set_window_progress (needs 10.6+ GCD/blocks) */
590+
#endif
582591
apple_display_server_set_window_decorations,
583592
#else
584593
NULL, /* set_window_opacity */

0 commit comments

Comments
 (0)