Skip to content

Commit

Permalink
Emscripten: reset fullscreen_window when leaving fullscreen
Browse files Browse the repository at this point in the history
If the browser left fullscreen mode by the user pressing ESC, the next
call to SDL_SetWindowFullscreen(1) will fail as it thinks the window is
already fullscreen. (#65)
  • Loading branch information
Daft-Freak committed Jan 29, 2019
1 parent 82b2c84 commit 80d690a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/video/emscripten/SDL_emscriptenevents.c
Expand Up @@ -551,6 +551,8 @@ static EM_BOOL
Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData)
{
SDL_WindowData *window_data = userData;
SDL_VideoDisplay *display;

if(fullscreenChangeEvent->isFullscreen)
{
window_data->window->flags |= window_data->requested_fullscreen_mode;
Expand All @@ -563,6 +565,13 @@ Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChang
else
{
window_data->window->flags &= ~FULLSCREEN_MASK;

/* reset fullscreen window if the browser left fullscreen */
display = SDL_GetDisplayForWindow(window_data->window);

if (display->fullscreen_window == window_data->window) {
display->fullscreen_window = NULL;
}
}

return 0;
Expand Down

0 comments on commit 80d690a

Please sign in to comment.