diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-06-19 14:53:01 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-06-19 15:45:39 -0700 |
commit | f8ecbf36df9383f142441bdacb4a166a8b772d90 (patch) | |
tree | 21bc66cf9a55c43eafc4ccdc9ef0894395523e24 | |
parent | d53193e2f5662c3fb9598251b178cfc2fe2bcc7e (diff) |
fire resize listener from sdl consistently each time
-rw-r--r-- | src/library_sdl.js | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js index 68460d73..2116afe2 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -1314,26 +1314,14 @@ var LibrarySDL = { Module['canvas'].addEventListener(event, SDL.receiveEvent, true); }); + var canvas = Module['canvas']; + // (0,0) means 'use fullscreen' in native; in Emscripten, use the current canvas size. if (width == 0 && height == 0) { - var canvas = Module['canvas']; width = canvas.width; height = canvas.height; } - Browser.setCanvasSize(width, height, -#if PROXY_TO_WORKER == 0 - true // XXX why? -#else - false -#endif - ); - // Free the old surface first. - if (SDL.screen) { - SDL.freeSurface(SDL.screen); - assert(!SDL.screen); - } - SDL.screen = SDL.makeSurface(width, height, flags, true, 'screen'); if (!SDL.addedResizeListener) { SDL.addedResizeListener = true; Browser.resizeListeners.push(function(w, h) { @@ -1344,6 +1332,19 @@ var LibrarySDL = { }); }); } + + if (width !== canvas.width || height !== canvas.height) { + Browser.setCanvasSize(width, height); + } + + // Free the old surface first if there is one + if (SDL.screen) { + SDL.freeSurface(SDL.screen); + assert(!SDL.screen); + } + + SDL.screen = SDL.makeSurface(width, height, flags, true, 'screen'); + return SDL.screen; }, |