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

enable escape for exit of webview fullscreen #2021

Merged
merged 1 commit into from
Jun 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions 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,6 +532,7 @@ class Frame extends ImmutableComponent {
})
this.webview.addEventListener('enter-html-full-screen', () => {
windowActions.setFullScreen(this.props.frame, true, true)
// disable the fullscreen warning after 5 seconds
setTimeout(windowActions.setFullScreen.bind(this, this.props.frame, undefined, false), 5000)
})
this.webview.addEventListener('leave-html-full-screen', () => {
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