Sorry for the delay in answering, was out of office for a couple of weeks. I do agree the API is a bit clumsy to operate from fully in JS side. I wanted it to replace the old fullscreen functionality altogether, but our dead code elimination machinery came in the way a bit for the C<->JS bridge, and there wasn't a really good mechanism to signal what code to pull in. The C++y way here would be to not register the onclick handler on JS side at all, but use the emscripten_set_click_callback function on the button element as a target.
The new api has the drawback though that you can't move to fullscreen at immediate startup until the JS code has loaded in, so you might want to start the button as grayed out or similar. Your manual workaround seems ok, although I'm not sure if we can guarantee it to not break in the future. You do have well enough knowledge though to not need to treat the runtime as a black box, so I don't think you'll run into anything you can't keep track of. The PR is here https://github.com/kripken/emscripten/pull/3298, but it's been on a bit of a thinking pause to figure out how to best structure so that our DCE can be effective. 2016-03-31 23:38 GMT+03:00 Floh <[email protected]>: > PS: here's the latest sample page with these fullscreen fixes: > http://floooh.github.io/oryol/ > > Clicking on the samples, there are now 2 options: 'fullscreen' and > 'expand', the latter is the soft-fullscreen mode which expands the canvas > to the full browser window size. > > Unfortunately 'real' fullscreen mode still doesn't work on iOS Safari (I > haven't debugged this yet), OSX Safari works fine though (this didn't work > before). > > Cheers, > -Floh. > > > Am Donnerstag, 31. März 2016 21:08:52 UTC+2 schrieb Floh: >> >> Hi, >> >> I'm currently cleaning up my fullscreen switching code so that it also >> works on Safari. There seems to be the 'simple' or 'old' way which is used >> by the fullscreen-button on the standard HTML shell file which calls the >> Module.requestFullscreen() function. This doesn't work on Safari though and >> also doesn't provide a lot of control. >> >> Then there's juj's really cool set of fullscreen functions in the html5.h >> header which allows full control over fullscreen switching behaviour and >> also works on Safari. But instead from inside a registered C >> event-handler-function (like mouse or keyboard input) I want to call this >> when clicking an HTML element outside of the application, similar to what >> the fullscreen button on the shell.html file does. >> >> What I'm currently doing is this: call a plain C function via cwrap() >> from within the onclick-handler of an HTML element, which in turn calls >> emscripten_request_fullscreen_strategy(). This doesn't work though since >> inside emscripten_request_fullscreen_strategy() there's a check whether the >> function is executed inside an event handler. 'Technically' it is, since it >> is called from an onclick, however there's a >> canPerformEventHandlerRequests() function which checks some internally set >> variables (JSEvents.inEventHandler and >> JSEvents.currentEventHandler.allowsDeferredCalls), and since these are not >> set when something is simply called from within a button, nothing happens. >> >> I realize that I'm probably moving outside of the intended usage, and I >> do have a workaround setting those inEventHandler variables before calling >> my C function, but I wonder if there's an easier/cleaner way to do this >> (call one of the html5.h function from inside a HTML element event handler)? >> >> Thanks! >> -Floh. >> >> >> -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
