aboutsummaryrefslogtreecommitdiff
path: root/src/library_sdl.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-08-30 11:21:48 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-08-30 11:21:48 -0700
commitb5b49215d4a40566380a769f47a9c1cce74a28b0 (patch)
tree68308b6059798a81f24f6a8a1ac28a0091c5d066 /src/library_sdl.js
parent1cc28b8e9e94267041bc71afebfbbe3059db4a3f (diff)
parentb895cdc7df2085d324003c9df582a3dcc1927697 (diff)
Merge branch 'incoming'
Diffstat (limited to 'src/library_sdl.js')
-rw-r--r--src/library_sdl.js26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 1fb75724..d6cb6d18 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -46,6 +46,9 @@ var LibrarySDL = {
keyboardState: null,
keyboardMap: {},
+ canRequestFullscreen: false,
+ isRequestingFullscreen: false,
+
textInput: false,
startTime: null,
@@ -467,6 +470,23 @@ var LibrarySDL = {
SDL.DOMButtons[event.button] = 0;
}
+ // We can only request fullscreen as the result of user input.
+ // Due to this limitation, we toggle a boolean on keydown which
+ // SDL_WM_ToggleFullScreen will check and subsequently set another
+ // flag indicating for us to request fullscreen on the following
+ // keyup. This isn't perfect, but it enables SDL_WM_ToggleFullScreen
+ // to work as the result of a keypress (which is an extremely
+ // common use case).
+ if (event.type === 'keydown') {
+ SDL.canRequestFullscreen = true;
+ } else if (event.type === 'keyup') {
+ if (SDL.isRequestingFullscreen) {
+ Module['requestFullScreen'](true, true);
+ SDL.isRequestingFullscreen = false;
+ }
+ SDL.canRequestFullscreen = false;
+ }
+
// SDL expects a unicode character to be passed to its keydown events.
// Unfortunately, the browser APIs only provide a charCode property on
// keypress events, so we must backfill in keydown events with their
@@ -1282,7 +1302,11 @@ var LibrarySDL = {
Module['canvas'].cancelFullScreen();
return 1;
} else {
- return 0;
+ if (!SDL.canRequestFullscreen) {
+ return 0;
+ }
+ SDL.isRequestingFullscreen = true;
+ return 1;
}
},