this repo has no description
1import { app, nativeTheme } from "electron";
2
3const enabledFeatures = app.commandLine.getSwitchValue("enable-features").split(",");
4
5moonlightHost.events.on("window-created", function (browserWindow) {
6 if (moonlightHost.getConfigOption<boolean>("nativeFixes", "devtoolsThemeFix") ?? true) {
7 browserWindow.webContents.on("devtools-opened", () => {
8 if (!nativeTheme.shouldUseDarkColors) return;
9 nativeTheme.themeSource = "light";
10 setTimeout(() => {
11 nativeTheme.themeSource = "dark";
12 }, 100);
13 });
14 }
15});
16
17if (moonlightHost.getConfigOption<boolean>("nativeFixes", "disableRendererBackgrounding") ?? true) {
18 // Discord already disables UseEcoQoSForBackgroundProcess and some other
19 // related features
20 app.commandLine.appendSwitch("disable-renderer-backgrounding");
21 app.commandLine.appendSwitch("disable-backgrounding-occluded-windows");
22
23 // already added on Windows, but not on other operating systems
24 app.commandLine.appendSwitch("disable-background-timer-throttling");
25}
26
27if (process.platform === "linux") {
28 if (moonlightHost.getConfigOption<boolean>("nativeFixes", "linuxAutoscroll") ?? false) {
29 app.commandLine.appendSwitch("enable-blink-features", "MiddleClickAutoscroll");
30 }
31
32 if (moonlightHost.getConfigOption<boolean>("nativeFixes", "linuxSpeechDispatcher") ?? true) {
33 app.commandLine.appendSwitch("enable-speech-dispatcher");
34 }
35}
36
37// NOTE: Only tested if this appears on Windows, it should appear on all when
38// hardware acceleration is disabled
39const noAccel = app.commandLine.hasSwitch("disable-gpu-compositing");
40if ((moonlightHost.getConfigOption<boolean>("nativeFixes", "vaapi") ?? true) && !noAccel) {
41 if (process.platform === "linux")
42 // These will eventually be renamed https://source.chromium.org/chromium/chromium/src/+/5482210941a94d70406b8da962426e4faca7fce4
43 enabledFeatures.push("VaapiVideoEncoder", "VaapiVideoDecoder", "VaapiVideoDecodeLinuxGL");
44}
45
46app.commandLine.appendSwitch("enable-features", [...new Set(enabledFeatures)].join(","));