From 3eba4fbb13799e919dcc25f0c561fdfa2a2a8d86 Mon Sep 17 00:00:00 2001 From: Andre Weissflog Date: Thu, 27 May 2021 20:29:03 +0200 Subject: sokol_app.h macos: applicationShouldHandleReopen This application delegate method is called when the dock icon is clicked and will unminimize the main window in case multiple windows are open. --- sokol_app.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sokol_app.h b/sokol_app.h index ae62ed10..b2ed70f0 100644 --- a/sokol_app.h +++ b/sokol_app.h @@ -4227,6 +4227,18 @@ _SOKOL_PRIVATE CVReturn _sapp_macos_displaylink_callback( _SOKOL_UNUSED(notification); _sapp_discard_state(); } + +- (BOOL)applicationShouldHandleReopen:(NSApplication*)sender hasVisibleWindows:(BOOL)flag { + _SOKOL_UNUSED(sender); + _SOKOL_UNUSED(flag); + /* unminimize the main window when clicking the dock icon (which doesn't + happen automatically if the application has multiple open windows) + */ + _sapp_window_t* win = _sapp_lookup_window(_sapp.main_window_id); + SOKOL_ASSERT(win); + [win->macos.window makeKeyAndOrderFront:nil]; + return YES; +} @end @implementation _sapp_macos_window_delegate -- cgit v1.2.3