From 0f0bddbef916286f5a2e6391660120c8ce9bfda5 Mon Sep 17 00:00:00 2001 From: Redeven <18680184+redeven@users.noreply.github.com> Date: Sat, 6 Jan 2024 23:11:00 -0300 Subject: [PATCH] feat: Add start minimized as a launch argument (#316) Co-authored-by: V --- src/main/mainWindow.ts | 15 +++++++++++---- src/main/splash.ts | 5 +++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 68cc0cb..2561c43 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -446,7 +446,8 @@ function createMainWindow() { const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"))); export async function createWindows() { - const splash = createSplashWindow(); + const startMinimized = process.argv.includes("--start-minimized"); + const splash = createSplashWindow(startMinimized); // SteamOS letterboxes and scales it terribly, so just full screen it if (isDeckGameMode) splash.setFullScreen(true); await ensureVencordFiles(); @@ -456,10 +457,10 @@ export async function createWindows() { mainWin.webContents.on("did-finish-load", () => { splash.destroy(); - mainWin!.show(); - if (State.store.maximized && !isDeckGameMode) { - mainWin!.maximize(); + if (!startMinimized) { + mainWin!.show(); + if (State.store.maximized && !isDeckGameMode) mainWin!.maximize(); } if (isDeckGameMode) { @@ -468,6 +469,12 @@ export async function createWindows() { askToApplySteamLayout(mainWin); } + + mainWin.once("show", () => { + if (State.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"));