DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Linux: use the X11 backend under XWayland so files can be dropped (#2)
Brandon Thomas192b72054d97
diff --git a/Cargo.lock b/Cargo.lockindex 60b8c52e1..e9e91ac7c 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.tomlindex b7d3a2c37..649714284 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.rsindex 5a577067d..35659f2b8 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,