Add transparency to linux (#618)

Co-authored-by: smartfridge <37928912+smartfrigde@users.noreply.github.com>
This commit is contained in:
SelfMadeSystem 2024-06-15 04:22:03 -04:00 committed by GitHub
parent d9d24d9473
commit 69c34435f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 31 additions and 3 deletions

View file

@ -15,7 +15,7 @@
"settings-theme-desc1": "ArmCord \"themes\" manage apps behaviour and looks.",
"settings-theme-desc2": "this is how ArmCord looks when you first launch it. It includes recreation of Discord's\n custom titlebar and ArmCord specific styles injected into Discord.",
"settings-theme-desc3": "uses native titlebar of OS you're currently running (e.g Windows 7/10). Functions more\n similar to actual Discord app on Linux.",
"settings-theme-desc4": "transparent window with native titlebar, you need a compatible theme to run this. Windows only.",
"settings-theme-desc4": "transparent window with native titlebar, you need a compatible theme to run this.",
"settings-theme-default": "Default",
"settings-theme-native": "Native",
"settings-theme-transparent": "Transparent",

View file

@ -361,6 +361,7 @@ export function createTransparentWindow(): void {
icon: iconPath,
frame: true,
backgroundColor: "#00000000",
transparent: true,
show: false,
autoHideMenuBar: true,
webPreferences: {

View file

@ -101,6 +101,7 @@ if (!app.requestSingleInstanceLock()) {
"disable-features",
"WinRetrieveSuggestionsOnlyOnDemand,HardwareMediaKeyHandling,MediaSessionService"
);
app.commandLine.appendSwitch("enable-transparent-visuals");
checkForDataFolder();
checkIfConfigExists();
checkIfConfigIsBroken();
@ -113,7 +114,33 @@ if (!app.requestSingleInstanceLock()) {
} else {
iconPath = path.join(import.meta.dirname, "../", "/assets/desktop.png");
}
await init();
async function init(): Promise<void> {
if (getConfig("skipSplash") == false) {
void createSplashWindow(); // REVIEW - Awaiting will hang at start
}
if (firstRun == true) {
setLang(new Intl.DateTimeFormat().resolvedOptions().locale);
await createSetupWindow();
}
switch (getConfig("windowStyle")) {
case "default":
createCustomWindow();
customTitlebar = true;
break;
case "native":
createNativeWindow();
break;
case "transparent":
createTransparentWindow();
break;
default:
createCustomWindow();
customTitlebar = true;
break;
}
}
// Patch for linux bug to insure things are loaded before window creation (fixes transparency on some linux systems)
await new Promise<void>((resolve) => setTimeout(() => (init(), resolve()), 1500));
await installModLoader();
session.fromPartition("some-partition").setPermissionRequestHandler((_webContents, permission, callback) => {
if (permission === "notifications") {

View file

@ -21,7 +21,7 @@
<option value="" disabled selected hidden data-string="settings-theme"></option>
<option value="default" data-string="settings-theme-default"></option>
<option value="native" data-string="settings-theme-native"></option>
<option value="transparent" windows-exclusive data-string="settings-theme-transparent"></option>
<option value="transparent" data-string="settings-theme-transparent"></option>
</select>
<p class="header" data-string="settings-theme"></p>