From b7b5fbe7aa35e5e5d3102ce8c133259916cddfda Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Wed, 27 Sep 2023 09:01:42 +0300 Subject: [PATCH] [macOS] Check all exclusive fullscreen windows before setting presentation mode. --- platform/macos/display_server_macos.h | 1 + platform/macos/display_server_macos.mm | 12 +++++++++++- platform/macos/godot_window_delegate.mm | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/platform/macos/display_server_macos.h b/platform/macos/display_server_macos.h index c03b4765f880..1c91ec899275 100644 --- a/platform/macos/display_server_macos.h +++ b/platform/macos/display_server_macos.h @@ -245,6 +245,7 @@ class DisplayServerMacOS : public DisplayServer { WindowID _get_focused_window_or_popup() const; void mouse_enter_window(WindowID p_window); void mouse_exit_window(WindowID p_window); + void update_presentation_mode(); void window_destroy(WindowID p_window); void window_resize(WindowID p_window, int p_width, int p_height); diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index 56cb4938ec5d..c7dbf952fa6c 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -749,6 +749,7 @@ } #endif windows.erase(p_window); + update_presentation_mode(); } void DisplayServerMacOS::window_resize(WindowID p_window, int p_width, int p_height) { @@ -2868,6 +2869,15 @@ return wd.max_size; } +void DisplayServerMacOS::update_presentation_mode() { + for (const KeyValue &wd : windows) { + if (wd.value.fullscreen && wd.value.exclusive_fullscreen) { + return; + } + } + [NSApp setPresentationOptions:NSApplicationPresentationDefault]; +} + void DisplayServerMacOS::window_set_min_size(const Size2i p_size, WindowID p_window) { _THREAD_SAFE_METHOD_ @@ -2978,7 +2988,7 @@ [wd.window_object toggleFullScreen:nil]; if (old_mode == WINDOW_MODE_EXCLUSIVE_FULLSCREEN) { - [NSApp setPresentationOptions:NSApplicationPresentationDefault]; + update_presentation_mode(); } wd.fullscreen = false; diff --git a/platform/macos/godot_window_delegate.mm b/platform/macos/godot_window_delegate.mm index 46355b4ae8fa..002ab0155f98 100644 --- a/platform/macos/godot_window_delegate.mm +++ b/platform/macos/godot_window_delegate.mm @@ -157,7 +157,7 @@ - (void)windowDidExitFullScreen:(NSNotification *)notification { DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); if (wd.exclusive_fullscreen) { - [NSApp setPresentationOptions:NSApplicationPresentationDefault]; + ds->update_presentation_mode(); } wd.fullscreen = false;