Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

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

Dylan M. Taylor52d2936f941d
diff --git a/Cargo.lock b/Cargo.lock
index da9f396292..5ed0a06832 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3068,6 +3068,7 @@ dependencies = [
"serde_json",
"solvecraft-engine",
"solvecraft-ui-egui",
+ "winit",
]
[[package]]
diff --git a/apps/solvecraft/Cargo.toml b/apps/solvecraft/Cargo.toml
index 49895c78b5..cb095c34b4 100644
--- a/apps/solvecraft/Cargo.toml
+++ b/apps/solvecraft/Cargo.toml
@@ -18,3 +18,6 @@ egui = { workspace = true }
serde_json = { workspace = true }
log = { workspace = true }
rfd = { workspace = true }
+
+[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
+winit = { version = "0.30", default-features = false, features = ["x11"] }
diff --git a/apps/solvecraft/src/main.rs b/apps/solvecraft/src/main.rs
index bfbea6a629..934e5e5f40 100644
--- a/apps/solvecraft/src/main.rs
+++ b/apps/solvecraft/src/main.rs
@@ -132,6 +132,17 @@ fn main() -> eframe::Result {
multisampling: samples,
..Default::default()
};
+ let mut options = options;
+ #[cfg(all(unix, not(target_os = "macos")))]
+ // 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; SOLVECRAFT_WAYLAND=1
+ // keeps the native Wayland backend.
+ if std::env::var_os("DISPLAY").is_some() && std::env::var_os("SOLVECRAFT_WAYLAND").is_none() {
+ options.event_loop_builder = Some(Box::new(|b| {
+ use winit::platform::x11::EventLoopBuilderExtX11;
+ b.with_x11();
+ }));
+ }
eframe::run_native(
"SolveCraft",
options,