2017-03-07 10:53:57 +00:00
|
|
|
extern crate wayland_server;
|
|
|
|
extern crate smithay;
|
|
|
|
|
|
|
|
use smithay::backend::glutin;
|
2017-03-19 20:56:10 +00:00
|
|
|
use smithay::backend::input::InputBackend;
|
2017-03-20 13:33:27 +00:00
|
|
|
use smithay::shm::ShmGlobal;
|
2017-03-07 10:53:57 +00:00
|
|
|
use wayland_server::protocol::wl_shm;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let (_, mut event_loop) = wayland_server::create_display();
|
|
|
|
|
|
|
|
// Insert the ShmGlobal as a handler to your event loop
|
|
|
|
// Here, we specify tha the standard Argb8888 and Xrgb8888 is the only supported.
|
2017-03-20 13:33:27 +00:00
|
|
|
let handler_id =
|
|
|
|
event_loop.add_handler_with_init(ShmGlobal::new(vec![], None /* we don't provide a logger here */));
|
2017-03-07 10:53:57 +00:00
|
|
|
|
|
|
|
// Register this handler to advertise a wl_shm global of version 1
|
2017-03-20 13:33:27 +00:00
|
|
|
let shm_global = event_loop.register_global::<wl_shm::WlShm, ShmGlobal>(handler_id, 1);
|
2017-03-07 10:53:57 +00:00
|
|
|
|
|
|
|
// Retrieve the shm token for later use to access the buffers
|
|
|
|
let shm_token = {
|
|
|
|
let state = event_loop.state();
|
|
|
|
state.get_handler::<ShmGlobal>(handler_id).get_token()
|
|
|
|
};
|
|
|
|
|
|
|
|
// Initialize a simple backend for testing
|
|
|
|
let (mut renderer, mut input) = glutin::init_windowed().unwrap();
|
|
|
|
|
2017-03-20 13:33:27 +00:00
|
|
|
// TODO render stuff
|
2017-03-07 10:53:57 +00:00
|
|
|
|
2017-03-20 13:33:27 +00:00
|
|
|
// TODO put input handling on the event loop
|
2017-03-19 20:56:10 +00:00
|
|
|
input.dispatch_new_events().unwrap();
|
2017-03-07 10:53:57 +00:00
|
|
|
|
2017-03-19 20:56:10 +00:00
|
|
|
event_loop.run().unwrap();
|
2017-03-07 10:53:57 +00:00
|
|
|
}
|