Skip to content

Commit 461bfe4

Browse files
committed
cocoa_gl_ctx: cast contentView to NSView* for -bounds on 32-bit
Fullscreen enter on the non-Metal path failed to compile on 32-bit Darwin (10.5 PPC, 10.6 i386): cocoa_gl_ctx.m:535: error: incompatible type for argument 1 of 'setFrame:' -[NSWindow contentView] returns id on the 10.5-10.9 SDKs (only tightened to NSView* in 10.10). When the receiver type is id, GCC resolves selectors against every matching @interface it's seen. -bounds is declared on two unrelated classes in our translation unit: -[NSView bounds] returns NSRect -[CALayer bounds] returns CGRect On 64-bit macOS NSRect is a typedef for CGRect and the distinction is invisible, but on 32-bit Darwin they're separate incompatible structs (different CGFloat / NSPoint / NSSize underneath). GCC resolves -bounds to CALayer's CGRect-returning method, and then -setFrame:'s NSRect parameter won't accept the CGRect rvalue. Cast the receiver to NSView* so -bounds resolves to NSView's NSRect version. Same fix class as 8e428f4 (ui_cocoa.m:629,726) and 47a7fd4. Not needed at the -addSubview: call sites (534, 554) because -addSubview: is unique to NSView - no resolution ambiguity there.
1 parent a1ddfb1 commit 461bfe4

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

gfx/drivers_context/cocoa_gl_ctx.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,14 @@ static bool cocoa_gl_gfx_ctx_set_video_mode(void *data,
532532
[g_view retain];
533533
[g_view removeFromSuperviewWithoutNeedingDisplay];
534534
[[fullscreen_window contentView] addSubview:g_view];
535-
[g_view setFrame:[[fullscreen_window contentView] bounds]];
535+
/* -[NSWindow contentView] returns id on the 10.5-10.9 SDKs,
536+
* which means GCC can resolve -bounds either to -[NSView
537+
* bounds] (NSRect) or -[CALayer bounds] (CGRect). On 32-bit
538+
* Darwin those are distinct incompatible structs, so the
539+
* implicit CGRect -> NSRect (setFrame:'s parameter) coercion
540+
* fails to compile. Cast the receiver to NSView* so the
541+
* right -bounds wins. Same fix class as 8e428f4e67. */
542+
[g_view setFrame:[(NSView*)[fullscreen_window contentView] bounds]];
536543
[g_view release];
537544

538545
/* Order the windowed window out, bring the fullscreen window

0 commit comments

Comments
 (0)