aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-11-06 15:44:44 +0100
committerLibravatar GitHub <noreply@github.com>2017-11-06 15:44:44 +0100
commit6acb04674d19242cfecacdd9c6d53ea7fb8351e4 (patch)
tree0ec6d543af23167911eca131709b4cd7772bc06b
parentbump version to beta 12 (diff)
parentremove debugging (diff)
downloadferdium-app-6acb04674d19242cfecacdd9c6d53ea7fb8351e4.tar.gz
ferdium-app-6acb04674d19242cfecacdd9c6d53ea7fb8351e4.tar.zst
ferdium-app-6acb04674d19242cfecacdd9c6d53ea7fb8351e4.zip
Merge pull request #227 from meetfranz/feature/win-skip-taskbar-minimize-systray
fix(Windows): Fix issue with multiple close handlers that prevent the app from quitting
-rw-r--r--src/index.js34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/index.js b/src/index.js
index a3aa14732..f0fe56ae5 100644
--- a/src/index.js
+++ b/src/index.js
@@ -26,19 +26,18 @@ if (isWindows) {
26} 26}
27 27
28// Force single window 28// Force single window
29if (process.platform !== 'darwin') { 29const isSecondInstance = app.makeSingleInstance(() => {
30 const isSecondInstance = app.makeSingleInstance(() => { 30 if (mainWindow) {
31 if (mainWindow) { 31 if (mainWindow.isMinimized()) mainWindow.restore();
32 if (mainWindow.isMinimized()) mainWindow.restore(); 32 mainWindow.focus();
33 mainWindow.focus();
34 }
35 });
36
37 if (isSecondInstance) {
38 app.quit();
39 } 33 }
34});
35
36if (isSecondInstance) {
37 app.exit();
40} 38}
41 39
40
42// Initialize Settings 41// Initialize Settings
43const settings = new Settings(); 42const settings = new Settings();
44 43
@@ -86,9 +85,13 @@ const createWindow = async () => {
86 // when you should delete the corresponding element. 85 // when you should delete the corresponding element.
87 if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) { 86 if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) {
88 e.preventDefault(); 87 e.preventDefault();
89 mainWindow.hide(); 88 if (isWindows) {
89 mainWindow.minimize();
90 } else {
91 mainWindow.hide();
92 }
90 93
91 if (process.platform === 'win32') { 94 if (isWindows && settings.get('minimizeToSystemTray')) {
92 mainWindow.setSkipTaskbar(true); 95 mainWindow.setSkipTaskbar(true);
93 } 96 }
94 } else { 97 } else {
@@ -111,13 +114,6 @@ const createWindow = async () => {
111 app.isMaximized = true; 114 app.isMaximized = true;
112 }); 115 });
113 116
114 mainWindow.on('close', (e) => {
115 if (settings.get('minimizeToSystemTray')) {
116 e.preventDefault();
117 mainWindow.minimize();
118 }
119 });
120
121 mainWindow.on('unmaximize', () => { 117 mainWindow.on('unmaximize', () => {
122 app.isMaximized = false; 118 app.isMaximized = false;
123 }); 119 });