floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.63k stars 472 forks source link

sokol_app.h: support sapp_toggle_fullscreen with HTML5 #887

Open edubart opened 10 months ago

edubart commented 10 months ago

Currently sapp_toggle_fullscreen is not implemented for HTML5 backend, however emscripten has the functions emscripten_request_fullscreen and emscripten_enter_soft_fullscreen which could be used to implement it.

There is an example if it in https://github.com/emscripten-core/emscripten/blob/main/test/test_html5_fullscreen.c

floooh commented 10 months ago

Yeah I'm aware of those functions (and IIRC actually used them in early sokol_app.h versions), but had a lot of trouble in the past because fullscreen implementation details differ a lot between browsers (and IIRC iOS Safari didn't support fullscreen at all for a long time). One problem I remember was that the fullscreen security popup clashes with mouse-lock security popup which made UX a mess.

There's also left-over comment which hints at some of the problems I ran into:

https://github.com/floooh/sokol/blob/d4ac122f36d7659a18b312fd4fa2317fb9e06a63/sokol_app.h#L5082-L5101

edubart commented 10 months ago

I see, I managed to workaround by adding some JavaScript code in the web frontend, so this problem can be solved in outside the sokol_app.h. Thus consider this low priority.