From 40b952d8bf75d437b2e6425c2a116ddead66c3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Vani=C5=A1?= Date: Sat, 9 Dec 2023 14:42:44 +0100 Subject: [PATCH] feat: Add start as minimized toggle to settings (#248) Co-authored-by: TheKodeToad Co-authored-by: V Co-authored-by: Lewis Crichton --- src/main/mainWindow.ts | 14 +++++++++----- src/main/splash.ts | 5 +++-- src/renderer/components/Settings.tsx | 3 ++- src/shared/settings.d.ts | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 8fdb6ee..6e9a05c 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -442,7 +442,8 @@ function createMainWindow() { const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"))); export async function createWindows() { - const splash = createSplashWindow(); + const { startMinimized } = Settings.store; + const splash = createSplashWindow(startMinimized); // SteamOS letterboxes and scales it terribly, so just full screen it if (isDeckGameMode) splash.setFullScreen(true); await ensureVencordFiles(); @@ -452,11 +453,8 @@ export async function createWindows() { mainWin.webContents.on("did-finish-load", () => { splash.destroy(); - mainWin!.show(); - if (Settings.store.maximized && !isDeckGameMode) { - mainWin!.maximize(); - } + if (!startMinimized || isDeckGameMode) mainWin!.show(); if (isDeckGameMode) { // always use entire display @@ -466,5 +464,11 @@ export async function createWindows() { } }); + mainWin.once("show", () => { + if (Settings.store.maximized && !mainWin!.isMaximized() && !isDeckGameMode) { + mainWin!.maximize(); + } + }); + initArRPC(); } diff --git a/src/main/splash.ts b/src/main/splash.ts index f21799d..7c05de9 100644 --- a/src/main/splash.ts +++ b/src/main/splash.ts @@ -11,10 +11,11 @@ import { ICON_PATH, VIEW_DIR } from "shared/paths"; import { Settings } from "./settings"; -export function createSplashWindow() { +export function createSplashWindow(startMinimized = false) { const splash = new BrowserWindow({ ...SplashProps, - icon: ICON_PATH + icon: ICON_PATH, + show: !startMinimized }); splash.loadFile(join(VIEW_DIR, "splash.html")); diff --git a/src/renderer/components/Settings.tsx b/src/renderer/components/Settings.tsx index f818c3c..b90c746 100644 --- a/src/renderer/components/Settings.tsx +++ b/src/renderer/components/Settings.tsx @@ -49,7 +49,8 @@ export default function SettingsUi() { "Open Links in app (experimental)", "Opens links in a new Vesktop window instead of your web browser" ], - ["checkUpdates", "Check for updates", "Automatically check for Vesktop updates", true] + ["checkUpdates", "Check for updates", "Automatically check for Vesktop updates", true], + ["startMinimized", "Start minimized", "Vesktop remains in minimized mode on start", false] ]; const switches = allSwitches.filter(isTruthy); diff --git a/src/shared/settings.d.ts b/src/shared/settings.d.ts index 5cb6ca0..236cdfc 100644 --- a/src/shared/settings.d.ts +++ b/src/shared/settings.d.ts @@ -19,6 +19,7 @@ export interface Settings { arRPC?: boolean; appBadge?: boolean; discordWindowsTitleBar?: boolean; + startMinimized?: boolean; maximized?: boolean; minimized?: boolean;