diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 4d9aaf8..8afbf2e 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -21,6 +21,7 @@ import { VENCORD_FILES_DIR, VENCORD_QUICKCSS_FILE, VENCORD_THEMES_DIR } from "./ import { mainWin } from "./mainWindow"; import { Settings } from "./settings"; import { handle, handleSync } from "./utils/ipcWrappers"; +import { PopoutWindows } from "./utils/popout"; import { isDeckGameMode, showGamePage } from "./utils/steamOS"; import { isValidVencordInstall } from "./utils/vencordLoader"; @@ -79,8 +80,12 @@ handle(IpcEvents.FOCUS, () => { mainWin.show(); }); -handle(IpcEvents.CLOSE, e => { - (BrowserWindow.fromWebContents(e.sender) ?? e.sender).close(); +handle(IpcEvents.CLOSE, (e, key?: string) => { + const popout = PopoutWindows.get(key!); + if (popout) return popout.close(); + + const win = BrowserWindow.fromWebContents(e.sender) ?? e.sender; + win.close(); }); handle(IpcEvents.MINIMIZE, e => { diff --git a/src/main/utils/popout.ts b/src/main/utils/popout.ts index 754fdb0..8070449 100644 --- a/src/main/utils/popout.ts +++ b/src/main/utils/popout.ts @@ -5,6 +5,7 @@ */ import { BrowserWindow, BrowserWindowConstructorOptions } from "electron"; +import { Settings } from "main/settings"; import { handleExternalUrl } from "./makeLinksOpenExternally"; @@ -36,7 +37,7 @@ const DEFAULT_POPOUT_OPTIONS: BrowserWindowConstructorOptions = { backgroundColor: "#2f3136", minWidth: MIN_POPOUT_WIDTH, minHeight: MIN_POPOUT_HEIGHT, - frame: process.platform === "linux", + frame: Settings.store.customTitleBar !== true, titleBarStyle: process.platform === "darwin" ? "hidden" : undefined, trafficLightPosition: process.platform === "darwin" @@ -51,7 +52,7 @@ const DEFAULT_POPOUT_OPTIONS: BrowserWindowConstructorOptions = { } }; -const PopoutWindows = new Map(); +export const PopoutWindows = new Map(); function focusWindow(window: BrowserWindow) { window.setAlwaysOnTop(true); diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts index c7c5a3c..8c49402 100644 --- a/src/preload/VesktopNative.ts +++ b/src/preload/VesktopNative.ts @@ -53,7 +53,7 @@ export const VesktopNative = { }, win: { focus: () => invoke(IpcEvents.FOCUS), - close: () => invoke(IpcEvents.CLOSE), + close: (key?: string) => invoke(IpcEvents.CLOSE, key), minimize: () => invoke(IpcEvents.MINIMIZE), maximize: () => invoke(IpcEvents.MAXIMIZE) },