Add OSX implementation for cocoagl_gfx_ctx_get_native_scale

This commit is contained in:
twinaphex 2015-11-01 12:15:21 +01:00
parent 7091e23254
commit a408a5e59a
2 changed files with 13 additions and 9 deletions

View File

@ -299,7 +299,7 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
(void)data;
// TODO: Maybe iOS users should be able to show/hide the status bar here?
/* TODO: Maybe iOS users should be able to show/hide the status bar here? */
return true;
}
@ -326,12 +326,19 @@ float cocoagl_gfx_ctx_get_native_scale(void)
if (!screen)
return 0.0f;
#if TARGET_OS_IPHONE
if ([screen respondsToSelector:selector])
return cocoagl_gfx_ctx_get_scale_from_selector(screen, selector, &ret);
#endif
ret = 1.0f;
#if TARGET_OS_IPHONE
if ([screen respondsToSelector:@selector(scale)])
ret = screen.scale;
#elif MAC_OS_X_VERSION_10_7
if (screen.backingScaleFactor > 1.0f)
ret = screen.backingScaleFactor;
#endif
return ret;
}
@ -397,7 +404,7 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty
#if MAC_OS_X_VERSION_10_7
float scale = screen.backingScaleFactor;
#else
float scale = 1.0f;
float scale = 1.0f;
#endif
float dpi = (display_width/ physical_width) * 25.4f * scale;
#elif defined(HAVE_COCOATOUCH)

View File

@ -31,6 +31,8 @@
static id apple_platform;
extern float cocoagl_gfx_ctx_get_native_scale(void);
void apple_rarch_exited(void)
{
[[NSApplication sharedApplication] terminate:nil];
@ -109,17 +111,12 @@ void apple_rarch_exited(void)
case NSOtherMouseDragged:
{
NSPoint pos;
NSPoint mouse_pos;
NSPoint mouse_pos;
CGFloat backing_scale_factor = cocoagl_gfx_ctx_get_native_scale();
/* Relative */
apple->mouse_rel_x = event.deltaX;
apple->mouse_rel_y = event.deltaY;
#if MAC_OS_X_VERSION_10_7
RAScreen *screen = [RAScreen mainScreen];
CGFloat backing_scale_factor = screen.backingScaleFactor;
#else
CGFloat backing_scale_factor = 1.0f;
#endif
/* Absolute */
pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil];