Skip to content

Commit deb85d1

Browse files
committed
emscripten: find the right SDL_Window during fullscreen events.
Fixes #14629.
1 parent 64df9cf commit deb85d1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/video/emscripten/SDL_emscriptenevents.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,21 @@ static EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const Emscripten
497497
static EM_BOOL Emscripten_HandleFullscreenChangeGlobal(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData)
498498
{
499499
SDL_VideoDevice *device = userData;
500-
SDL_Window *window = Emscripten_GetFocusedWindow(device);
500+
SDL_Window *window = NULL;
501+
for (window = device->windows; window != NULL; window = window->next) {
502+
const char *canvas_id = window->internal->canvas_id;
503+
if (*canvas_id == '#') {
504+
canvas_id++;
505+
}
506+
if (SDL_strcmp(fullscreenChangeEvent->id, canvas_id) == 0) {
507+
break; // this is the window.
508+
}
509+
}
510+
501511
if (window) {
502512
return Emscripten_HandleFullscreenChange(eventType, fullscreenChangeEvent, window->internal);
503513
}
514+
504515
return EM_FALSE;
505516
}
506517

0 commit comments

Comments
 (0)