@@ -29,6 +29,7 @@ import dis from "../../../../../dispatcher/dispatcher";
29
29
import { UserTab } from "../../../dialogs/UserTab" ;
30
30
import { OpenToTabPayload } from "../../../../../dispatcher/payloads/OpenToTabPayload" ;
31
31
import { Action } from "../../../../../dispatcher/actions" ;
32
+ import SdkConfig from "../../../../../SdkConfig" ;
32
33
33
34
interface IProps {
34
35
closeSettingsFn ( success : boolean ) : void ;
@@ -43,6 +44,8 @@ interface IState {
43
44
alwaysShowMenuBar : boolean ;
44
45
minimizeToTraySupported : boolean ;
45
46
minimizeToTray : boolean ;
47
+ togglingHardwareAccelerationSupported : boolean ;
48
+ enableHardwareAcceleration : boolean ;
46
49
autocompleteDelay : string ;
47
50
readMarkerInViewThresholdMs : string ;
48
51
readMarkerOutOfViewThresholdMs : string ;
@@ -117,6 +120,8 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
117
120
alwaysShowMenuBarSupported : false ,
118
121
minimizeToTray : true ,
119
122
minimizeToTraySupported : false ,
123
+ enableHardwareAcceleration : true ,
124
+ togglingHardwareAccelerationSupported : false ,
120
125
autocompleteDelay :
121
126
SettingsStore . getValueAt ( SettingLevel . DEVICE , 'autocompleteDelay' ) . toString ( 10 ) ,
122
127
readMarkerInViewThresholdMs :
@@ -153,6 +158,12 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
153
158
minimizeToTray = await platform . getMinimizeToTrayEnabled ( ) ;
154
159
}
155
160
161
+ const togglingHardwareAccelerationSupported = platform . supportsTogglingHardwareAcceleration ( ) ;
162
+ let enableHardwareAcceleration = true ;
163
+ if ( togglingHardwareAccelerationSupported ) {
164
+ enableHardwareAcceleration = await platform . getHardwareAccelerationEnabled ( ) ;
165
+ }
166
+
156
167
this . setState ( {
157
168
autoLaunch,
158
169
autoLaunchSupported,
@@ -162,6 +173,8 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
162
173
alwaysShowMenuBar,
163
174
minimizeToTraySupported,
164
175
minimizeToTray,
176
+ togglingHardwareAccelerationSupported,
177
+ enableHardwareAcceleration,
165
178
} ) ;
166
179
}
167
180
@@ -181,6 +194,11 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
181
194
PlatformPeg . get ( ) . setMinimizeToTrayEnabled ( checked ) . then ( ( ) => this . setState ( { minimizeToTray : checked } ) ) ;
182
195
} ;
183
196
197
+ private onHardwareAccelerationChange = ( checked : boolean ) => {
198
+ PlatformPeg . get ( ) . setHardwareAccelerationEnabled ( checked ) . then (
199
+ ( ) => this . setState ( { enableHardwareAcceleration : checked } ) ) ;
200
+ } ;
201
+
184
202
private onAutocompleteDelayChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
185
203
this . setState ( { autocompleteDelay : e . target . value } ) ;
186
204
SettingsStore . setValue ( "autocompleteDelay" , null , SettingLevel . DEVICE , e . target . value ) ;
@@ -246,6 +264,17 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
246
264
label = { _t ( 'Show tray icon and minimise window to it on close' ) } /> ;
247
265
}
248
266
267
+ let hardwareAccelerationOption = null ;
268
+ if ( this . state . togglingHardwareAccelerationSupported ) {
269
+ const appName = SdkConfig . get ( ) . brand ;
270
+ hardwareAccelerationOption = < LabelledToggleSwitch
271
+ value = { this . state . enableHardwareAcceleration }
272
+ onChange = { this . onHardwareAccelerationChange }
273
+ label = { _t ( 'Enable hardware acceleration (restart %(appName)s to take effect)' , {
274
+ appName,
275
+ } ) } /> ;
276
+ }
277
+
249
278
return (
250
279
< div className = "mx_SettingsTab mx_PreferencesUserSettingsTab" >
251
280
< div className = "mx_SettingsTab_heading" > { _t ( "Preferences" ) } </ div >
@@ -303,6 +332,7 @@ export default class PreferencesUserSettingsTab extends React.Component<IProps,
303
332
< span className = "mx_SettingsTab_subheading" > { _t ( "General" ) } </ span >
304
333
{ this . renderGroup ( PreferencesUserSettingsTab . GENERAL_SETTINGS ) }
305
334
{ minimizeToTrayOption }
335
+ { hardwareAccelerationOption }
306
336
{ autoHideMenuOption }
307
337
{ autoLaunchOption }
308
338
{ warnBeforeExitOption }
0 commit comments