Account for WAYLAND_SOCKET when detecting Wayland

Fixes #3459.
This commit is contained in:
Kirill Chibisov
2024-02-07 06:41:23 +04:00
parent bd2d2760f0
commit ba6254bc25
2 changed files with 8 additions and 4 deletions

View File

@@ -20,6 +20,7 @@ Unreleased` header.
- On Wayland, fix `Focused(false)` being send when other seats still have window focused. - On Wayland, fix `Focused(false)` being send when other seats still have window focused.
- On Wayland, fix `Window::set_{min,max}_inner_size` not always applied. - On Wayland, fix `Window::set_{min,max}_inner_size` not always applied.
- On Windows, fix inconsistent resizing behavior with multi-monitor setups when repositioning outside the event loop. - On Windows, fix inconsistent resizing behavior with multi-monitor setups when repositioning outside the event loop.
- On Wayland, fix `WAYLAND_SOCKET` not used when detecting platform.
# 0.29.10 # 0.29.10

View File

@@ -757,8 +757,11 @@ impl<T: 'static> EventLoop<T> {
let backend = match ( let backend = match (
attributes.forced_backend, attributes.forced_backend,
env::var("WAYLAND_DISPLAY") env::var("WAYLAND_DISPLAY")
.map(|var| !var.is_empty()) .ok()
.unwrap_or(false), .filter(|var| !var.is_empty())
.or_else(|| env::var("WAYLAND_SOCKET").ok())
.filter(|var| !var.is_empty())
.is_some(),
env::var("DISPLAY") env::var("DISPLAY")
.map(|var| !var.is_empty()) .map(|var| !var.is_empty())
.unwrap_or(false), .unwrap_or(false),
@@ -776,9 +779,9 @@ impl<T: 'static> EventLoop<T> {
let msg = if wayland_display && !cfg!(wayland_platform) { let msg = if wayland_display && !cfg!(wayland_platform) {
"DISPLAY is not set; note: enable the `winit/wayland` feature to support Wayland" "DISPLAY is not set; note: enable the `winit/wayland` feature to support Wayland"
} else if x11_display && !cfg!(x11_platform) { } else if x11_display && !cfg!(x11_platform) {
"WAYLAND_DISPLAY is not set; note: enable the `winit/x11` feature to support X11" "neither WAYLAND_DISPLAY nor WAYLAND_SOCKET is set; note: enable the `winit/x11` feature to support X11"
} else { } else {
"neither WAYLAND_DISPLAY nor DISPLAY is set." "neither WAYLAND_DISPLAY nor WAYLAND_SOCKET nor DISPLAY is set."
}; };
return Err(EventLoopError::Os(os_error!(OsError::Misc(msg)))); return Err(EventLoopError::Os(os_error!(OsError::Misc(msg))));
} }