And properly account for -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR.
Module['canvas'] can be read even from code compiled with -s MODULARIZE
so it's a preferrable option to hardcoding it in Configuration. The
target strings in Emscripten depend on whether we're compiled with
DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR (see
https://github.com/emscripten-core/emscripten/pull/7977). This is now
detected and handled at runtime to prepend element IDs with and use
the correct window and document magic targets.
Not yet sure about all interactions with older Emscripten versions and
DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR set to 0, reverting until
it's clear.
This reverts commit c760acb548.
Instead of first entering the main loop, processing events etc. This
also makes it finally possible to exit the application cleanly, with all
non-global destructors executed as well.
The canvasX/Y properties were silently deprecated (I wouldn't know
without looking at the source, the docs say no such thing) and when
-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 is enabled, these are
not initialized to any meaningful value.
On Emscripten as well, however I'm keeping the Configuration::setTitle()
a no-op because the title is usually set by the HTML markup already and
so dynamic code implicitly changing it to something else doesn't make
much sense.
The code was taken straight from Sdl2Application where it assumed the
main render loop polls for canvas size changes and so it would pick it
up automagically. Not the case here, so the viewport event was never
fired after this.
By mistake I thought it's the same as in Emscripten's SDL, but there
Emscripten does some emulation to ensure windowSize() ==
framebufferSize().
For the resize event it's possible to hook into the window resize
callback instead of polling for the size every frame, That's much more
efficient.