Linux: default to XWayland for file drag-and-drop on Wayland desktops

This commit is contained in:
Dylan M. Taylor
2026-10-10 09:02:26 -04:00
parent b70ae1741e
commit 0ed5fcd938
3 changed files with 16 additions and 0 deletions
Generated
+1
View File
@@ -2989,6 +2989,7 @@ dependencies = [
"muda",
"rfd",
"serde_json",
"winit",
"winresource",
]
+3
View File
@@ -32,6 +32,9 @@ log = { workspace = true }
# Icon + VERSIONINFO for lightcraft.exe; build.rs only uses it when targeting Windows.
winresource = "0.1"
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
winit = { version = "0.30", default-features = false, features = ["x11"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rfd = { workspace = true }
+12
View File
@@ -754,6 +754,18 @@ fn main() -> eframe::Result {
};
// the app's copy: `log_file` is still named in the message of a start that fails
let app_log_file = log_file.clone();
#[cfg(all(unix, not(target_os = "macos")))]
let mut options = options;
// winit has no file drag-and-drop on Wayland (only on X11), so dropping files from the file
// manager showed a "no" cursor. Run through XWayland when it's there; LIGHTCRAFT_WAYLAND=1
// keeps the native Wayland backend.
#[cfg(all(unix, not(target_os = "macos")))]
if std::env::var_os("DISPLAY").is_some() && std::env::var_os("LIGHTCRAFT_WAYLAND").is_none() {
options.event_loop_builder = Some(Box::new(|b| {
use winit::platform::x11::EventLoopBuilderExtX11;
b.with_x11();
}));
}
let started = eframe::run_native(
"LightCraft",
options,