Skip to content

Commit

Permalink
Ensure that DISPLAY vars are non-empty before using
Browse files Browse the repository at this point in the history
It's common to disable Wayland by `WAYLAND_DISPLAY= <application>`.
  • Loading branch information
kchibisov committed Oct 21, 2023
1 parent 837dac9 commit 7a23c5c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/platform_impl/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,16 @@ impl<T: 'static> EventLoop<T> {
);
}

// 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,
Expand Down

0 comments on commit 7a23c5c

Please sign in to comment.