Commit 69e9b2acee6272030e1cc9b0f8c51ecb5095863d

Sam Lantinga 2021-02-01T22:35:46

Fixed bug 5471 - Creating a fullscreen desktop window goes windowed temporarily This is caused by the Metal renderer recreating the window because by default we create an OpenGL window on macOS. It turns out that at least on macOS 10.15, a window that has been initialized for OpenGL can also be used with Metal. So we'll skip recreating the window in that case.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m
index 67ac1b6..32c1c48 100644
--- a/src/render/metal/SDL_render_metal.m
+++ b/src/render/metal/SDL_render_metal.m
@@ -1674,7 +1674,7 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags)
     }
 
     window_flags = SDL_GetWindowFlags(window);
-    if (!(window_flags & SDL_WINDOW_METAL)) {
+    if (!(window_flags & (SDL_WINDOW_METAL|SDL_WINDOW_OPENGL))) {
         changed_window = SDL_TRUE;
         if (SDL_RecreateWindow(window, (window_flags & ~(SDL_WINDOW_VULKAN | SDL_WINDOW_OPENGL)) | SDL_WINDOW_METAL) < 0) {
             return NULL;