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