Center video on current screen (#427)

Fixes #404
This commit is contained in:
DC
2016-04-22 19:59:17 -07:00
committed by Feross Aboukhadijeh
parent 9a1c329434
commit 6b70554e63
2 changed files with 9 additions and 5 deletions

View File

@@ -140,6 +140,14 @@ function setBounds (bounds, maximize) {
// Assuming we're not maximized or maximizing, set the window size
if (!willBeMaximized) {
log('setBounds: setting bounds to ' + JSON.stringify(bounds))
if (bounds.x === null && bounds.y === null) {
// X and Y not specified? By default, center on current screen
var screen = require('screen')
var scr = screen.getDisplayMatching(windows.main.getBounds())
bounds.x = Math.round(scr.bounds.x + scr.bounds.width / 2 - bounds.width / 2)
bounds.y = Math.round(scr.bounds.y + scr.bounds.height / 2 - bounds.height / 2)
log('setBounds: centered to ' + JSON.stringify(bounds))
}
windows.main.setBounds(bounds, true)
} else {
log('setBounds: not setting bounds because of window maximization')

View File

@@ -1054,12 +1054,8 @@ function setDimensions (dimensions) {
config.WINDOW_MIN_HEIGHT
)
// Center window on screen
var x = Math.floor((screenWidth - width) / 2)
var y = Math.floor((screenHeight - height) / 2)
ipcRenderer.send('setAspectRatio', aspectRatio)
ipcRenderer.send('setBounds', {x, y, width, height})
ipcRenderer.send('setBounds', {x: null, y: null, width, height})
}
function restoreBounds () {