Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

Linux: default to XWayland for file drag-and-drop on Wayland desktops (#634)

Dylan M. Taylor7d8dd5ae782e
diff --git a/apps/filmcraft/Cargo.toml b/apps/filmcraft/Cargo.toml
index 2cf5669e5..a2e8f1c18 100644
--- a/apps/filmcraft/Cargo.toml
+++ b/apps/filmcraft/Cargo.toml
@@ -54,6 +54,9 @@ objc2 = "0.6"
# Same winit as eframe: macOS event-loop options (no app activation when driven by an agent).
winit = { version = "0.30", default-features = false }
+[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
+winit = { version = "0.30", default-features = false, features = ["x11"] }
+
[target.'cfg(target_os = "linux")'.dependencies]
# Settings ▸ Appearance ▸ Sync with system: the XDG desktop portal's colour scheme. The zbus the
# portal file dialogs (rfd) and accesskit already use.
diff --git a/apps/filmcraft/src/main.rs b/apps/filmcraft/src/main.rs
index ec9d083ce..ccc56f453 100644
--- a/apps/filmcraft/src/main.rs
+++ b/apps/filmcraft/src/main.rs
@@ -442,6 +442,16 @@ fn agent_event_loop(agent: bool) -> Option<eframe::EventLoopBuilderHook> {
b.with_activate_ignoring_other_apps(false);
}));
}
+ // 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; FILMCRAFT_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("FILMCRAFT_WAYLAND").is_none() {
+ return Some(Box::new(|b| {
+ use winit::platform::x11::EventLoopBuilderExtX11;
+ b.with_x11();
+ }));
+ }
let _ = agent;
None
}