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 <noreply@anthropic.com>
This commit is contained in:
parent
a2bbd96f30
commit
192b72054d
|
|
@ -865,6 +865,7 @@ dependencies = [
|
||||||
"muda",
|
"muda",
|
||||||
"rfd",
|
"rfd",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"winit",
|
||||||
"winresource",
|
"winresource",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,9 @@ winresource = "0.1"
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
rfd = { workspace = true }
|
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]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
muda = { version = "0.21", default-features = false }
|
muda = { version = "0.21", default-features = false }
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,16 @@ fn main() -> eframe::Result {
|
||||||
if let Some(icon) = app_icon() {
|
if let Some(icon) = app_icon() {
|
||||||
options.viewport = options.viewport.with_icon(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(
|
eframe::run_native(
|
||||||
"DesignCraft",
|
"DesignCraft",
|
||||||
options,
|
options,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue