Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add the option to disable hardware acceleration #8655

Merged
merged 10 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/BasePlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,18 @@ export default abstract class BasePlatform {
throw new Error("Unimplemented");
}

public supportsTogglingHardwareAcceleration(): boolean {
return false;
}

public async getHardwareAccelerationEnabled(): Promise<boolean> {
return true;
}

public async setHardwareAccelerationEnabled(enabled: boolean): Promise<void> {
throw new Error("Unimplemented");
}

/**
* Get our platform specific EventIndexManager.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ interface IState {
alwaysShowMenuBar: boolean;
minimizeToTraySupported: boolean;
minimizeToTray: boolean;
togglingHardwareAccelerationSupported: boolean;
enableHardwareAcceleration: boolean;
autocompleteDelay: string;
readMarkerInViewThresholdMs: string;
readMarkerOutOfViewThresholdMs: string;
Expand Down Expand Up @@ -117,6 +119,8 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
alwaysShowMenuBarSupported: false,
minimizeToTray: true,
minimizeToTraySupported: false,
enableHardwareAcceleration: true,
togglingHardwareAccelerationSupported: false,
autocompleteDelay:
SettingsStore.getValueAt(SettingLevel.DEVICE, 'autocompleteDelay').toString(10),
readMarkerInViewThresholdMs:
Expand Down Expand Up @@ -153,6 +157,12 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
minimizeToTray = await platform.getMinimizeToTrayEnabled();
}

const togglingHardwareAccelerationSupported = platform.supportsTogglingHardwareAcceleration();
let enableHardwareAcceleration = true;
if (togglingHardwareAccelerationSupported) {
enableHardwareAcceleration = await platform.getHardwareAccelerationEnabled();
}

this.setState({
autoLaunch,
autoLaunchSupported,
Expand All @@ -162,6 +172,8 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
alwaysShowMenuBar,
minimizeToTraySupported,
minimizeToTray,
togglingHardwareAccelerationSupported,
enableHardwareAcceleration,
});
}

Expand All @@ -181,6 +193,11 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
PlatformPeg.get().setMinimizeToTrayEnabled(checked).then(() => this.setState({ minimizeToTray: checked }));
};

private onHardwareAccelerationChange = (checked: boolean) => {
PlatformPeg.get().setHardwareAccelerationEnabled(checked).then(
() => this.setState({ enableHardwareAcceleration: checked }));
};

private onAutocompleteDelayChange = (e: React.ChangeEvent<HTMLInputElement>) => {
this.setState({ autocompleteDelay: e.target.value });
SettingsStore.setValue("autocompleteDelay", null, SettingLevel.DEVICE, e.target.value);
Expand Down Expand Up @@ -246,6 +263,14 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
label={_t('Show tray icon and minimise window to it on close')} />;
}

let hardwareAccelerationOption = null;
if (this.state.togglingHardwareAccelerationSupported) {
hardwareAccelerationOption = <LabelledToggleSwitch
value={this.state.enableHardwareAcceleration}
onChange={this.onHardwareAccelerationChange}
label={_t('Enable hardware acceleration (requires restart to take effect)')} />;
}

return (
<div className="mx_SettingsTab mx_PreferencesUserSettingsTab">
<div className="mx_SettingsTab_heading">{ _t("Preferences") }</div>
Expand Down Expand Up @@ -303,6 +328,7 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
<span className="mx_SettingsTab_subheading">{ _t("General") }</span>
{ this.renderGroup(PreferencesUserSettingsTab.GENERAL_SETTINGS) }
{ minimizeToTrayOption }
{ hardwareAccelerationOption }
{ autoHideMenuOption }
{ autoLaunchOption }
{ warnBeforeExitOption }
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 (requires restart to take effect)": "Enable hardware acceleration (requires restart to take effect)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls can we rephrase to:

Enable hardware acceleration (restart Element to take effect)

...to reduce ambiguity.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enable hardware acceleration (restart %(brand)s to take effect)

"Preferences": "Preferences",
"Room list": "Room list",
"Keyboard shortcuts": "Keyboard shortcuts",
Expand Down