mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-09 03:29:43 -10:00
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:
1 parent
8e428f4e67
commit
d38dcb543f
1 file changed
+10
-3
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user