diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-02-26 17:09:11 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-02-26 17:09:11 -0800 |
commit | b47f101d59dc7288f1488431f5db02e9b9922e97 (patch) | |
tree | aff47953746f588b7748c9fc8acfeb33520521aa /src | |
parent | 202a13e9bb409cf320dd19f3aff48b77ba934fb2 (diff) | |
parent | 793eb176a0c777d91941cb17386de0f5da981bac (diff) |
Merge pull request #2165 from juj/fs_element_size1.12.3
Fullscreen element sizes
Diffstat (limited to 'src')
-rw-r--r-- | src/library_html5.js | 18 | ||||
-rw-r--r-- | src/struct_info.json | 6 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/library_html5.js b/src/library_html5.js index 63a4dff7..b17a0d4d 100644 --- a/src/library_html5.js +++ b/src/library_html5.js @@ -13,6 +13,10 @@ var LibraryJSEvents = { visibilityChangeEvent: 0, touchEvent: 0, + // When we transition from fullscreen to windowed mode, we remember here the element that was just in fullscreen mode + // so that we can report information about that element in the event message. + previousFullscreenElement: null, + // When the C runtime exits via exit(), we unregister all event handlers added by this library to be nice and clean. // Track in this field whether we have yet registered that __ATEXIT__ handler. removeEventListenersRegistered: false, @@ -484,10 +488,20 @@ var LibraryJSEvents = { var isFullscreen = !!fullscreenElement; {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenFullscreenChangeEvent.isFullscreen, 'isFullscreen', 'i32') }}}; {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenFullscreenChangeEvent.fullscreenEnabled, 'JSEvents.fullscreenEnabled()', 'i32') }}}; - var nodeName = JSEvents.getNodeNameForTarget(fullscreenElement); - var id = (fullscreenElement && fullscreenElement.id) ? fullscreenElement.id : ''; + // If transitioning to fullscreen, report info about the element that is now fullscreen. + // If transitioning to windowed mode, report info about the element that just was fullscreen. + var reportedElement = isFullscreen ? fullscreenElement : JSEvents.previousFullscreenElement; + var nodeName = JSEvents.getNodeNameForTarget(reportedElement); + var id = (reportedElement && reportedElement.id) ? reportedElement.id : ''; writeStringToMemory(nodeName, eventStruct + {{{ C_STRUCTS.EmscriptenFullscreenChangeEvent.nodeName }}} ); writeStringToMemory(id, eventStruct + {{{ C_STRUCTS.EmscriptenFullscreenChangeEvent.id }}} ); + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenFullscreenChangeEvent.elementWidth, 'reportedElement ? reportedElement.clientWidth : 0', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenFullscreenChangeEvent.elementHeight, 'reportedElement ? reportedElement.clientHeight : 0', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenFullscreenChangeEvent.screenWidth, 'screen.width', 'i32') }}}; + {{{ makeSetValue('eventStruct', C_STRUCTS.EmscriptenFullscreenChangeEvent.screenHeight, 'screen.height', 'i32') }}}; + if (isFullscreen) { + JSEvents.previousFullscreenElement = fullscreenElement; + } }, registerFullscreenChangeEventCallback: function(target, userData, useCapture, callbackfunc, eventTypeId, eventTypeString) { diff --git a/src/struct_info.json b/src/struct_info.json index 2aeffc9c..2a2b4c64 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -1207,7 +1207,11 @@ "isFullscreen", "fullscreenEnabled", "nodeName", - "id" + "id", + "elementWidth", + "elementHeight", + "screenWidth", + "screenHeight" ], "EmscriptenPointerlockChangeEvent": [ "isActive", |