Files
wayland_server/examples/simple_compd.rs
T

44 lines
1.0 KiB
Rust

// SPDX: GPL-2.0-only
use std::io;
use wayland_server::client::Client;
use wayland_server::display::Display;
use wayland_server::global::{Global, GlobalState};
use wayland_server::interface::{Interface, Output};
use wayland_server::resource::Resource;
struct State {
output_interface: Interface<Output>,
}
impl State {
pub fn new() -> Self {
Self { output_interface: Interface::<Output>::new() }
}
}
impl GlobalState for State {
fn handle_output_bind(&self, client: &Client, _version: u32, id: u32) -> io::Result<()>{
let resource = Resource::new(&client, id, &self.output_interface)?;
Ok(())
}
}
fn main() -> io::Result<()> {
// Creating a compositor State
let state = State::new();
// create a wayland display
let display = Display::new()?;
// get the global registry
let _global = Global::new(&display, state)?;
println!("Running wayland_display on {}", display.get_name());
display.run()?;
// clean-up
drop(display);
Ok(())
}