Ver código fonte

emscripten: find the right SDL_Window during fullscreen events.

Fixes #14629.
Ryan C. Gordon 2 meses atrás
pai
commit
deb85d1fa8
1 arquivos alterados com 12 adições e 1 exclusões
  1. 12 1
      src/video/emscripten/SDL_emscriptenevents.c

+ 12 - 1
src/video/emscripten/SDL_emscriptenevents.c

@@ -497,10 +497,21 @@ static EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const Emscripten
 static EM_BOOL Emscripten_HandleFullscreenChangeGlobal(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData)
 {
     SDL_VideoDevice *device = userData;
-    SDL_Window *window = Emscripten_GetFocusedWindow(device);
+    SDL_Window *window = NULL;
+    for (window = device->windows; window != NULL; window = window->next) {
+        const char *canvas_id = window->internal->canvas_id;
+        if (*canvas_id == '#') {
+            canvas_id++;
+        }
+        if (SDL_strcmp(fullscreenChangeEvent->id, canvas_id) == 0) {
+            break;  // this is the window.
+        }
+    }
+
     if (window) {
         return Emscripten_HandleFullscreenChange(eventType, fullscreenChangeEvent, window->internal);
     }
+
     return EM_FALSE;
 }