Skip to content

Commit d38dcb5

Browse files
committed
cocoa_input: fix frame dot-syntax and NSPoint/CGPoint mismatch
GCC 4.0 (Xcode 3.1, PowerPC) reports: cocoa_input.m:1062: error: invalid initializer Two problems compound in this four-line sequence on 32-bit 10.5: CGPoint window_pos = window.frame.origin; CGSize window_size = window.frame.size; First, NSWindow's frame is declared - (NSRect)frame; on the 10.5-10.9 SDKs, not as @Property. GCC 4.0 only supports Obj-C 2.0 dot-syntax on explicitly declared @Property, so window.frame fails (same class of issue as the keyWindow / alphaValue fixes in c49a525). Second, window.frame.origin evaluates to NSPoint, but the variable is typed CGPoint. On 32-bit Darwin, NSPoint and CGPoint are separate, incompatible types — Apple only unified them on LP64. Same for NSSize vs CGSize on the next line. Rewrite to fetch the frame once via bracket syntax into an NSRect local, then feed the float field values directly to CGPointMake. CGWarpMouseCursorPosition gets the same CGPoint as before; no runtime change. Modern clang compiles identically.
1 parent 8e428f4 commit d38dcb5

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

input/drivers/cocoa_input.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,9 +1059,16 @@ static void cocoa_input_grab_mouse(void *data, bool state)
10591059
if (state)
10601060
{
10611061
NSWindow *window = (BRIDGE NSWindow*)ui_companion_cocoa.get_main_window(nil);
1062-
CGPoint window_pos = window.frame.origin;
1063-
CGSize window_size = window.frame.size;
1064-
CGPoint window_center = CGPointMake(window_pos.x + window_size.width / 2.0f, window_pos.y + window_size.height / 2.0f);
1062+
/* NSWindow's frame method is declared as a plain getter (not
1063+
* @property) on the 10.5-10.9 SDKs, so dot-syntax fails on
1064+
* GCC 4.0. And on 32-bit Darwin, NSPoint and CGPoint are
1065+
* separate incompatible types — only unified on LP64. Use
1066+
* bracket syntax and build a CGPoint from the float fields
1067+
* directly. */
1068+
NSRect window_frame = [window frame];
1069+
CGPoint window_center = CGPointMake(
1070+
window_frame.origin.x + window_frame.size.width / 2.0f,
1071+
window_frame.origin.y + window_frame.size.height / 2.0f);
10651072
CGWarpMouseCursorPosition(window_center);
10661073
}
10671074

0 commit comments

Comments
 (0)