From 4918d699d56ce29168b50965f288aaa681d97b27 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 28 Feb 2023 22:17:39 +0100 Subject: [PATCH] Windows: Add Option to use native titlebar ~ Closes #537 --- src/Vencord.ts | 9 +++++++++ src/api/settings.ts | 2 ++ src/components/VencordSettings/VencordTab.tsx | 8 ++++++-- src/patcher.ts | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Vencord.ts b/src/Vencord.ts index ac8579bfe..ba7d01fe6 100644 --- a/src/Vencord.ts +++ b/src/Vencord.ts @@ -95,3 +95,12 @@ async function init() { } init(); + +if (!IS_WEB && Settings.winNativeTitleBar && navigator.platform.toLowerCase().startsWith("win")) { + document.addEventListener("DOMContentLoaded", () => { + document.head.append(Object.assign(document.createElement("style"), { + id: "vencord-native-titlebar-style", + textContent: "[class*=titleBar-]{display: none!important}" + })); + }, { once: true }); +} diff --git a/src/api/settings.ts b/src/api/settings.ts index c7117918a..d05afcd93 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -34,6 +34,7 @@ export interface Settings { frameless: boolean; transparent: boolean; winCtrlQ: boolean; + winNativeTitleBar: boolean; plugins: { [plugin: string]: { enabled: boolean; @@ -57,6 +58,7 @@ const DefaultSettings: Settings = { frameless: false, transparent: false, winCtrlQ: false, + winNativeTitleBar: false, plugins: {}, notifications: { diff --git a/src/components/VencordSettings/VencordTab.tsx b/src/components/VencordSettings/VencordTab.tsx index 98808728a..5ac120d7c 100644 --- a/src/components/VencordSettings/VencordTab.tsx +++ b/src/components/VencordSettings/VencordTab.tsx @@ -63,11 +63,15 @@ function VencordSettings() { title: "Enable React Developer Tools", note: "Requires a full restart" }, - !IS_WEB && !isWindows && { + !IS_WEB && (!isWindows ? { key: "frameless", title: "Disable the window frame", note: "Requires a full restart" - }, + } : { + key: "winNativeTitleBar", + title: "Use Windows' native title bar instead of Discord's custom one", + note: "Requires a full restart" + }), !IS_WEB && { key: "transparent", title: "Enable window transparency", diff --git a/src/patcher.ts b/src/patcher.ts index d51405d1b..9752a0441 100644 --- a/src/patcher.ts +++ b/src/patcher.ts @@ -79,7 +79,10 @@ if (!process.argv.includes("--vanilla")) { options.webPreferences.sandbox = false; if (settings.frameless) { options.frame = false; + } else if (process.platform === "win32" && settings.winNativeTitleBar) { + delete options.frame; } + if (settings.transparent) { options.transparent = true; options.backgroundColor = "#00000000";