Linux: run on native Wayland again by default (revert #165) (#2789)

* Linux: run on native Wayland again by default (revert #165)
  
  winit 0.30.13 reported dropped files only on X11. The egui 0.37 migration
  (#2543) pins storytold/winit, whose patch W15 reports file drops through
  a per-seat Wayland data device (rust-windowing/winit#4729), so files
  dragged from the file manager open on native Wayland too. The XWayland
  default is no longer needed.
  
  It also costs a startup crash: winit's X11 backend loads
  libxkbcommon-x11, which the Linux packages don't depend on. Where it's
  missing (a Fedora toolbox, minimal installs), GridCraft panics before the
  window opens: "Library libxkbcommon-x11.so could not be loaded."
  
  Checked on GNOME (Wayland, Fedora 44) with a build of main plus other
  proposed changes, run with GRIDCRAFT_WAYLAND=1 (the path this revert
  makes the default): an .xlsx and a .csv dragged from Files each open as a
  workbook, and the app starts without libxkbcommon-x11 installed.
  
  This reverts commit 6f0e43c21c.
  
  Claude-Session: https://claude.ai/code/session_01Rvu8dWh26U2fsLQMSBQfH8
This commit is contained in:
bmh129 authored and GitHub committed 2026-11-18 16:26:39 +07:00
1 parent 20c5742f79
commit 82c97858df
2 files changed
+1 -14

No files matched your search

-3
View File
@@ -25,9 +25,6 @@ chrono = { workspace = true }
# Icon + VERSIONINFO for gridcraft.exe; build.rs only uses it when the target is Windows.
winresource = "0.1"
[target.'cfg(all(unix, not(any(target_os = "macos", target_os = "linux"))))'.dependencies]
winit = { version = "0.30", default-features = false, features = ["x11"] }
[target.'cfg(target_os = "linux")'.dependencies]
# Retain X11 fallback; draw Wayland client-side controls without bundled title fonts.
winit = { version = "0.30", default-features = false, features = ["x11", "wayland-csd-adwaita-notitle"] }
+1 -11
View File
@@ -358,21 +358,11 @@ fn main() -> eframe::Result<()> {
}
let window_builder = viewport.clone();
let options = eframe::NativeOptions { viewport, ..Default::default() };
#[cfg(unix)]
#[cfg(target_os = "macos")]
let mut options = options;
// Intel Macs: Metal's compiler aborts on wgpu's indirect-validation shaders (see graphics.rs).
#[cfg(target_os = "macos")]
graphics::configure_indirect_validation(&mut options, graphics::skips_indirect_validation(true, cfg!(target_arch = "x86_64")));
// 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; GRIDCRAFT_WAYLAND=1
// keeps the native Wayland backend.
#[cfg(all(unix, not(target_os = "macos")))]
if std::env::var_os("DISPLAY").is_some_and(|d| !d.is_empty()) && std::env::var_os("GRIDCRAFT_WAYLAND").is_none() {
options.event_loop_builder = Some(Box::new(|b| {
use winit::platform::x11::EventLoopBuilderExtX11;
b.with_x11();
}));
}
// Before eframe creates the wgpu instance: Windows starts on DirectX 12, or OpenGL when
// DirectX 12 has no GPU driver, and never touches Vulkan unless asked (see graphics.rs).
#[cfg(target_os = "windows")]