Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(dev/linux): select the wayland backend when reachable in the native desktop app (#2899)

omstera1e2bf2c8d7b
diff --git a/fluxer_desktop/src/main/ChromiumRuntime.ts b/fluxer_desktop/src/main/ChromiumRuntime.ts
index 5d76a9783..4adf3ef69 100644
--- a/fluxer_desktop/src/main/ChromiumRuntime.ts
+++ b/fluxer_desktop/src/main/ChromiumRuntime.ts
@@ -292,23 +292,6 @@ export function addLinuxHardwareVideoEncodeFeatures(features: Set<string>): void
features.add('AcceleratedVideoEncoder');
}
-export interface ChromiumCommandLine {
- appendSwitch(name: string, value?: string): void;
- getSwitchValue(name: string): string;
- hasSwitch(name: string): boolean;
-}
-
-export function hasConfiguredOzonePlatformSwitch(commandLine: ChromiumCommandLine = app.commandLine): boolean {
- return commandLine.hasSwitch('ozone-platform') || commandLine.getSwitchValue('ozone-platform').length > 0;
-}
-
-export function appendLinuxOzonePlatformHint(commandLine: ChromiumCommandLine = app.commandLine): void {
- if (process.platform !== 'linux') return;
- if (hasConfiguredOzonePlatformSwitch(commandLine)) return;
- if (commandLine.hasSwitch('ozone-platform-hint')) return;
- commandLine.appendSwitch('ozone-platform-hint', 'auto');
-}
-
export function addWindowsHardwareVideoEncodeFeatures(features: Set<string>): void {
if (process.platform !== 'win32') return;
features.add('WebRtcAV1HWEncode');
diff --git a/fluxer_desktop/src/main/index.ts b/fluxer_desktop/src/main/index.ts
index 5c536cbee..efe0a6f6c 100644
--- a/fluxer_desktop/src/main/index.ts
+++ b/fluxer_desktop/src/main/index.ts
@@ -25,7 +25,6 @@ import {
appendEnabledBlinkFeature,
appendEnabledChromiumFeatures,
appendLinuxChromiumFlagsConfig,
- appendLinuxOzonePlatformHint,
appendWindowsGpuDriverWorkaroundSwitches,
BASE_DISABLED_CHROMIUM_FEATURES,
MIDDLE_CLICK_AUTOSCROLL_BLINK_FEATURE,
@@ -271,7 +270,6 @@ if (launchConfigurationError) {
if (launchDiagnosticOptions.safeMode !== true) {
appendLinuxChromiumFlagsConfig(userDataConfig.channel);
}
- appendLinuxOzonePlatformHint();
if (process.platform === 'win32') {
app.setToastActivatorCLSID(WINDOWS_TOAST_ACTIVATOR_CLSID);
app.setAppUserModelId(WINDOWS_APP_USER_MODEL_ID);
diff --git a/tools/dev/src/desktop.rs b/tools/dev/src/desktop.rs
index 62775a072..d9997253f 100644
--- a/tools/dev/src/desktop.rs
+++ b/tools/dev/src/desktop.rs
@@ -103,10 +103,35 @@ pub fn electron_args(args: &[String]) -> Vec<String> {
{
runtime_args.push("--no-sandbox".to_owned());
}
+ if linux_wayland_session() && !args.iter().any(|arg| arg.starts_with("--ozone-platform")) {
+ runtime_args.push("--ozone-platform=wayland".to_owned());
+ }
runtime_args.extend(args.iter().cloned());
runtime_args
}
+fn linux_wayland_session() -> bool {
+ if !cfg!(target_os = "linux") {
+ return false;
+ }
+ let Some(display) = env::var_os("WAYLAND_DISPLAY") else {
+ return false;
+ };
+ if display.is_empty() {
+ return false;
+ }
+ let display_path = PathBuf::from(&display);
+ let socket = if display_path.is_absolute() {
+ display_path
+ } else {
+ let Some(runtime_dir) = env::var_os("XDG_RUNTIME_DIR") else {
+ return false;
+ };
+ Path::new(&runtime_dir).join(display_path)
+ };
+ socket.exists()
+}
+
pub fn electron_command(args: &[String]) -> Vec<String> {
let mut command = base_electron_command();
command.extend(electron_args(args));