Skip to content
Permalink
Browse files

fix(Windows): Fix losing window when "Keep Franz in background" is en…

…abled
  • Loading branch information...
adlk committed Mar 5, 2019
1 parent 03430f9 commit 78a372272d5001e2033eeddafbb57cf42c2f666a
Showing with 19 additions and 4 deletions.
  1. +19 −4 src/index.js
@@ -223,20 +223,24 @@ const createWindow = () => {

// Emitted when the window is closed.
mainWindow.on('close', (e) => {
debug('Window: close window');
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
if (!willQuitApp && (settings.get('runInBackground') === undefined || settings.get('runInBackground'))) {
e.preventDefault();
if (isWindows) {
debug('Window: minimize');
mainWindow.minimize();

if (settings.get('minimizeToSystemTray')) {
debug('Skip taskbar: true');
mainWindow.setSkipTaskbar(true);
}
} else {
debug('Window: hide');
mainWindow.hide();
}

if (isWindows) {
mainWindow.setSkipTaskbar(true);
}
} else {
app.quit();
}
@@ -248,39 +252,47 @@ const createWindow = () => {
app.wasMaximized = app.isMaximized;

if (settings.get('minimizeToSystemTray')) {
debug('Skip taskbar: true');
mainWindow.setSkipTaskbar(true);
trayIcon.show();
}
});

mainWindow.on('maximize', () => {
debug('Window: maximize');
app.isMaximized = true;
});

mainWindow.on('unmaximize', () => {
debug('Window: unmaximize');
app.isMaximized = false;
});

mainWindow.on('restore', () => {
debug('Window: restore');
mainWindow.setSkipTaskbar(false);

if (app.wasMaximized) {
debug('Window: was maximized before, maximize window');
mainWindow.maximize();
}

if (!settings.get('enableSystemTray')) {
debug('Tray: hiding tray icon');
trayIcon.hide();
}
});

mainWindow.on('show', () => {
debug('Skip taskbar: false');
mainWindow.setSkipTaskbar(false);
});

app.mainWindow = mainWindow;
app.isMaximized = mainWindow.isMaximized();

mainWindow.webContents.on('new-window', (e, url) => {
debug('Open url', url);
e.preventDefault();
shell.openExternal(url);
});
@@ -360,7 +372,10 @@ app.on('window-all-closed', () => {
// to stay active until the user quits explicitly with Cmd + Q
if (settings.get('runInBackground') === undefined
|| settings.get('runInBackground')) {
debug('Window: all windows closed, quit app');
app.quit();
} else {
debug('Window: don\'t quit app');
}
});

2 comments on commit 78a3722

@imaginarny

This comment has been minimized.

Copy link
Contributor

imaginarny replied Mar 21, 2019

This commit reintroduced issue (#763 #1006) on windows when you can't minimize to task bar or close window completely. Fix in my PR was removed. #1038

@imaginarny

This comment has been minimized.

Copy link
Contributor

imaginarny replied Apr 5, 2019

@adlk bump? It got into stable anyway. I have no idea why is this condition on close action if (settings.get('minimizeToSystemTray')) back again so I won't post another issue nor pull request.

Please sign in to comment.
You can’t perform that action at this time.