diff options
author | Stefan <stefan@adlk.io> | 2019-03-05 10:53:52 +0100 |
---|---|---|
committer | Stefan <stefan@adlk.io> | 2019-03-05 10:53:52 +0100 |
commit | 78a372272d5001e2033eeddafbb57cf42c2f666a (patch) | |
tree | 8dcaafde9e0e6422577b81607a0034e38a283717 /src | |
parent | move devmode info (diff) | |
download | ferdium-app-78a372272d5001e2033eeddafbb57cf42c2f666a.tar.gz ferdium-app-78a372272d5001e2033eeddafbb57cf42c2f666a.tar.zst ferdium-app-78a372272d5001e2033eeddafbb57cf42c2f666a.zip |
fix(Windows): Fix losing window when "Keep Franz in background" is enabled
Diffstat (limited to 'src')
-rw-r--r-- | src/index.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/index.js b/src/index.js index 69cfa77e7..0614197a2 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -223,20 +223,24 @@ const createWindow = () => { | |||
223 | 223 | ||
224 | // Emitted when the window is closed. | 224 | // Emitted when the window is closed. |
225 | mainWindow.on('close', (e) => { | 225 | mainWindow.on('close', (e) => { |
226 | debug('Window: close window'); | ||
226 | // Dereference the window object, usually you would store windows | 227 | // Dereference the window object, usually you would store windows |
227 | // in an array if your app supports multi windows, this is the time | 228 | // in an array if your app supports multi windows, this is the time |
228 | // when you should delete the corresponding element. | 229 | // when you should delete the corresponding element. |
229 | if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) { | 230 | if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) { |
230 | e.preventDefault(); | 231 | e.preventDefault(); |
231 | if (isWindows) { | 232 | if (isWindows) { |
233 | debug('Window: minimize'); | ||
232 | mainWindow.minimize(); | 234 | mainWindow.minimize(); |
235 | |||
236 | if (settings.get('minimizeToSystemTray')) { | ||
237 | debug('Skip taskbar: true'); | ||
238 | mainWindow.setSkipTaskbar(true); | ||
239 | } | ||
233 | } else { | 240 | } else { |
241 | debug('Window: hide'); | ||
234 | mainWindow.hide(); | 242 | mainWindow.hide(); |
235 | } | 243 | } |
236 | |||
237 | if (isWindows) { | ||
238 | mainWindow.setSkipTaskbar(true); | ||
239 | } | ||
240 | } else { | 244 | } else { |
241 | app.quit(); | 245 | app.quit(); |
242 | } | 246 | } |
@@ -248,32 +252,39 @@ const createWindow = () => { | |||
248 | app.wasMaximized = app.isMaximized; | 252 | app.wasMaximized = app.isMaximized; |
249 | 253 | ||
250 | if (settings.get('minimizeToSystemTray')) { | 254 | if (settings.get('minimizeToSystemTray')) { |
255 | debug('Skip taskbar: true'); | ||
251 | mainWindow.setSkipTaskbar(true); | 256 | mainWindow.setSkipTaskbar(true); |
252 | trayIcon.show(); | 257 | trayIcon.show(); |
253 | } | 258 | } |
254 | }); | 259 | }); |
255 | 260 | ||
256 | mainWindow.on('maximize', () => { | 261 | mainWindow.on('maximize', () => { |
262 | debug('Window: maximize'); | ||
257 | app.isMaximized = true; | 263 | app.isMaximized = true; |
258 | }); | 264 | }); |
259 | 265 | ||
260 | mainWindow.on('unmaximize', () => { | 266 | mainWindow.on('unmaximize', () => { |
267 | debug('Window: unmaximize'); | ||
261 | app.isMaximized = false; | 268 | app.isMaximized = false; |
262 | }); | 269 | }); |
263 | 270 | ||
264 | mainWindow.on('restore', () => { | 271 | mainWindow.on('restore', () => { |
272 | debug('Window: restore'); | ||
265 | mainWindow.setSkipTaskbar(false); | 273 | mainWindow.setSkipTaskbar(false); |
266 | 274 | ||
267 | if (app.wasMaximized) { | 275 | if (app.wasMaximized) { |
276 | debug('Window: was maximized before, maximize window'); | ||
268 | mainWindow.maximize(); | 277 | mainWindow.maximize(); |
269 | } | 278 | } |
270 | 279 | ||
271 | if (!settings.get('enableSystemTray')) { | 280 | if (!settings.get('enableSystemTray')) { |
281 | debug('Tray: hiding tray icon'); | ||
272 | trayIcon.hide(); | 282 | trayIcon.hide(); |
273 | } | 283 | } |
274 | }); | 284 | }); |
275 | 285 | ||
276 | mainWindow.on('show', () => { | 286 | mainWindow.on('show', () => { |
287 | debug('Skip taskbar: false'); | ||
277 | mainWindow.setSkipTaskbar(false); | 288 | mainWindow.setSkipTaskbar(false); |
278 | }); | 289 | }); |
279 | 290 | ||
@@ -281,6 +292,7 @@ const createWindow = () => { | |||
281 | app.isMaximized = mainWindow.isMaximized(); | 292 | app.isMaximized = mainWindow.isMaximized(); |
282 | 293 | ||
283 | mainWindow.webContents.on('new-window', (e, url) => { | 294 | mainWindow.webContents.on('new-window', (e, url) => { |
295 | debug('Open url', url); | ||
284 | e.preventDefault(); | 296 | e.preventDefault(); |
285 | shell.openExternal(url); | 297 | shell.openExternal(url); |
286 | }); | 298 | }); |
@@ -360,7 +372,10 @@ app.on('window-all-closed', () => { | |||
360 | // to stay active until the user quits explicitly with Cmd + Q | 372 | // to stay active until the user quits explicitly with Cmd + Q |
361 | if (settings.get('runInBackground') === undefined | 373 | if (settings.get('runInBackground') === undefined |
362 | || settings.get('runInBackground')) { | 374 | || settings.get('runInBackground')) { |
375 | debug('Window: all windows closed, quit app'); | ||
363 | app.quit(); | 376 | app.quit(); |
377 | } else { | ||
378 | debug('Window: don\'t quit app'); | ||
364 | } | 379 | } |
365 | }); | 380 | }); |
366 | 381 | ||