Skip to content

Commit

Permalink
fix(Linux): Fix minimized window focusing (#1304) (@skoruppa)
Browse files Browse the repository at this point in the history
* trigger build

* Check if window is minimized before restoring it

* restore() should be executed only when window is minimized
  • Loading branch information
skoruppa authored and adlk committed Mar 8, 2019
1 parent c62a6a6 commit 5b02c4d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ if (!gotTheLock) {
app.on('second-instance', (event, argv) => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.show();
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
mainWindow.focus();

if (isWindows) {
Expand Down
8 changes: 8 additions & 0 deletions src/lib/Tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export default class TrayIcon {
{
label: 'Show Franz',
click() {
if (app.mainWindow.isMinimized()) {
app.mainWindow.restore();
}
app.mainWindow.show();
app.mainWindow.focus();
},
}, {
label: 'Quit Franz',
Expand All @@ -36,7 +40,11 @@ export default class TrayIcon {
this.trayIcon.setContextMenu(trayMenu);

this.trayIcon.on('click', () => {
if (app.mainWindow.isMinimized()) {
app.mainWindow.restore();
}
app.mainWindow.show();
app.mainWindow.focus();
});

if (process.platform === 'darwin') {
Expand Down
9 changes: 4 additions & 5 deletions src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { URL } from 'url';
import Store from './lib/Store';
import Request from './lib/Request';
import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config';
import { isMac, isLinux, isWindows } from '../environment';
import { isMac } from '../environment';
import locales from '../i18n/translations';
import { gaEvent, gaPage } from '../lib/analytics';
import { onVisibilityChange } from '../helpers/visibility-helper';
Expand Down Expand Up @@ -195,12 +195,11 @@ export default class AppStore extends Store {
});

this.actions.service.setActive({ serviceId });

if (isWindows) {
mainWindow.show();
if (app.mainWindow.isMinimized()) {
mainWindow.restore();
} else if (isLinux) {
mainWindow.show();
}
mainWindow.focus();
}
};
}
Expand Down

0 comments on commit 5b02c4d

Please sign in to comment.