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.
This commit is contained in:
U-DESKTOP-SPFP6AQ\twistedtechre committed 2026-04-21 02:02:35 +02:00
1 parent 8e428f4e67
commit d38dcb543f
1 file changed
+10 -3
+10 -3
View File
@@ -1059,9 +1059,16 @@ static void cocoa_input_grab_mouse(void *data, bool state)
if (state)
{
NSWindow *window = (BRIDGE NSWindow*)ui_companion_cocoa.get_main_window(nil);
CGPoint window_pos = window.frame.origin;
CGSize window_size = window.frame.size;
CGPoint window_center = CGPointMake(window_pos.x + window_size.width / 2.0f, window_pos.y + window_size.height / 2.0f);
/* NSWindow's frame method is declared as a plain getter (not
* @property) on the 10.5-10.9 SDKs, so dot-syntax fails on
* GCC 4.0. And on 32-bit Darwin, NSPoint and CGPoint are
* separate incompatible types — only unified on LP64. Use
* bracket syntax and build a CGPoint from the float fields
* directly. */
NSRect window_frame = [window frame];
CGPoint window_center = CGPointMake(
window_frame.origin.x + window_frame.size.width / 2.0f,
window_frame.origin.y + window_frame.size.height / 2.0f);
CGWarpMouseCursorPosition(window_center);
}