From 6b70554e63b1aef81f82f20c0b221e91e8375f8c Mon Sep 17 00:00:00 2001 From: DC Date: Fri, 22 Apr 2016 19:59:17 -0700 Subject: [PATCH] Center video on current screen (#427) Fixes #404 --- main/ipc.js | 8 ++++++++ renderer/index.js | 6 +----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/main/ipc.js b/main/ipc.js index b056a248..79bdd928 100644 --- a/main/ipc.js +++ b/main/ipc.js @@ -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') diff --git a/renderer/index.js b/renderer/index.js index bd127e7d..ab6206de 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -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 () {