Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
enable escape for exit of webview fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed Jun 1, 2016
1 parent 1ff038c commit bdc84e6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
12 changes: 11 additions & 1 deletion js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 12 additions & 6 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bdc84e6

Please sign in to comment.