mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-12 21:48:29 +09:00
feat(dev/linux): select the wayland backend when reachable in the native desktop app (#2899)
Signed-off-by: omstr <[email protected]>
This commit is contained in:
1 parent
82b2f4ec5e
commit
a1e2bf2c8d
3 files changed
+25
-19
No files matched your search
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user