Emscripten: reset fullscreen_window when leaving fullscreen
authorCharlie Birks <charlie@daftgames.net>
Tue, 29 Jan 2019 12:14:33 +0000
changeset 12570bb39a14d510c
parent 12569 05aff4771d9a
child 12571 aa455cfe9ff3
Emscripten: reset fullscreen_window when leaving fullscreen
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)
src/video/emscripten/SDL_emscriptenevents.c
     1.1 --- a/src/video/emscripten/SDL_emscriptenevents.c	Mon Jan 21 23:41:43 2019 +0100
     1.2 +++ b/src/video/emscripten/SDL_emscriptenevents.c	Tue Jan 29 12:14:33 2019 +0000
     1.3 @@ -551,6 +551,8 @@
     1.4  Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData)
     1.5  {
     1.6      SDL_WindowData *window_data = userData;
     1.7 +    SDL_VideoDisplay *display;
     1.8 +
     1.9      if(fullscreenChangeEvent->isFullscreen)
    1.10      {
    1.11          window_data->window->flags |= window_data->requested_fullscreen_mode;
    1.12 @@ -563,6 +565,13 @@
    1.13      else
    1.14      {
    1.15          window_data->window->flags &= ~FULLSCREEN_MASK;
    1.16 +
    1.17 +        /* reset fullscreen window if the browser left fullscreen */
    1.18 +        display = SDL_GetDisplayForWindow(window_data->window);
    1.19 +
    1.20 +        if (display->fullscreen_window == window_data->window) {
    1.21 +            display->fullscreen_window = NULL;
    1.22 +        }
    1.23      }
    1.24  
    1.25      return 0;