Skip to content

Commit ac2d623

Browse files
authored
Merge branch 'Legcord:dev' into dev
2 parents f3f3d02 + 288cff7 commit ac2d623

File tree

8 files changed

+102
-67
lines changed

8 files changed

+102
-67
lines changed

assets/lang/en-US.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
"settings-theme-desc": "Window style manages what titlebar Legcord uses.",
1616
"settings-theme-default": "Default (Custom)",
1717
"settings-theme-native": "Native",
18-
"settings-theme-transparent": "Transparent",
1918
"settings-theme-overlay": "Overlay",
19+
"settings-transparency": "Transparency",
20+
"settings-transparency-desc": "Set the transparency mode Legcord uses.",
21+
"settings-transparency-universal": "Universal",
22+
"settings-transparency-modern": "Modern (Windows 11 only)",
23+
"settings-theme-transparent": "Transparent",
2024
"settings-audio": "Audio",
2125
"settings-audio-desc": "Select which method Legcord uses to grab audio from your system during screenshare.",
2226
"settings-csp-desc": "Legcord CSP is our system that manages loading custom content loading into the Discord app. Stuff like client mods and themes depend on it. Disable if you want to get rid of mods and custom styles.",

build/icon.icns

286 KB
Binary file not shown.

src/@types/settings.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ export interface Settings {
88
// Only used for external url warning dialog.
99
ignoreProtocolWarning?: boolean;
1010
customIcon: string;
11-
windowStyle: "default" | "native" | "transparent" | "overlay";
11+
windowStyle: "default" | "native" | "overlay";
1212
channel: "stable" | "ptb" | "canary";
1313
audio: "loopback" | "loopbackWithMute";
14+
transparency: "universal" | "modern" | "none";
1415
legcordCSP: boolean;
1516
minimizeToTray: boolean;
1617
multiInstance: boolean;

src/common/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const defaults: Settings = {
1313
audio: "loopbackWithMute",
1414
multiInstance: false,
1515
mods: ["vencord"],
16+
transparency: "none",
1617
spellcheck: true,
1718
hardwareAcceleration: true,
1819
performanceMode: "none",

src/discord/window.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function doAfterDefiningTheWindow(passedWindow: BrowserWindow): void {
5959
void passedWindow.webContents.executeJavaScript(`document.body.setAttribute("isMaximized", "");`);
6060
passedWindow.hide(); // please don't flashbang the user
6161
}
62-
if (getConfig("windowStyle") === "transparent" && process.platform === "win32") {
62+
if (getConfig("transparency") === "modern" && process.platform === "win32") {
6363
passedWindow.setBackgroundMaterial("mica");
6464
if (getConfig("startMinimized") === false) {
6565
passedWindow.show();
@@ -339,15 +339,18 @@ export function createWindow() {
339339
height: 30,
340340
};
341341
break;
342-
case "transparent":
342+
}
343+
switch (getConfig("transparency")) {
344+
case "universal":
343345
browserWindowOptions.backgroundColor = "#00000000";
344-
345-
if (os.platform() === "win32" && os.release().startsWith("10")) {
346-
browserWindowOptions.transparent = true;
347-
} else {
348-
browserWindowOptions.transparent = false;
349-
browserWindowOptions.frame = true;
350-
}
346+
browserWindowOptions.transparent = true;
347+
break;
348+
case "modern":
349+
browserWindowOptions.backgroundColor = "#00000000";
350+
browserWindowOptions.transparent = false;
351+
browserWindowOptions.frame = true;
352+
break;
353+
case "none":
351354
break;
352355
}
353356
const mainWindow = new BrowserWindow(browserWindowOptions);

src/main.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ if (!app.requestSingleInstanceLock() && getConfig("multiInstance") === false) {
6565
// kill if 2nd instance
6666
app.quit();
6767
} else {
68+
app.setAppUserModelId("app.legcord.Legcord");
6869
app.commandLine.appendSwitch("disable-features", "WidgetLayering"); // fix dev tools layers
6970
// Your data now belongs to CCP
7071
crashReporter.start({ uploadToServer: false });
@@ -105,6 +106,9 @@ if (!app.requestSingleInstanceLock() && getConfig("multiInstance") === false) {
105106
if (getConfig("audio") === undefined) setConfig("audio", "loopbackWithMute");
106107
if (getConfig("keybinds") === undefined) setConfig("keybinds", []);
107108
if (getConfig("trayIcon") === "default") setConfig("trayIcon", "dynamic");
109+
if (getConfig("transparency") === undefined) setConfig("transparency", "none");
110+
// @ts-ignore
111+
if (getConfig("windowStyle") === "transparent") setConfig("windowStyle", "default");
108112
if (getConfig("smoothScroll") === false) app.commandLine.appendSwitch("disable-smooth-scrolling");
109113
if (getConfig("autoScroll")) app.commandLine.appendSwitch("enable-blink-features", "MiddleClickAutoscroll");
110114
if (getConfig("disableHttpCache")) app.commandLine.appendSwitch("disable-http-cache");
@@ -128,6 +132,10 @@ if (!app.requestSingleInstanceLock() && getConfig("multiInstance") === false) {
128132
// Approves the permissions request
129133
callback(true);
130134
}
135+
if (permission === "fullscreen") {
136+
// Approves the permissions request
137+
callback(true);
138+
}
131139
});
132140
app.on("activate", () => {
133141
if (BrowserWindow.getAllWindows().length === 0) {

src/screenshare/main.ts

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -33,61 +33,65 @@ function showAudioDialog(): boolean {
3333
}
3434

3535
function registerCustomHandler(): void {
36-
session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {
37-
console.log(request);
38-
void desktopCapturer
39-
.getSources({
40-
types: ["screen", "window"],
41-
})
42-
.then((sources) => {
43-
if (!sources) return callback({});
44-
isDone = false;
45-
console.log(sources);
46-
if (process.platform === "linux" && process.env.XDG_SESSION_TYPE?.toLowerCase() === "wayland") {
47-
console.log("WebRTC Capturer detected, skipping window creation."); //assume webrtc capturer is used
48-
let options: Streams = { video: sources[0] };
49-
if (sources[0] === undefined) return callback({});
50-
if (showAudioDialog() === true) options = { video: sources[0], audio: getConfig("audio") };
51-
callback(options);
52-
} else {
53-
capturerWindow = new BrowserWindow({
54-
width: 800,
55-
height: 600,
56-
title: "Legcord Screenshare",
57-
darkTheme: true,
58-
icon: getConfig("customIcon") ?? path.join(import.meta.dirname, "../", "/assets/desktop.png"),
59-
frame: true,
60-
autoHideMenuBar: true,
61-
webPreferences: {
62-
sandbox: false,
63-
spellcheck: false,
64-
preload: path.join(import.meta.dirname, "screenshare", "preload.mjs"),
65-
},
66-
});
67-
ipcMain.once("selectScreenshareSource", (_event, id: string, name: string, audio: boolean) => {
68-
isDone = true;
69-
console.log(`Audio status: ${audio}`);
70-
capturerWindow.close();
71-
const result = { id, name };
36+
session.defaultSession.setDisplayMediaRequestHandler(
37+
(request, callback) => {
38+
console.log(request);
39+
void desktopCapturer
40+
.getSources({
41+
types: ["screen", "window"],
42+
})
43+
.then((sources) => {
44+
if (!sources) return callback({});
45+
isDone = false;
46+
console.log(sources);
47+
if (process.platform === "linux" && process.env.XDG_SESSION_TYPE?.toLowerCase() === "wayland") {
48+
console.log("WebRTC Capturer detected, skipping window creation."); //assume webrtc capturer is used
7249
let options: Streams = { video: sources[0] };
73-
switch (process.platform) {
74-
case "win32":
75-
case "linux":
76-
options = { video: result };
77-
if (audio) options = { video: result, audio: getConfig("audio") };
78-
callback(options);
79-
break;
80-
default:
81-
callback({ video: result });
82-
}
83-
});
84-
capturerWindow.on("closed", () => {
85-
if (!isDone) callback({});
86-
});
87-
void capturerWindow.loadFile(path.join(import.meta.dirname, "html", "picker.html"));
88-
capturerWindow.webContents.send("getSources", sources);
89-
}
90-
});
91-
});
50+
if (sources[0] === undefined) return callback({});
51+
if (showAudioDialog() === true) options = { video: sources[0], audio: getConfig("audio") };
52+
callback(options);
53+
} else {
54+
capturerWindow = new BrowserWindow({
55+
width: 800,
56+
height: 600,
57+
title: "Legcord Screenshare",
58+
darkTheme: true,
59+
icon:
60+
getConfig("customIcon") ?? path.join(import.meta.dirname, "../", "/assets/desktop.png"),
61+
frame: true,
62+
autoHideMenuBar: true,
63+
webPreferences: {
64+
sandbox: false,
65+
spellcheck: false,
66+
preload: path.join(import.meta.dirname, "screenshare", "preload.mjs"),
67+
},
68+
});
69+
ipcMain.once("selectScreenshareSource", (_event, id: string, name: string, audio: boolean) => {
70+
isDone = true;
71+
console.log(`Audio status: ${audio}`);
72+
capturerWindow.close();
73+
const result = { id, name };
74+
let options: Streams = { video: sources[0] };
75+
switch (process.platform) {
76+
case "win32":
77+
case "linux":
78+
options = { video: result };
79+
if (audio) options = { video: result, audio: getConfig("audio") };
80+
callback(options);
81+
break;
82+
default:
83+
callback({ video: result });
84+
}
85+
});
86+
capturerWindow.on("closed", () => {
87+
if (!isDone) callback({});
88+
});
89+
void capturerWindow.loadFile(path.join(import.meta.dirname, "html", "picker.html"));
90+
capturerWindow.webContents.send("getSources", sources);
91+
}
92+
});
93+
},
94+
{ useSystemPicker: true },
95+
);
9296
}
9397
registerCustomHandler();

src/shelter/settings/pages/SettingsPage.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,25 @@ export function SettingsPage() {
6161
>
6262
<option value="default">{store.i18n["settings-theme-default"]}</option>
6363
<option value="native">{store.i18n["settings-theme-native"]}</option>
64-
<option value="transparent">{store.i18n["settings-theme-transparent"]}</option>
6564
<Show when={window.legcord.platform === "win32"}>
6665
<option value="overlay">{store.i18n["settings-theme-overlay"]}</option>
6766
</Show>
6867
</DropdownItem>
68+
<DropdownItem
69+
value={store.settings.transparency}
70+
onChange={(e) =>
71+
setConfig("transparency", (e.target as HTMLInputElement).value as Settings["transparency"], true)
72+
}
73+
title={store.i18n["settings-transparency"]}
74+
note={store.i18n["settings-transparency-desc"]}
75+
link="https://github.com/Legcord/Legcord/wiki/Transparency-options"
76+
>
77+
<option value="universal">{store.i18n["settings-transparency-universal"]}</option>
78+
<Show when={window.legcord.platform === "win32"}>
79+
<option value="modern">{store.i18n["settings-transparency-modern"]}</option>
80+
</Show>
81+
<option value="none">{store.i18n["settings-none"]}</option>
82+
</DropdownItem>
6983
<DropdownItem
7084
value={store.settings.trayIcon}
7185
onChange={(e) =>

0 commit comments

Comments
 (0)