From 6d35be79b8d66a76b567686e4616786a0d841f7a Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Fri, 14 Jul 2023 00:07:48 +0000 Subject: [PATCH] feat: use inset title bar style on macOS (#47) Co-authored-by: V --- src/main/mainWindow.ts | 1 + src/renderer/patches/index.ts | 1 + src/renderer/patches/platformClass.tsx | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 src/renderer/patches/platformClass.tsx diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index e4266c7..5d6e0c6 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -289,6 +289,7 @@ function createMainWindow() { backgroundColor: "#ffffff00" } : {}), + ...(process.platform === "darwin" ? { titleBarStyle: "hiddenInset" } : {}), ...getWindowBoundsOptions() })); win.setMenuBarVisibility(false); diff --git a/src/renderer/patches/index.ts b/src/renderer/patches/index.ts index 8ff8c6f..d2bd536 100644 --- a/src/renderer/patches/index.ts +++ b/src/renderer/patches/index.ts @@ -6,3 +6,4 @@ // TODO: Possibly auto generate glob if we have more patches in the future import "./spellCheck"; +import "./platformClass"; diff --git a/src/renderer/patches/platformClass.tsx b/src/renderer/patches/platformClass.tsx new file mode 100644 index 0000000..da71127 --- /dev/null +++ b/src/renderer/patches/platformClass.tsx @@ -0,0 +1,22 @@ +/* + * SPDX-License-Identifier: GPL-3.0 + * Vesktop, a desktop app aiming to give you a snappier Discord Experience + * Copyright (c) 2023 Vendicated and Vencord contributors + */ + +import { addPatch } from "./shared"; + +addPatch({ + patches: [ + { + find: "platform-web", + replacement: { + // eslint-disable-next-line no-useless-escape + match: /(?<=" platform-overlay"\):)\i/, + replace: "$self.getPlatformClass()" + } + } + ], + + getPlatformClass: () => (navigator.platform.toLowerCase().startsWith("mac") ? "platform-osx" : "platform-web") +});