diff --git a/src/main/ipc.ts b/src/main/ipc.ts index c073c68..c92d905 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -7,6 +7,7 @@ import { app, dialog, ipcMain, session, shell } from "electron"; import { existsSync, readFileSync, watch } from "fs"; import { open, readFile } from "fs/promises"; +import { release } from "os"; import { join } from "path"; import { debounce } from "shared/utils/debounce"; @@ -41,6 +42,10 @@ ipcMain.on(IpcEvents.GET_VERSION, e => { e.returnValue = app.getVersion(); }); +ipcMain.on(IpcEvents.SUPPORTS_WINDOWS_TRANSPARENCY, e => { + e.returnValue = process.platform === "win32" && Number(release().split(".").pop()) >= 22621; +}); + ipcMain.on(IpcEvents.AUTOSTART_ENABLED, e => { e.returnValue = autoStart.isEnabled(); }); diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 4e115a1..5550c6b 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -262,6 +262,15 @@ function createMainWindow() { }, icon: ICON_PATH, frame: VencordSettings.store.frameless !== true, + ...(Settings.store.transparencyOption !== "none" + ? { + backgroundColor: "#00000000", + backgroundMaterial: Settings.store.transparencyOption, + transparent: true + } + : { + transparent: false + }), ...(Settings.store.staticTitle ? { title: "Vencord" } : {}), ...(VencordSettings.store.macosTranslucency ? { diff --git a/src/preload/VencordDesktopNative.ts b/src/preload/VencordDesktopNative.ts index 6f0f402..5d2f724 100644 --- a/src/preload/VencordDesktopNative.ts +++ b/src/preload/VencordDesktopNative.ts @@ -23,7 +23,8 @@ export const VencordDesktopNative = { app: { relaunch: () => invoke(IpcEvents.RELAUNCH), getVersion: () => sendSync(IpcEvents.GET_VERSION), - setBadgeCount: (count: number) => invoke(IpcEvents.SET_BADGE_COUNT, count) + setBadgeCount: (count: number) => invoke(IpcEvents.SET_BADGE_COUNT, count), + supportsWindowsTransparency: () => sendSync(IpcEvents.SUPPORTS_WINDOWS_TRANSPARENCY) }, autostart: { isEnabled: () => sendSync(IpcEvents.AUTOSTART_ENABLED), diff --git a/src/renderer/components/Settings.tsx b/src/renderer/components/Settings.tsx index bf915b0..b5d8c3d 100644 --- a/src/renderer/components/Settings.tsx +++ b/src/renderer/components/Settings.tsx @@ -13,6 +13,7 @@ import { useSettings } from "renderer/settings"; export default function SettingsUi() { const Settings = useSettings(); + const supportsWindowsTransparency = VencordDesktopNative.app.supportsWindowsTransparency(); const { autostart } = VencordDesktopNative; const [autoStartEnabled, setAutoStartEnabled] = useState(autostart.isEnabled()); @@ -46,7 +47,7 @@ export default function SettingsUi() { Vencord Desktop Settings - Discord Branch + Discord Branch (Settings.transparencyOption = v)} + isSelected={v => v === Settings.transparencyOption} + serialize={s => s} + /> + + + + )} + Vencord Location Vencord files are loaded from{" "} diff --git a/src/shared/IpcEvents.ts b/src/shared/IpcEvents.ts index ff129ec..05b342b 100644 --- a/src/shared/IpcEvents.ts +++ b/src/shared/IpcEvents.ts @@ -11,6 +11,7 @@ export const enum IpcEvents { GET_RENDERER_CSS_FILE = "VCD_GET_RENDERER_CSS_FILE", GET_VERSION = "VCD_GET_VERSION", + SUPPORTS_WINDOWS_TRANSPARENCY = "VCD_SUPPORTS_WINDOWS_TRANSPARENCY", RELAUNCH = "VCD_RELAUNCH", CLOSE = "VCD_CLOSE", diff --git a/src/shared/settings.d.ts b/src/shared/settings.d.ts index f2b6ced..2844b6b 100644 --- a/src/shared/settings.d.ts +++ b/src/shared/settings.d.ts @@ -7,6 +7,7 @@ import type { Rectangle } from "electron"; export interface Settings { + transparencyOption?: "none" | "mica" | "tabbed" | "acrylic"; maximized?: boolean; minimized?: boolean; windowBounds?: Rectangle;