feat(desktop): add native Wayland toggle on Linux (#11971)

Co-authored-by: Brendan Allan <git@brendonovich.dev>
This commit is contained in:
Israel Araújo de Oliveira
2026-02-09 06:00:35 -03:00
committed by GitHub
parent 94feb811ca
commit 93a11ddedf
9 changed files with 179 additions and 9 deletions

View File

@@ -2,6 +2,9 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
// borrowed from https://github.com/skyline69/balatro-mod-manager
#[cfg(target_os = "linux")]
mod display;
#[cfg(target_os = "linux")]
fn configure_display_backend() -> Option<String> {
use std::env;
@@ -23,12 +26,16 @@ fn configure_display_backend() -> Option<String> {
return None;
}
// Allow users to explicitly keep Wayland if they know their setup is stable.
let allow_wayland = matches!(
env::var("OC_ALLOW_WAYLAND"),
Ok(v) if matches!(v.to_ascii_lowercase().as_str(), "1" | "true" | "yes")
);
let prefer_wayland = display::read_wayland().unwrap_or(false);
let allow_wayland = prefer_wayland
|| matches!(
env::var("OC_ALLOW_WAYLAND"),
Ok(v) if matches!(v.to_ascii_lowercase().as_str(), "1" | "true" | "yes")
);
if allow_wayland {
if prefer_wayland {
return Some("Wayland session detected; using native Wayland from settings".into());
}
return Some("Wayland session detected; respecting OC_ALLOW_WAYLAND=1".into());
}