Redo the Wayland checks for Linux (#327)

* Redo the Wayland checks for Linux

* Update the Wayland window decorations comments

* Nit: don't nest if checks, update some comments

* Nit: stricter env var checks

* toLowerCase() on Wayland/Linux string checks

* Use toLowerCase() properly

Co-authored-by: Ven <vendicated@riseup.net>

* Don't use toLowerCase() on XDG_SESSION_TYPE

* Null safety for XDG_SESSION_TYPE and toLowerCase

Co-authored-by: Ven <vendicated@riseup.net>
This commit is contained in:
Oro 2023-01-24 03:29:57 -06:00 committed by GitHub
parent dfe3e2acc8
commit a66f477af6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,21 +25,22 @@ if (!app.requestSingleInstanceLock()) {
} else { } else {
// Your data now belongs to CCP // Your data now belongs to CCP
crashReporter.start({uploadToServer: false}); crashReporter.start({uploadToServer: false});
if (process.env.USE_WAYLAND == "0") { // We use toLowerCase to account for desktops where XDG_SESSION_TYPE might be Wayland and not wayland.
console.log("Wayland patches disabled."); if (process.platform.toLowerCase() === "linux" && process.env.XDG_SESSION_TYPE?.toLowerCase() === "wayland") {
} else { // Just using the native Wayland backend doesn't enable PipeWire capture, we need to enable it explicitly.
if (process.platform == "linux") { app.commandLine.appendSwitch('enable-features', 'WebRTCPipeWireCapturer');
if (process.env.XDG_SESSION_TYPE == "wayland") { console.log("Wayland detected, using PipeWire for video capture.");
console.log("Wayland specific patches applied."); // Some people might want to disable the Wayland backend for one reason or another, such as for Wayland-specific bugs.
app.commandLine.appendSwitch("ozone-platform=wayland"); if (process.env.USE_WAYLAND === "0") {
if (process.env.XDG_CURRENT_DESKTOP == "GNOME") { console.log("Wayland backend disabled.");
app.commandLine.appendSwitch("enable-features=UseOzonePlatform,WaylandWindowDecorations"); } else {
} else { console.log("Using native Wayland, not Xwayland. Disable with USE_WAYLAND=0 if you find issues.");
app.commandLine.appendSwitch("enable-features=UseOzonePlatform"); app.commandLine.appendSwitch('ozone-platform', 'wayland');
} // The Wayland spec doesn't require SSDs, so lets enable self-drawn window decorations.
} // If SSDs are supported on the compositor, Electron will let the compositor handle the decorations.
app.commandLine.appendSwitch('enable-features', 'UseOzonePlatform,WaylandWindowDecorations');
}
} }
}
checkForDataFolder(); checkForDataFolder();
checkIfConfigExists(); checkIfConfigExists();