Don't clear DISPLAY/WAYLAND_DISPLAY/WAYLAND_SOCKET on WSL with --session (#2354)

* use winit backend on WSL

* Update src/main.rs

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
This commit is contained in:
ilyx
2025-09-08 12:13:04 -07:00
committed by GitHub
parent 22f629c24b
commit bdee1a6576

View File

@@ -70,20 +70,23 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
if cli.session {
// If we're starting as a session, assume that the intention is to start on a TTY. Remove
// DISPLAY, WAYLAND_DISPLAY or WAYLAND_SOCKET from our environment if they are set, since
// they will cause the winit backend to be selected instead.
if env::var_os("DISPLAY").is_some() {
warn!("running as a session but DISPLAY is set, removing it");
env::remove_var("DISPLAY");
}
if env::var_os("WAYLAND_DISPLAY").is_some() {
warn!("running as a session but WAYLAND_DISPLAY is set, removing it");
env::remove_var("WAYLAND_DISPLAY");
}
if env::var_os("WAYLAND_SOCKET").is_some() {
warn!("running as a session but WAYLAND_SOCKET is set, removing it");
env::remove_var("WAYLAND_SOCKET");
// If we're starting as a session, assume that the intention is to start on a TTY unless
// this is a WSL environment. Remove DISPLAY, WAYLAND_DISPLAY or WAYLAND_SOCKET from our
// environment if they are set, since they will cause the winit backend to be selected
// instead.
if env::var_os("WSL_DISTRO_NAME").is_none() {
if env::var_os("DISPLAY").is_some() {
warn!("running as a session but DISPLAY is set, removing it");
env::remove_var("DISPLAY");
}
if env::var_os("WAYLAND_DISPLAY").is_some() {
warn!("running as a session but WAYLAND_DISPLAY is set, removing it");
env::remove_var("WAYLAND_DISPLAY");
}
if env::var_os("WAYLAND_SOCKET").is_some() {
warn!("running as a session but WAYLAND_SOCKET is set, removing it");
env::remove_var("WAYLAND_SOCKET");
}
}
// Set the current desktop for xdg-desktop-portal.