Save window position and size when exiting usually

This commit is contained in:
Yuya Ochiai
2015-12-05 19:32:24 +09:00
parent f8f38ba0de
commit b3bcc89a4d

View File

@@ -85,6 +85,7 @@ app.on('ready', function() {
} }
catch (e) { catch (e) {
// follow Electron's defaults // follow Electron's defaults
window_options = {};
} }
window_options.icon = __dirname + '/resources/appicon.png'; window_options.icon = __dirname + '/resources/appicon.png';
mainWindow = new BrowserWindow(window_options); mainWindow = new BrowserWindow(window_options);
@@ -96,8 +97,11 @@ app.on('ready', function() {
// mainWindow.openDevTools(); // mainWindow.openDevTools();
mainWindow.on('close', function(event) { mainWindow.on('close', function(event) {
// Minimize or hide the window for close button. if (willAppQuit) { // when [Ctrl|Cmd]+Q
if (!willAppQuit) { // avoid [Ctrl|Cmd]+Q var bounds = mainWindow.getBounds();
fs.writeFileSync(bounds_info_path, JSON.stringify(bounds));
}
else { // Minimize or hide the window for close button.
event.preventDefault(); event.preventDefault();
switch (process.platform) { switch (process.platform) {
case 'win32': case 'win32':