mod app;
mod device;
mod library;
mod text_menu;
use eframe::egui;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum BackendChoice {
X11,
NativeWayland,
}
fn select_backend(podlib_wayland: Option<&str>) -> BackendChoice {
match podlib_wayland {
Some("1") | Some("true") => BackendChoice::NativeWayland,
_ => BackendChoice::X11,
}
}
fn main() -> eframe::Result {
match select_backend(std::env::var("PODLIB_WAYLAND").ok().as_deref()) {
BackendChoice::NativeWayland => {
eprintln!(
"[backend] PODLIB_WAYLAND=1: Wayland backend requested — drag-and-drop will be unavailable (winit 0.30 implements file drag-and-drop on X11 only)"
);
}
BackendChoice::X11 => {
std::env::remove_var("WAYLAND_DISPLAY");
std::env::remove_var("WAYLAND_SOCKET");
}
}
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_inner_size([1100.0, 700.0])
.with_drag_and_drop(true),
..Default::default()
};
eframe::run_native(
"podlib",
options,
Box::new(|cc| Ok(Box::new(app::PodlibApp::new(cc.egui_ctx.clone())))),
)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn wayland_opt_out_requires_exact_1_or_true() {
for not_set in [None, Some(""), Some("0"), Some("yes"), Some("1 "), Some(" true")] {
assert_eq!(select_backend(not_set), BackendChoice::X11);
}
assert_eq!(select_backend(Some("1")), BackendChoice::NativeWayland);
assert_eq!(select_backend(Some("true")), BackendChoice::NativeWayland);
}
}