diff --git a/src/main/index.ts b/src/main/index.ts index 5a55f40..c8bd462 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -39,12 +39,14 @@ function init() { if (hardwareAcceleration === false) { app.disableHardwareAcceleration(); } else { - enabledFeatures.add("AcceleratedVideoEncoder"); - enabledFeatures.add("AcceleratedVideoDecoder"); + if (Settings.store.hardwareVideoAcceleration) { + enabledFeatures.add("AcceleratedVideoEncoder"); + enabledFeatures.add("AcceleratedVideoDecoder"); - if (isLinux) { - enabledFeatures.add("AcceleratedVideoDecodeLinuxGL"); - enabledFeatures.add("AcceleratedVideoDecodeLinuxZeroCopyGL"); + if (isLinux) { + enabledFeatures.add("AcceleratedVideoDecodeLinuxGL"); + enabledFeatures.add("AcceleratedVideoDecodeLinuxZeroCopyGL"); + } } } diff --git a/src/renderer/components/settings/AutoStartToggle.tsx b/src/renderer/components/settings/AutoStartToggle.tsx index 2fec7a6..3499170 100644 --- a/src/renderer/components/settings/AutoStartToggle.tsx +++ b/src/renderer/components/settings/AutoStartToggle.tsx @@ -4,15 +4,16 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { Switch, useState } from "@vencord/types/webpack/common"; +import { useState } from "@vencord/types/webpack/common"; import { SettingsComponent } from "./Settings"; +import { VesktopSettingsSwitch } from "./VesktopSettingsSwitch"; export const AutoStartToggle: SettingsComponent = () => { const [autoStartEnabled, setAutoStartEnabled] = useState(VesktopNative.autostart.isEnabled()); return ( - { await VesktopNative.autostart[v ? "enable" : "disable"](); @@ -21,6 +22,6 @@ export const AutoStartToggle: SettingsComponent = () => { note="Automatically start Vesktop on computer start-up" > Start With System - + ); }; diff --git a/src/renderer/components/settings/NotificationBadgeToggle.tsx b/src/renderer/components/settings/NotificationBadgeToggle.tsx index 598bfa7..efc5353 100644 --- a/src/renderer/components/settings/NotificationBadgeToggle.tsx +++ b/src/renderer/components/settings/NotificationBadgeToggle.tsx @@ -4,14 +4,14 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { Switch } from "@vencord/types/webpack/common"; import { setBadge } from "renderer/appBadge"; import { SettingsComponent } from "./Settings"; +import { VesktopSettingsSwitch } from "./VesktopSettingsSwitch"; export const NotificationBadgeToggle: SettingsComponent = ({ settings }) => { return ( - { settings.appBadge = v; @@ -21,6 +21,6 @@ export const NotificationBadgeToggle: SettingsComponent = ({ settings }) => { note="Show mention badge on the app icon" > Notification Badge - + ); }; diff --git a/src/renderer/components/settings/Settings.tsx b/src/renderer/components/settings/Settings.tsx index 7baae7c..24edb4f 100644 --- a/src/renderer/components/settings/Settings.tsx +++ b/src/renderer/components/settings/Settings.tsx @@ -7,7 +7,7 @@ import "./settings.css"; import { ErrorBoundary } from "@vencord/types/components"; -import { Forms, Switch, Text } from "@vencord/types/webpack/common"; +import { Forms, Text } from "@vencord/types/webpack/common"; import { ComponentType } from "react"; import { Settings, useSettings } from "renderer/settings"; import { isMac, isWindows } from "renderer/utils"; @@ -16,6 +16,7 @@ import { AutoStartToggle } from "./AutoStartToggle"; import { DeveloperOptionsButton } from "./DeveloperOptions"; import { DiscordBranchPicker } from "./DiscordBranchPicker"; import { NotificationBadgeToggle } from "./NotificationBadgeToggle"; +import { VesktopSettingsSwitch } from "./VesktopSettingsSwitch"; import { WindowsTransparencyControls } from "./WindowsTransparencyControls"; interface BooleanSetting { @@ -38,6 +39,14 @@ const SettingsOptions: Record> title: "Hardware Acceleration", description: "Enable hardware acceleration", defaultValue: true + }, + { + key: "hardwareVideoAcceleration", + title: "Video Hardware Acceleration", + description: + "Enable hardware video acceleration. This can improve performance of screenshare and video playback, but may cause graphical glitches and infinitely loading streams.", + defaultValue: false, + disabled: () => !Settings.store.hardwareAcceleration } ], "User Interface": [ @@ -132,32 +141,35 @@ const SettingsOptions: Record> function SettingsSections() { const Settings = useSettings(); - const sections = Object.entries(SettingsOptions).map(([title, settings]) => ( - - {settings.map(Setting => { - if (typeof Setting === "function") return ; + const sections = Object.entries(SettingsOptions).map(([title, settings], i, arr) => ( +
+ + {title} + - const { defaultValue, title, description, key, disabled, invisible } = Setting; - if (invisible?.()) return null; +
+ {settings.map(Setting => { + if (typeof Setting === "function") return ; - return ( - (Settings[key as any] = v)} - note={description} - disabled={disabled?.()} - key={key} - > - {title} - - ); - })} - + const { defaultValue, title, description, key, disabled, invisible } = Setting; + if (invisible?.()) return null; + + return ( + (Settings[key as any] = v)} + note={description} + disabled={disabled?.()} + key={key} + > + {title} + + ); + })} +
+ + {i < arr.length - 1 && } +
)); return <>{sections}; @@ -167,10 +179,11 @@ export default ErrorBoundary.wrap( function SettingsUI() { return ( - + {/* FIXME: Outdated type */} + {/* @ts-expect-error Outdated type */} + Vesktop Settings - ); diff --git a/src/renderer/components/settings/VesktopSettingsSwitch.tsx b/src/renderer/components/settings/VesktopSettingsSwitch.tsx new file mode 100644 index 0000000..bd1c2fb --- /dev/null +++ b/src/renderer/components/settings/VesktopSettingsSwitch.tsx @@ -0,0 +1,16 @@ +/* + * Vesktop, a desktop app aiming to give you a snappier Discord Experience + * Copyright (c) 2025 Vendicated and Vesktop contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { Switch } from "@vencord/types/webpack/common"; +import { ComponentProps } from "react"; + +export function VesktopSettingsSwitch(props: ComponentProps) { + return ( + + {props.children} + + ); +} diff --git a/src/renderer/components/settings/WindowsTransparencyControls.tsx b/src/renderer/components/settings/WindowsTransparencyControls.tsx index 14d3f8e..3e864a7 100644 --- a/src/renderer/components/settings/WindowsTransparencyControls.tsx +++ b/src/renderer/components/settings/WindowsTransparencyControls.tsx @@ -13,8 +13,8 @@ export const WindowsTransparencyControls: SettingsComponent = ({ settings }) => if (!VesktopNative.app.supportsWindowsTransparency()) return null; return ( - <> - Transparency Options +
+ Transparency Options Requires a full restart. You will need a theme that supports transparency for this to work. @@ -42,8 +42,6 @@ export const WindowsTransparencyControls: SettingsComponent = ({ settings }) => isSelected={v => v === settings.transparencyOption} serialize={s => s} /> - - - +
); }; diff --git a/src/renderer/components/settings/settings.css b/src/renderer/components/settings/settings.css index 294ecec..5ae9887 100644 --- a/src/renderer/components/settings/settings.css +++ b/src/renderer/components/settings/settings.css @@ -5,10 +5,30 @@ margin-top: 0.5em; } -.vcd-settings-section { - margin-top: 1.5rem; +.vcd-settings-title { + margin-bottom: 32px; } -.vcd-settings-title { - margin-bottom: 0.5rem; +.vcd-settings-category { + display: flex; + flex-direction: column; +} + +.vcd-settings-category-title { + margin-bottom: 16px; +} + +.vcd-settings-category-content { + display: flex; + flex-direction: column; + gap: 24px; +} + +.vcd-settings-category-divider { + margin-top: 32px; + margin-bottom: 32px; +} + +.vcd-settings-switch { + margin-bottom: 0; } \ No newline at end of file diff --git a/src/shared/settings.d.ts b/src/shared/settings.d.ts index 0279aeb..01c26e5 100644 --- a/src/shared/settings.d.ts +++ b/src/shared/settings.d.ts @@ -16,6 +16,7 @@ export interface Settings { enableMenu?: boolean; disableSmoothScroll?: boolean; hardwareAcceleration?: boolean; + hardwareVideoAcceleration?: boolean; arRPC?: boolean; appBadge?: boolean; disableMinSize?: boolean;