diff --git a/Cargo.lock b/Cargo.lock index da9f3962..5ed0a068 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 49895c78..cb095c34 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 bfbea6a6..934e5e5f 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,