From 7a23c5ca2b6d5266b09deb8e88427783e29c1146 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Thu, 19 Oct 2023 17:03:15 +0400 Subject: [PATCH] Ensure that DISPLAY vars are non-empty before using It's common to disable Wayland by `WAYLAND_DISPLAY= `. --- src/platform_impl/linux/mod.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index 19d1e6a723..f5de3f7c7e 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -752,11 +752,16 @@ impl EventLoop { ); } - // NOTE: Wayland first because of X11 could be present under wayland as well. + // NOTE: Wayland first because of X11 could be present under Wayland as well. Empty + // variables are also treated as not set. let backend = match ( attributes.forced_backend, - env::var("WAYLAND_DISPLAY").is_ok(), - env::var("DISPLAY").is_ok(), + env::var("WAYLAND_DISPLAY") + .map(|var| !var.is_empty()) + .unwrap_or(false), + env::var("DISPLAY") + .map(|var| !var.is_empty()) + .unwrap_or(false), ) { // User is forcing a backend. (Some(backend), _, _) => backend,