From 7583d927474da7dd3ffae743c03cefe2558408bd Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sun, 7 Feb 2021 12:49:22 +0100 Subject: [PATCH] set terminus to use built-in graphics by default - fixes #657 --- terminus-core/src/components/appRoot.component.ts | 2 ++ terminus-core/src/services/hostApp.service.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/terminus-core/src/components/appRoot.component.ts b/terminus-core/src/components/appRoot.component.ts index c028b60c..9d64d1bf 100644 --- a/terminus-core/src/components/appRoot.component.ts +++ b/terminus-core/src/components/appRoot.component.ts @@ -142,6 +142,8 @@ export class AppRootComponent { this.touchbar.update() + this.hostApp.useBuiltinGraphics() + config.changed$.subscribe(() => this.updateVibrancy()) this.updateVibrancy() diff --git a/terminus-core/src/services/hostApp.service.ts b/terminus-core/src/services/hostApp.service.ts index d400eb6c..9388e4e0 100644 --- a/terminus-core/src/services/hostApp.service.ts +++ b/terminus-core/src/services/hostApp.service.ts @@ -8,6 +8,10 @@ import { ElectronService } from './electron.service' import { Logger, LogService } from './log.service' import { isWindowsBuild, WIN_BUILD_FLUENT_BG_SUPPORTED } from '../utils' +try { + var wnr = require('windows-native-registry') // eslint-disable-line @typescript-eslint/no-var-requires, no-var +} catch (_) { } + export enum Platform { Linux = 'Linux', macOS = 'macOS', @@ -283,6 +287,16 @@ export class HostAppService { this.electron.ipcRenderer.send('app:register-global-hotkey', specs) } + useBuiltinGraphics () { + const keyPath = 'SOFTWARE\\Microsoft\\DirectX\\UserGpuPreferences' + const valueName = this.electron.app.getPath('exe') + if (this.platform === Platform.Windows) { + if (!wnr.getRegistryValue(wnr.HK.CU, keyPath, valueName)) { + wnr.setRegistryValue(wnr.HK.CU, keyPath, valueName, wnr.REG.SZ, 'GpuPreference=1;') + } + } + } + relaunch (): void { if (this.isPortable) { this.electron.app.relaunch({ execPath: process.env.PORTABLE_EXECUTABLE_FILE })