smithay/anvil/src/main.rs

68 lines
1.9 KiB
Rust
Raw Normal View History

2018-12-15 20:58:43 +00:00
#![warn(rust_2018_idioms)]
#[macro_use]
extern crate glium;
#[macro_use]
extern crate slog;
#[macro_use(define_roles)]
extern crate smithay;
use slog::Drain;
2018-12-15 20:58:43 +00:00
use smithay::reexports::wayland_server::{calloop::EventLoop, Display};
#[macro_use]
mod shaders;
mod glium_drawer;
2018-05-13 12:35:27 +00:00
mod input_handler;
mod shell;
2018-05-13 12:35:27 +00:00
mod shm_load;
2018-05-08 17:39:38 +00:00
#[cfg(feature = "udev")]
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.",
#[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
];
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!(),
);
2018-09-24 22:30:39 +00:00
let mut event_loop = EventLoop::<()>::new().unwrap();
let mut display = Display::new(event_loop.handle());
2018-06-27 12:04:29 +00:00
let arg = ::std::env::args().nth(1);
2018-05-08 10:47:09 +00:00
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-08 17:39:38 +00:00
#[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");
2018-06-27 12:04:29 +00:00
println!();
2018-05-08 10:47:09 +00:00
println!("Possible backends are:");
for b in POSSIBLE_BACKENDS {
println!("\t{}", b);
}
}
}
}