fix fullscreen on Windows
The win.isFullScreen() state takes a second to update so we should just pass the state manually into onToggleFullScreen().
This commit is contained in:
@@ -2,9 +2,10 @@ module.exports = {
|
||||
init: init
|
||||
}
|
||||
|
||||
var electron = require('electron')
|
||||
var debug = require('debug')('webtorrent-app:ipcMain')
|
||||
var electron = require('electron')
|
||||
var ipcMain = electron.ipcMain
|
||||
var menu = require('./menu')
|
||||
var windows = require('./windows')
|
||||
|
||||
function init () {
|
||||
@@ -28,8 +29,8 @@ function init () {
|
||||
setProgress(progress)
|
||||
})
|
||||
|
||||
ipcMain.on('toggleFullScreen', function (e) {
|
||||
windows.main.setFullScreen(!windows.main.isFullScreen())
|
||||
ipcMain.on('toggleFullScreen', function (e, flag) {
|
||||
menu.toggleFullScreen(flag)
|
||||
})
|
||||
|
||||
ipcMain.on('setTitle', function (e, title) {
|
||||
|
||||
29
main/menu.js
29
main/menu.js
@@ -5,19 +5,21 @@ var windows = require('./windows')
|
||||
|
||||
var app = electron.app
|
||||
|
||||
function toggleFullScreen () {
|
||||
debug('toggleFullScreen')
|
||||
function toggleFullScreen (flag) {
|
||||
debug('toggleFullScreen %s', flag)
|
||||
if (windows.main && windows.main.isVisible()) {
|
||||
windows.main.setFullScreen(!windows.main.isFullScreen())
|
||||
flag = flag != null ? flag : !windows.main.isFullScreen()
|
||||
windows.main.setFullScreen(flag)
|
||||
}
|
||||
}
|
||||
|
||||
// Sets whether the window should always show on top of other windows
|
||||
function toggleFloatOnTop () {
|
||||
debug('toggleFloatOnTop %s')
|
||||
function toggleFloatOnTop (flag) {
|
||||
debug('toggleFloatOnTop %s', flag)
|
||||
if (windows.main) {
|
||||
windows.main.setAlwaysOnTop(!windows.main.isAlwaysOnTop())
|
||||
getMenuItem('Float on Top').checked = windows.main.isAlwaysOnTop()
|
||||
flag = flag != null ? flag : !windows.main.isAlwaysOnTop()
|
||||
windows.main.setAlwaysOnTop(flag)
|
||||
getMenuItem('Float on Top').checked = flag
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +39,7 @@ function reloadWindow () {
|
||||
}
|
||||
|
||||
function addFakeDevice (device) {
|
||||
debug('addFakeDevice %s', device)
|
||||
windows.main.send('addFakeDevice', device)
|
||||
}
|
||||
|
||||
@@ -53,9 +56,11 @@ function onWindowHide () {
|
||||
}
|
||||
|
||||
function onToggleFullScreen () {
|
||||
windows.main.setMenuBarVisibility(!windows.main.isFullScreen())
|
||||
getMenuItem('Full Screen').checked = windows.main.isFullScreen()
|
||||
windows.main.send('fullscreenChanged', windows.main.isFullScreen())
|
||||
function onToggleFullScreen (isFullScreen) {
|
||||
isFullScreen = isFullScreen != null ? isFullScreen : windows.main.isFullScreen()
|
||||
windows.main.setMenuBarVisibility(!isFullScreen)
|
||||
getMenuItem('Full Screen').checked = isFullScreen
|
||||
windows.main.send('fullscreenChanged', isFullScreen)
|
||||
}
|
||||
|
||||
function getMenuItem (label) {
|
||||
@@ -150,12 +155,12 @@ function getMenuTemplate () {
|
||||
if (process.platform === 'darwin') return 'Ctrl+Command+F'
|
||||
else return 'F11'
|
||||
})(),
|
||||
click: toggleFullScreen
|
||||
click: () => toggleFullScreen()
|
||||
},
|
||||
{
|
||||
label: 'Float on Top',
|
||||
type: 'checkbox',
|
||||
click: toggleFloatOnTop
|
||||
click: () => toggleFloatOnTop()
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
|
||||
@@ -42,8 +42,8 @@ function createMainWindow (menu) {
|
||||
win.on('blur', menu.onWindowHide)
|
||||
win.on('focus', menu.onWindowShow)
|
||||
|
||||
win.on('enter-full-screen', menu.onToggleFullScreen)
|
||||
win.on('leave-full-screen', menu.onToggleFullScreen)
|
||||
win.on('enter-full-screen', () => menu.onToggleFullScreen(true))
|
||||
win.on('leave-full-screen', () => menu.onToggleFullScreen(false))
|
||||
|
||||
win.on('close', function (e) {
|
||||
if (process.platform === 'darwin' && !isQuitting) {
|
||||
|
||||
@@ -193,7 +193,7 @@ function dispatch (action, ...args) {
|
||||
update()
|
||||
}
|
||||
if (action === 'toggleFullScreen') {
|
||||
ipcRenderer.send('toggleFullScreen')
|
||||
ipcRenderer.send('toggleFullScreen', args[0])
|
||||
update()
|
||||
}
|
||||
if (action === 'videoMouseMoved') {
|
||||
@@ -448,7 +448,7 @@ function closePlayer () {
|
||||
update()
|
||||
|
||||
if (state.isFullScreen) {
|
||||
ipcRenderer.send('toggleFullScreen')
|
||||
dispatch('toggleFullScreen', false)
|
||||
}
|
||||
restoreBounds()
|
||||
stopServer()
|
||||
|
||||
Reference in New Issue
Block a user