Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sokol_app.h: support sapp_toggle_fullscreen with HTML5 #887

Open
edubart opened this issue Sep 15, 2023 · 2 comments
Open

sokol_app.h: support sapp_toggle_fullscreen with HTML5 #887

edubart opened this issue Sep 15, 2023 · 2 comments

Comments

@edubart
Copy link
Contributor

edubart commented Sep 15, 2023

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
Copy link
Owner

floooh commented Sep 17, 2023

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:

sokol/sokol_app.h

Lines 5082 to 5101 in d4ac122

/* The above method might report zero when toggling HTML5 fullscreen,
in that case use the window's inner width reported by the
emscripten event. This works ok when toggling *into* fullscreen
but doesn't properly restore the previous canvas size when switching
back from fullscreen.
In general, due to the HTML5's fullscreen API's flaky nature it is
recommended to use 'soft fullscreen' (stretching the WebGL canvas
over the browser windows client rect) with a CSS definition like this:
position: absolute;
top: 0px;
left: 0px;
margin: 0px;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
display: block;
*/

@edubart
Copy link
Contributor Author

edubart commented Sep 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants