Restore window size correctly

* Don't attempt to change size when maximized or fullscreen
* Bugfix: restore window size correctly when returning from a video so big that it that caused the window to maximize
This commit is contained in:
DC
2016-03-21 02:02:29 -07:00
parent 1c2cd5f49e
commit 511c60671c
2 changed files with 30 additions and 6 deletions

View File

@@ -26,8 +26,8 @@ function init () {
menu.showOpenTorrentFile()
})
ipcMain.on('setBounds', function (e, bounds) {
setBounds(bounds)
ipcMain.on('setBounds', function (e, bounds, maximize) {
setBounds(bounds, maximize)
})
ipcMain.on('setAspectRatio', function (e, aspectRatio, extraSize) {
@@ -59,9 +59,24 @@ function init () {
ipcMain.on('unblockPowerSave', unblockPowerSave)
}
function setBounds (bounds) {
debug('setBounds %o', bounds)
if (windows.main && !windows.main.isFullScreen() && !windows.main.isMaximized()) {
function setBounds (bounds, maximize) {
// Do nothing in fullscreen
if (!windows.main || windows.main.isFullScreen()) return
// Maximize or minimize, if the second argument is present
var willBeMaximized
if (maximize === true) {
windows.main.maximize()
willBeMaximized = true
} else if (maximize === false) {
windows.main.unmaximize()
willBeMaximized = false
} else {
willBeMaximized = windows.main.isMaximized()
}
// Assuming we're not maximized or maximizing, set the window size
if (!willBeMaximized) {
windows.main.setBounds(bounds, true)
}
}