Remember window position, size, and maximized/fullscreen status
FREEBIE
This commit is contained in:
parent
ebc373185a
commit
69d4a77f1e
1 changed files with 28 additions and 3 deletions
31
main.js
31
main.js
|
@ -9,6 +9,8 @@ const autoUpdaterInterval = 60 * 60 * 1000;
|
||||||
const ipc = electron.ipcMain;
|
const ipc = electron.ipcMain;
|
||||||
const Menu = electron.Menu;
|
const Menu = electron.Menu;
|
||||||
const shell = electron.shell;
|
const shell = electron.shell;
|
||||||
|
const ElectronConfig = require('electron-config');
|
||||||
|
const userConfig = new ElectronConfig();
|
||||||
|
|
||||||
console.log('setting AUMID');
|
console.log('setting AUMID');
|
||||||
app.setAppUserModelId('org.whispersystems.signal-desktop')
|
app.setAppUserModelId('org.whispersystems.signal-desktop')
|
||||||
|
@ -72,10 +74,10 @@ console.log('userData ' + app.getPath('userData'));
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
let windowConfig = userConfig.get('window');
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
const windowOptions = Object.assign({
|
||||||
mainWindow = new BrowserWindow({
|
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 610,
|
height: 610,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
|
@ -83,7 +85,30 @@ function createWindow () {
|
||||||
//sandbox: true,
|
//sandbox: true,
|
||||||
preload: path.join(__dirname, 'preload.js')
|
preload: path.join(__dirname, 'preload.js')
|
||||||
}
|
}
|
||||||
});
|
}, windowConfig);
|
||||||
|
|
||||||
|
// Create the browser window.
|
||||||
|
mainWindow = new BrowserWindow(windowOptions);
|
||||||
|
|
||||||
|
function captureAndSaveWindowStats() {
|
||||||
|
const size = mainWindow.getSize();
|
||||||
|
const position = mainWindow.getPosition();
|
||||||
|
|
||||||
|
// so if we need to recreate the window, we have the most recent settings
|
||||||
|
windowConfig = {
|
||||||
|
maximized: mainWindow.isMaximized(),
|
||||||
|
fullscreen: mainWindow.isFullScreen(),
|
||||||
|
width: size[0],
|
||||||
|
height: size[1],
|
||||||
|
x: position[0],
|
||||||
|
y: position[1]
|
||||||
|
};
|
||||||
|
|
||||||
|
userConfig.set('window', windowConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
mainWindow.on('resize', captureAndSaveWindowStats);
|
||||||
|
mainWindow.on('move', captureAndSaveWindowStats);
|
||||||
|
|
||||||
mainWindow.on('focus', function() {
|
mainWindow.on('focus', function() {
|
||||||
mainWindow.flashFrame(false);
|
mainWindow.flashFrame(false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue