From 11464176cb7b47235a5c57200a3b62a4eac2c2e4 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 5 Mar 2016 14:56:55 -0800 Subject: [PATCH] Start in correct full screen state If the app is already fullscreen when it is loaded, set state.view.isFullScreen to the correct state. --- main/windows.js | 25 +++++++++++++++---------- renderer/index.js | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/main/windows.js b/main/windows.js index 1bba659d..08d7dd47 100644 --- a/main/windows.js +++ b/main/windows.js @@ -15,7 +15,7 @@ app.on('before-quit', function () { }) function createMainWindow (menu) { - windows.main = new electron.BrowserWindow({ + var win = windows.main = new electron.BrowserWindow({ backgroundColor: '#282828', darkTheme: true, minWidth: 375, @@ -26,23 +26,28 @@ function createMainWindow (menu) { width: 450, height: 300 }) - windows.main.loadURL(config.INDEX) - windows.main.webContents.on('did-finish-load', function () { + win.loadURL(config.INDEX) + + win.webContents.on('dom-ready', function () { + menu.onToggleFullScreen() + }) + + win.webContents.on('did-finish-load', function () { setTimeout(function () { debug('startup time: %sms', Date.now() - app.startTime) - windows.main.show() + win.show() }, 50) }) - windows.main.on('enter-full-screen', menu.onToggleFullScreen) - windows.main.on('leave-full-screen', menu.onToggleFullScreen) - windows.main.on('close', function (e) { + win.on('enter-full-screen', menu.onToggleFullScreen) + win.on('leave-full-screen', menu.onToggleFullScreen) + win.on('close', function (e) { if (process.platform === 'darwin' && !isQuitting) { e.preventDefault() - windows.main.hide() + win.hide() } }) - windows.main.once('closed', function () { - windows.main = null + win.once('closed', function () { + win = null }) } diff --git a/renderer/index.js b/renderer/index.js index 7168e1b8..a82d9b7d 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -46,6 +46,7 @@ var state = global.state = { // history: [], /* track how we got to the current view. enables Back button */ // historyIndex: 0, isFocused: true, + isFullScreen: false, mainWindowBounds: null, /* x y width height */ title: 'WebTorrent' /* current window title */ },