From 192b72054d977c070a1e8c40ac55570068b994a6 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 4 Oct 2026 11:37:22 -0400 Subject: [PATCH] Linux: use the X11 backend under XWayland so files can be dropped (#2) winit 0.30 has no file drag-and-drop on Wayland. DESIGNCRAFT_WAYLAND=1 keeps the native Wayland backend. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 1 + apps/designcraft/Cargo.toml | 4 ++++ apps/designcraft/src/main.rs | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 60b8c52e..e9e91ac7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -865,6 +865,7 @@ dependencies = [ "muda", "rfd", "serde_json", + "winit", "winresource", ] diff --git a/apps/designcraft/Cargo.toml b/apps/designcraft/Cargo.toml index b7d3a2c3..64971428 100644 --- a/apps/designcraft/Cargo.toml +++ b/apps/designcraft/Cargo.toml @@ -24,5 +24,9 @@ winresource = "0.1" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] rfd = { workspace = true } +[target.'cfg(target_os = "linux")'.dependencies] +# The same winit eframe uses: to pick the X11 backend (file drag-and-drop) in main.rs. +winit = { version = "0.30", default-features = false, features = ["x11"] } + [target.'cfg(target_os = "macos")'.dependencies] muda = { version = "0.21", default-features = false } diff --git a/apps/designcraft/src/main.rs b/apps/designcraft/src/main.rs index 5a577067..35659f2b 100644 --- a/apps/designcraft/src/main.rs +++ b/apps/designcraft/src/main.rs @@ -198,6 +198,16 @@ fn main() -> eframe::Result { if let Some(icon) = app_icon() { options.viewport = options.viewport.with_icon(icon); } + // winit has no file drag-and-drop on Wayland (only on X11), so dropping images from the file + // manager showed a "no" cursor. Run through XWayland when it's there; DESIGNCRAFT_WAYLAND=1 + // keeps the native Wayland backend. + #[cfg(target_os = "linux")] + if std::env::var_os("DISPLAY").is_some() && std::env::var_os("DESIGNCRAFT_WAYLAND").is_none() { + options.event_loop_builder = Some(Box::new(|b| { + use winit::platform::x11::EventLoopBuilderExtX11; + b.with_x11(); + })); + } eframe::run_native( "DesignCraft", options,