From 4f9598361f41a9b0a4fb59ae3a55ad3e04612169 Mon Sep 17 00:00:00 2001 From: James Salter Date: Mon, 23 May 2022 11:23:40 +0100 Subject: [PATCH] Add the option to disable hardware acceleration (#8655) --- src/BasePlatform.ts | 12 ++++++++ .../tabs/user/PreferencesUserSettingsTab.tsx | 30 +++++++++++++++++++ src/i18n/strings/en_EN.json | 1 + 3 files changed, 43 insertions(+) diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts index 95f3459763..d1f4ba397a 100644 --- a/src/BasePlatform.ts +++ b/src/BasePlatform.ts @@ -291,6 +291,18 @@ export default abstract class BasePlatform { throw new Error("Unimplemented"); } + public supportsTogglingHardwareAcceleration(): boolean { + return false; + } + + public async getHardwareAccelerationEnabled(): Promise { + return true; + } + + public async setHardwareAccelerationEnabled(enabled: boolean): Promise { + throw new Error("Unimplemented"); + } + /** * Get our platform specific EventIndexManager. * diff --git a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx index 8b3bdeb7fc..64f052b1ac 100644 --- a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.tsx @@ -29,6 +29,7 @@ import dis from "../../../../../dispatcher/dispatcher"; import { UserTab } from "../../../dialogs/UserTab"; import { OpenToTabPayload } from "../../../../../dispatcher/payloads/OpenToTabPayload"; import { Action } from "../../../../../dispatcher/actions"; +import SdkConfig from "../../../../../SdkConfig"; interface IProps { closeSettingsFn(success: boolean): void; @@ -43,6 +44,8 @@ interface IState { alwaysShowMenuBar: boolean; minimizeToTraySupported: boolean; minimizeToTray: boolean; + togglingHardwareAccelerationSupported: boolean; + enableHardwareAcceleration: boolean; autocompleteDelay: string; readMarkerInViewThresholdMs: string; readMarkerOutOfViewThresholdMs: string; @@ -117,6 +120,8 @@ export default class PreferencesUserSettingsTab extends React.Component this.setState({ minimizeToTray: checked })); }; + private onHardwareAccelerationChange = (checked: boolean) => { + PlatformPeg.get().setHardwareAccelerationEnabled(checked).then( + () => this.setState({ enableHardwareAcceleration: checked })); + }; + private onAutocompleteDelayChange = (e: React.ChangeEvent) => { this.setState({ autocompleteDelay: e.target.value }); SettingsStore.setValue("autocompleteDelay", null, SettingLevel.DEVICE, e.target.value); @@ -246,6 +264,17 @@ export default class PreferencesUserSettingsTab extends React.Component; } + let hardwareAccelerationOption = null; + if (this.state.togglingHardwareAccelerationSupported) { + const appName = SdkConfig.get().brand; + hardwareAccelerationOption = ; + } + return (
{ _t("Preferences") }
@@ -303,6 +332,7 @@ export default class PreferencesUserSettingsTab extends React.Component{ _t("General") } { this.renderGroup(PreferencesUserSettingsTab.GENERAL_SETTINGS) } { minimizeToTrayOption } + { hardwareAccelerationOption } { autoHideMenuOption } { autoLaunchOption } { warnBeforeExitOption } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 61aa116da2..86917dbb86 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1500,6 +1500,7 @@ "Warn before quitting": "Warn before quitting", "Always show the window menu bar": "Always show the window menu bar", "Show tray icon and minimise window to it on close": "Show tray icon and minimise window to it on close", + "Enable hardware acceleration (restart %(appName)s to take effect)": "Enable hardware acceleration (restart %(appName)s to take effect)", "Preferences": "Preferences", "Room list": "Room list", "Keyboard shortcuts": "Keyboard shortcuts",