Canvas resize event is sent only once #66
Comments
window->external_size seems reset to 0 when calling the function anyway. |
Yeah, the window gets destroyed.
It's for HiDPI where we need to set the CSS size of the canvas to the window size and the canvas size to the window size * pixel ratio, but not if the user has already set a size through CSS. I guess we could always set it to 1 if the |
Your idea appears to work without graphical artifact :)
Incidentally SDL_RecreateWindow is also called when using SDL_CreateWindowAndRenderer combo function. |
I think you can avoid the recreating by creating the window with |
The check would fail if the canvas happened to be the correct size already. (emscripten-ports#66, mentioned in emscripten-ports#58)
Hi!
This port detects if the canvas is CSS-resized by assigning it dimensions and checking right after if the effective dimensions are the same. If not, this sets window->external_size forever and resize events are emitted.
This fails:
when the window didn't need to be resized on start-up (e.g. due to reaching a maximum CSS size already)
more importantly, when calling SDL_CreateRenderer, which triggers SDL_RecreateWindow:
When the test is run for the second time, the canvas was already resized once and the initial and CSS-resized dimensions match. window->external_size is then reset to 0 and resize events are not emitted anymore.
We could either try to find a better detection algorithm (fixing both cases), or avoid zero-ing window->external_size if it was already to 1 (fixing the second case).
What do you think?
The text was updated successfully, but these errors were encountered: