src/video/emscripten/SDL_emscriptenvideo.c
changeset 12571 aa455cfe9ff3
parent 12503 806492103856
child 12574 109c919d61f6
     1.1 --- a/src/video/emscripten/SDL_emscriptenvideo.c	Tue Jan 29 12:14:33 2019 +0000
     1.2 +++ b/src/video/emscripten/SDL_emscriptenvideo.c	Tue Jan 29 12:14:41 2019 +0000
     1.3 @@ -206,21 +206,22 @@
     1.4      scaled_w = SDL_floor(window->w * wdata->pixel_ratio);
     1.5      scaled_h = SDL_floor(window->h * wdata->pixel_ratio);
     1.6  
     1.7 -    emscripten_set_canvas_size(scaled_w, scaled_h);
     1.8 -
     1.9 +    /* set a fake size to check if there is any CSS sizing the canvas */
    1.10 +    emscripten_set_canvas_size(1, 1);
    1.11      emscripten_get_element_css_size(NULL, &css_w, &css_h);
    1.12  
    1.13 -    wdata->external_size = SDL_floor(css_w) != scaled_w || SDL_floor(css_h) != scaled_h;
    1.14 +    wdata->external_size = SDL_floor(css_w) != 1 || SDL_floor(css_h) != 1;
    1.15  
    1.16      if ((window->flags & SDL_WINDOW_RESIZABLE) && wdata->external_size) {
    1.17          /* external css has resized us */
    1.18          scaled_w = css_w * wdata->pixel_ratio;
    1.19          scaled_h = css_h * wdata->pixel_ratio;
    1.20  
    1.21 -        emscripten_set_canvas_size(scaled_w, scaled_h);
    1.22          SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, css_w, css_h);
    1.23      }
    1.24  
    1.25 +    emscripten_set_canvas_size(scaled_w, scaled_h);
    1.26 +
    1.27      /* if the size is not being controlled by css, we need to scale down for hidpi */
    1.28      if (!wdata->external_size) {
    1.29          if (wdata->pixel_ratio != 1.0f) {