diff --git a/js/components/frame.js b/js/components/frame.js index 091189c11f8..c255503e232 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -202,6 +202,17 @@ class Frame extends ImmutableComponent { if (this.props.isActive && !prevProps.isActive) { this.webview.focus() } + + // make sure the webview content updates to + // match the fullscreen state of the frame + if (prevProps.frame.get('isFullScreen') !== + this.props.frame.get('isFullScreen')) { + if (this.props.frame.get('isFullScreen')) { + this.webview.executeJavaScript('document.webkitRequestFullscreen()') + } else { + this.webview.executeJavaScript('document.webkitExitFullscreen()') + } + } this.webview.setAudioMuted(this.props.frame.get('audioMuted') || false) this.updateAboutDetails() } @@ -521,7 +532,6 @@ class Frame extends ImmutableComponent { }) this.webview.addEventListener('enter-html-full-screen', () => { windowActions.setFullScreen(this.props.frame, true, true) - setTimeout(windowActions.setFullScreen.bind(this, this.props.frame, undefined, false), 5000) }) this.webview.addEventListener('leave-html-full-screen', () => { windowActions.setFullScreen(this.props.frame, false) diff --git a/js/components/main.js b/js/components/main.js index fbfb9052b8d..68c4841de98 100644 --- a/js/components/main.js +++ b/js/components/main.js @@ -78,6 +78,9 @@ class Main extends ImmutableComponent { const isDarwin = process.platform === 'darwin' document.addEventListener('keydown', (e) => { switch (e.which) { + case keyCodes.ESC: + this.exitFullScreen() + break case keyCodes.F12: if (!isDarwin) { ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_TOGGLE_DEV_TOOLS) @@ -96,6 +99,14 @@ class Main extends ImmutableComponent { } }) } + + exitFullScreen () { + const activeFrame = FrameStateUtil.getActiveFrame(this.props.windowState) + if (activeFrame && activeFrame.get('isFullScreen')) { + windowActions.setFullScreen(activeFrame, false) + } + } + registerSwipeListener () { // Navigates back/forward on OS X two-finger swipe var trackingFingers = false @@ -129,12 +140,7 @@ class Main extends ImmutableComponent { deltaY = 0 startTime = 0 }) - ipc.on(messages.LEAVE_FULL_SCREEN, () => { - const activeFrame = FrameStateUtil.getActiveFrame(this.props.windowState) - if (activeFrame && activeFrame.get('isFullScreen')) { - windowActions.setFullScreen(activeFrame, false) - } - }) + ipc.on(messages.LEAVE_FULL_SCREEN, this.exitFullScreen.bind(this)) } loadOpenSearch () { diff --git a/js/stores/windowStore.js b/js/stores/windowStore.js index b68b2934831..95d3e0e005c 100644 --- a/js/stores/windowStore.js +++ b/js/stores/windowStore.js @@ -264,7 +264,7 @@ const doAction = (action) => { break case WindowConstants.WINDOW_SET_FULL_SCREEN: windowState = windowState.mergeIn(['frames', FrameStateUtil.getFramePropsIndex(windowState.get('frames'), action.frameProps)], { - isFullScreen: action.isFullScreen !== undefined ? action.isFullScreen : windowState.getIn(['frames', FrameStateUtil.getFramePropsIndex(windowState.get('frames'), action.frameProps)].concat('isFullScreen')), + isFullScreen: action.isFullScreen, showFullScreenWarning: action.showFullScreenWarning }) break