diff --git a/ui/drivers/cocoa/cocoa_common.m b/ui/drivers/cocoa/cocoa_common.m index 18b86bbb1d..194e74b44e 100644 --- a/ui/drivers/cocoa/cocoa_common.m +++ b/ui/drivers/cocoa/cocoa_common.m @@ -33,6 +33,12 @@ static CocoaView* g_instance; +void *nsview_set_ptr(void *inst) +{ + g_instance = (BRIDGE void*)inst; + return (BRIDGE void *)g_instance; +} + void *nsview_get_ptr(void) { #if defined(HAVE_COCOA) @@ -75,20 +81,11 @@ void *glkitview_init(void); + (CocoaView*)get { - if (!g_instance) - g_instance = [CocoaView new]; + void *inst = nsview_get_ptr(); + if (!inst) + return nsview_set_ptr([CocoaView new]); -#if defined(HAVE_COCOA) - video_driver_display_type_set(RARCH_DISPLAY_OSX); - video_driver_display_set(0); - video_driver_display_userdata_set((uintptr_t)g_instance); -#elif defined(HAVE_COCOA_METAL) - video_driver_display_type_set(RARCH_DISPLAY_OSX); - video_driver_display_set(0); - video_driver_display_userdata_set((uintptr_t)g_instance); -#endif - - return g_instance; + return inst; } - (id)init