Skip to content

Commit

Permalink
also allow using discord titlebar on non-windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Vendicated committed Jan 16, 2024
1 parent 2aa0b0f commit 2e4c834
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/main/mainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,11 @@ function createMainWindow() {
removeSettingsListeners();
removeVencordSettingsListeners();

const { staticTitle, transparencyOption, enableMenu, discordWindowsTitleBar } = Settings.store;
const { staticTitle, transparencyOption, enableMenu, customTitleBar } = Settings.store;

const { frameless } = VencordSettings.store;

const noFrame = frameless === true || (process.platform === "win32" && discordWindowsTitleBar === true);
const noFrame = frameless === true || customTitleBar === true;

const win = (mainWin = new BrowserWindow({
show: false,
Expand All @@ -398,7 +398,7 @@ function createMainWindow() {
backgroundMaterial: transparencyOption
}),
// Fix transparencyOption for custom discord titlebar
...(discordWindowsTitleBar &&
...(customTitleBar &&
transparencyOption &&
transparencyOption !== "none" && {
transparent: true
Expand Down
10 changes: 8 additions & 2 deletions src/main/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ function loadSettings<T extends object = any>(file: string, name: string) {
}

export const Settings = loadSettings<TSettings>(SETTINGS_FILE, "Vesktop settings");
if (Object.hasOwn(Settings.plain, "discordWindowsTitleBar")) {
Settings.plain.customTitleBar = Settings.plain.discordWindowsTitleBar;
delete Settings.plain.discordWindowsTitleBar;
Settings.markAsChanged();
}

export const VencordSettings = loadSettings<any>(VENCORD_SETTINGS_FILE, "Vencord settings");

if (Object.hasOwn(Settings.store, "firstLaunch") && !existsSync(STATE_FILE)) {
if (Object.hasOwn(Settings.plain, "firstLaunch") && !existsSync(STATE_FILE)) {
console.warn("legacy state in settings.json detected. migrating to state.json");
const state = {} as TState;
for (const prop of [
Expand All @@ -47,7 +53,7 @@ if (Object.hasOwn(Settings.store, "firstLaunch") && !existsSync(STATE_FILE)) {
"skippedUpdate",
"steamOSLayoutVersion",
"windowBounds"
]) {
] as const) {
state[prop] = Settings.plain[prop];
delete Settings.plain[prop];
}
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Margins } from "@vencord/types/utils";
import { Button, Forms, Select, Switch, Text, Toasts, useState } from "@vencord/types/webpack/common";
import { setBadge } from "renderer/appBadge";
import { useSettings } from "renderer/settings";
import { isMac, isWindows } from "renderer/utils";
import { isMac } from "renderer/utils";
import { isTruthy } from "shared/utils/guards";

export default function SettingsUi() {
Expand All @@ -21,10 +21,10 @@ export default function SettingsUi() {
const [autoStartEnabled, setAutoStartEnabled] = useState(autostart.isEnabled());

const allSwitches: Array<false | [keyof typeof Settings, string, string, boolean?, (() => boolean)?]> = [
isWindows && [
"discordWindowsTitleBar",
[
"customTitleBar",
"Discord Titlebar",
"Use Discord's custom title bar instead of the Windows one. Requires a full restart."
"Use Discord's custom title bar instead of the native system one. Requires a full restart."
],
!isMac && ["tray", "Tray Icon", "Add a tray icon for Vesktop", true],
!isMac && [
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/patches/platformClass.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { Settings } from "renderer/settings";
import { isMac, isWindows } from "renderer/utils";
import { isMac } from "renderer/utils";

import { addPatch } from "./shared";

Expand All @@ -22,8 +22,8 @@ addPatch({
],

getPlatformClass() {
if (Settings.store.customTitleBar) return "platform-win";
if (isMac) return "platform-osx";
if (isWindows && Settings.store.discordWindowsTitleBar) return "platform-win";
return "platform-web";
}
});
2 changes: 1 addition & 1 deletion src/renderer/patches/windowsTitleBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Settings } from "renderer/settings";

import { addPatch } from "./shared";

if (Settings.store.discordWindowsTitleBar)
if (Settings.store.customTitleBar)
addPatch({
patches: [
{
Expand Down
5 changes: 4 additions & 1 deletion src/shared/settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ export interface Settings {
hardwareAcceleration?: boolean;
arRPC?: boolean;
appBadge?: boolean;
discordWindowsTitleBar?: boolean;
disableMinSize?: boolean;

/** @deprecated use customTitleBar */
discordWindowsTitleBar?: boolean;
customTitleBar?: boolean;

checkUpdates?: boolean;

splashTheming?: boolean;
Expand Down

0 comments on commit 2e4c834

Please sign in to comment.