diff --git a/main/ipc.js b/main/ipc.js index f0352f22..02d99fbc 100644 --- a/main/ipc.js +++ b/main/ipc.js @@ -49,7 +49,7 @@ function addTorrentFromPaste () { function setBounds (bounds) { debug('setBounds %o', bounds) - if (windows.main && !windows.main.isFullScreen()) { + if (windows.main && !windows.main.isFullScreen() && !windows.main.isMaximized()) { windows.main.setBounds(bounds, true) } } diff --git a/main/windows.js b/main/windows.js index 4b7c08b9..0a02e445 100644 --- a/main/windows.js +++ b/main/windows.js @@ -16,13 +16,14 @@ app.on('before-quit', function () { function createMainWindow (menu) { var win = windows.main = new electron.BrowserWindow({ + autoHideMenuBar: true, // Hide top menu bar unless Alt key is pressed (Windows, Linux) backgroundColor: '#282828', - darkTheme: true, + darkTheme: true, // Forces dark theme (GTK+3 only) minWidth: 375, minHeight: 158, - show: false, + show: false, // Hide window until DOM finishes loading title: config.APP_NAME, - titleBarStyle: 'hidden-inset', + titleBarStyle: 'hidden-inset', // Hide OS chrome, except traffic light buttons (OS X) width: 450, height: 300 }) @@ -33,10 +34,8 @@ function createMainWindow (menu) { }) win.webContents.on('did-finish-load', function () { - setTimeout(function () { - debug('startup time: %sms', Date.now() - app.startTime) - win.show() - }, 50) + debug('startup time: %sms', Date.now() - app.startTime) + win.show() }) win.on('blur', menu.onWindowHide) diff --git a/renderer/index.js b/renderer/index.js index d0b088b1..bd2f9732 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -163,13 +163,7 @@ function dispatch (action, ...args) { if (action === 'back') { // TODO // window.history.back() - if (state.url === '/player') { - restoreBounds() - closeServer() - } - state.url = '/' - state.title = config.APP_NAME - update() + closePlayer() } if (action === 'forward') { // TODO @@ -404,6 +398,17 @@ function openPlayer (torrent) { }) } +function closePlayer () { + state.url = '/' + state.title = config.APP_NAME + if (state.isFullScreen) { + electron.ipcRenderer.send('toggleFullScreen') + } + restoreBounds() + closeServer() + update() +} + function deleteTorrent (torrent) { var ix = state.saved.torrents.findIndex((x) => x.infoHash === torrent.infoHash) if (ix > -1) state.saved.torrents.splice(ix, 1)