2018-05-07 17:56:38 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate glium;
|
|
|
|
extern crate rand;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate slog;
|
|
|
|
extern crate slog_async;
|
|
|
|
extern crate slog_term;
|
|
|
|
#[macro_use(define_roles)]
|
|
|
|
extern crate smithay;
|
|
|
|
extern crate xkbcommon;
|
|
|
|
|
|
|
|
use slog::Drain;
|
|
|
|
use smithay::wayland_server::Display;
|
|
|
|
|
|
|
|
mod glium_drawer;
|
2018-05-13 12:35:27 +00:00
|
|
|
mod input_handler;
|
|
|
|
#[cfg(feature = "tty_launch")]
|
|
|
|
mod raw_drm;
|
2018-05-07 17:56:38 +00:00
|
|
|
mod shell;
|
2018-05-13 12:35:27 +00:00
|
|
|
mod shm_load;
|
2018-05-08 17:39:38 +00:00
|
|
|
#[cfg(feature = "udev")]
|
2018-05-07 17:56:38 +00:00
|
|
|
mod udev;
|
|
|
|
mod window_map;
|
|
|
|
#[cfg(feature = "winit")]
|
|
|
|
mod winit;
|
2018-05-08 10:47:09 +00:00
|
|
|
|
|
|
|
static POSSIBLE_BACKENDS: &'static [&'static str] = &[
|
|
|
|
#[cfg(feature = "winit")]
|
2018-05-08 17:39:38 +00:00
|
|
|
"--winit : Run anvil as a X11 or Wayland client using winit.",
|
2018-05-08 10:47:09 +00:00
|
|
|
#[cfg(feature = "tty_launch")]
|
2018-05-08 17:39:38 +00:00
|
|
|
"--tty-raw : Run anvil as a raw DRM client (requires root).",
|
|
|
|
#[cfg(feature = "udev")]
|
|
|
|
"--tty-udev : Run anvil as a tty udev client (requires root if without logind).",
|
2018-05-08 10:47:09 +00:00
|
|
|
];
|
2018-05-07 17:56:38 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// A logger facility, here we use the terminal here
|
|
|
|
let log = slog::Logger::root(
|
|
|
|
slog_async::Async::default(slog_term::term_full().fuse()).fuse(),
|
|
|
|
o!(),
|
|
|
|
);
|
|
|
|
|
|
|
|
let (mut display, mut event_loop) = Display::new();
|
|
|
|
|
2018-05-08 10:47:09 +00:00
|
|
|
let arg = ::std::env::args().skip(1).next();
|
|
|
|
match arg.as_ref().map(|s| &s[..]) {
|
|
|
|
#[cfg(feature = "winit")]
|
|
|
|
Some("--winit") => {
|
|
|
|
info!(log, "Starting anvil with winit backend");
|
|
|
|
if let Err(()) = winit::run_winit(&mut display, &mut event_loop, log.clone()) {
|
|
|
|
crit!(log, "Failed to initialize winit backend.");
|
|
|
|
}
|
2018-05-07 17:56:38 +00:00
|
|
|
}
|
2018-05-08 10:47:09 +00:00
|
|
|
#[cfg(feature = "tty_launch")]
|
2018-05-08 17:39:38 +00:00
|
|
|
Some("--tty-raw") => {
|
|
|
|
info!(log, "Starting anvil on a tty using raw DRM");
|
|
|
|
if let Err(()) = raw_drm::run_raw_drm(display, event_loop, log.clone()) {
|
|
|
|
crit!(log, "Failed to initialize tty backend.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#[cfg(feature = "udev")]
|
|
|
|
Some("--tty-udev") => {
|
|
|
|
info!(log, "Starting anvil on a tty using udev");
|
2018-05-08 10:47:09 +00:00
|
|
|
if let Err(()) = udev::run_udev(display, event_loop, log.clone()) {
|
|
|
|
crit!(log, "Failed to initialize tty backend.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
println!("USAGE: anvil --backend");
|
|
|
|
println!("");
|
|
|
|
println!("Possible backends are:");
|
|
|
|
for b in POSSIBLE_BACKENDS {
|
|
|
|
println!("\t{}", b);
|
|
|
|
}
|
2018-05-07 17:56:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|