From 7ef591f3a85e01a630c630d39fc751bb49f0ca11 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Mon, 10 Jul 2023 03:59:09 -0700 Subject: [PATCH] Desktop: Fixes #8256: Don't start window minimized in GNOME (#8441) --- packages/app-desktop/ElectronAppWrapper.ts | 5 ++++- packages/app-desktop/app.ts | 2 +- packages/lib/shim.ts | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/app-desktop/ElectronAppWrapper.ts b/packages/app-desktop/ElectronAppWrapper.ts index 4c12a8c35..43cd0380e 100644 --- a/packages/app-desktop/ElectronAppWrapper.ts +++ b/packages/app-desktop/ElectronAppWrapper.ts @@ -100,7 +100,10 @@ export default class ElectronAppWrapper { webviewTag: true, // We start with a hidden window, which is then made visible depending on the showTrayIcon setting // https://github.com/laurent22/joplin/issues/2031 - show: debugEarlyBugs, + // + // On Linux/GNOME, however, the window doesn't show correctly if show is false initially: + // https://github.com/laurent22/joplin/issues/8256 + show: debugEarlyBugs || shim.isGNOME(), }; // Linux icon workaround for bug https://github.com/electron-userland/electron-builder/issues/2098 diff --git a/packages/app-desktop/app.ts b/packages/app-desktop/app.ts index 1b93df76a..813763e46 100644 --- a/packages/app-desktop/app.ts +++ b/packages/app-desktop/app.ts @@ -494,7 +494,7 @@ class Application extends BaseApplication { }, 1000 * 60 * 60); if (Setting.value('startMinimized') && Setting.value('showTrayIcon')) { - // Keep it hidden + bridge().window().hide(); } else { bridge().window().show(); } diff --git a/packages/lib/shim.ts b/packages/lib/shim.ts index b97be62f2..13592b9fa 100644 --- a/packages/lib/shim.ts +++ b/packages/lib/shim.ts @@ -57,6 +57,13 @@ const shim = { return process && process.platform === 'linux'; }, + isGNOME: () => { + // XDG_CURRENT_DESKTOP may be something like "ubuntu:GNOME" and not just "GNOME". + // Thus, we use .includes and not ===. + return (shim.isLinux() || shim.isFreeBSD()) + && process && (process.env['XDG_CURRENT_DESKTOP'] ?? '').includes('GNOME'); + }, + isFreeBSD: () => { return process && process.platform === 'freebsd'; },