From 1b2632e7fa310b2d26948da9574ba770dbc714aa Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 15 Jan 2016 12:53:33 +0100 Subject: [PATCH] Refactor function get_float_from_selector - obsolete hardcoded ifdef --- gfx/drivers_context/cocoa_gl_ctx.m | 8 +++++--- ui/drivers/ui_cocoa.m | 11 ++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 58831b135f..d796e848e0 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -310,7 +310,7 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data, return true; } -static float cocoagl_gfx_ctx_get_scale_from_selector(RAScreen *screen, SEL selector, float *ret) +void get_float_from_selector(RAScreen *screen, SEL selector, float *ret) { NSInvocation *invocation = [NSInvocation invocationWithMethodSignature: [[screen class] instanceMethodSignatureForSelector:selector]]; @@ -318,7 +318,6 @@ static float cocoagl_gfx_ctx_get_scale_from_selector(RAScreen *screen, SEL selec [invocation setTarget:screen]; [invocation invoke]; [invocation getReturnValue:ret]; - return *ret; } float cocoagl_gfx_ctx_get_native_scale(void) @@ -337,7 +336,10 @@ float cocoagl_gfx_ctx_get_native_scale(void) return 0.0f; if ([screen respondsToSelector:selector]) - return cocoagl_gfx_ctx_get_scale_from_selector(screen, selector, &ret); + { + get_float_from_selector(screen, selector, &ret); + return ret; + } ret = 1.0f; if ([screen respondsToSelector:@selector(scale)]) diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 560330b77a..4326a1bece 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -33,7 +33,8 @@ static id apple_platform; -void *get_chosen_screen(void); +extern void *get_chosen_screen(void); +extern void get_float_from_selector(RAScreen *screen, SEL selector, float *ret); void apple_rarch_exited(void) { @@ -107,13 +108,14 @@ void apple_rarch_exited(void) { NSPoint pos; NSPoint mouse_pos; - CGFloat backing_scale_factor = 1.0f; + float backing_scale_factor = 1.0f; #if __has_feature(objc_arc) RAScreen *screen = (__bridge RAScreen*)get_chosen_screen(); #else RAScreen *screen = (RAScreen*)get_chosen_screen(); #endif + SEL selector = NSSelectorFromString(BOXSTRING("backingScaleFactor")); apple = (cocoa_input_data_t*)input_driver_get_data(); if (!apple) @@ -125,9 +127,8 @@ void apple_rarch_exited(void) apple->mouse_rel_x = event.deltaX; apple->mouse_rel_y = event.deltaY; -#if MAC_OS_X_VERSION_10_7 - backing_scale_factor = screen.backingScaleFactor; -#endif + if ([screen respondsToSelector:selector]) + get_float_from_selector(screen, selector, &backing_scale_factor); /* Absolute */ pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil];