From 860ffb2b6aa1327e7ff2b1ba336c8b2fa49d9076 Mon Sep 17 00:00:00 2001 From: Eric Warmenhoven Date: Wed, 4 Jan 2023 16:12:03 -0800 Subject: [PATCH] Fix for fullscreen GL driver in Metal OSX build After calling enterFullScreenMode on the GL view, it becomes the "key" window, meaning it gets all of the input. This is problematic as that view doesn't forward the input on to the input driver. --- gfx/drivers_context/cocoa_gl_ctx.m | 3 +++ ui/drivers/cocoa/apple_platform.h | 1 + ui/drivers/ui_cocoa.m | 9 +++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index b0a36beb75..046a878e7e 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -420,6 +420,9 @@ static bool cocoa_gl_gfx_ctx_set_video_mode(void *data, if (!has_went_fullscreen) { [g_view enterFullScreenMode:(BRIDGE NSScreen *)cocoa_screen_get_chosen() withOptions:nil]; +#ifdef HAVE_COCOA_METAL + [apple_platform setupMainWindow]; +#endif cocoa_show_mouse(data, false); } } diff --git a/ui/drivers/cocoa/apple_platform.h b/ui/drivers/cocoa/apple_platform.h index c7f78faaf6..728209738f 100644 --- a/ui/drivers/cocoa/apple_platform.h +++ b/ui/drivers/cocoa/apple_platform.h @@ -28,6 +28,7 @@ * the displays should not sleep. */ - (bool)setDisableDisplaySleep:(bool)disable; +- (void)setupMainWindow; @end #endif diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index ea6d292816..01269fee1f 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -565,8 +565,7 @@ static ui_application_t ui_application_cocoa = { waiting_argc = 0; #ifdef HAVE_COCOA_METAL - [self.window makeMainWindow]; - [self.window makeKeyWindow]; + [self setupMainWindow]; #endif [self performSelectorOnMainThread:@selector(rarch_main) withObject:nil waitUntilDone:NO]; @@ -575,6 +574,12 @@ static ui_application_t ui_application_cocoa = { #pragma mark - ApplePlatform #ifdef HAVE_COCOA_METAL +- (void)setupMainWindow +{ + [self.window makeMainWindow]; + [self.window makeKeyWindow]; +} + - (void)setViewType:(apple_view_type_t)vt { if (vt == _vt)