use std::process::exit;
#[cfg(any(target_os = "android", target_os = "linux"))]
mod platform {
use anyhow::Context;
use anyhow::Result;
use gpu_display::*;
use vm_control::gpu::DisplayMode;
use vm_control::gpu::DisplayParameters;
pub fn run() -> Result<()> {
let mut disp = GpuDisplay::open_wayland(None::<&str>).context("open_wayland")?;
let surface_id = disp
.create_surface(
None,
Some(0),
&DisplayParameters::default_with_mode(DisplayMode::Windowed(1280, 1024)),
SurfaceType::Scanout,
)
.context("create_surface")?;
disp.flip(surface_id);
disp.commit(surface_id).context("commit")?;
while !disp.close_requested(surface_id) {
disp.dispatch_events().context("dispatch_events")?;
}
Ok(())
}
}
#[cfg(not(unix))]
mod platform {
use anyhow::anyhow;
use anyhow::Result;
pub fn run() -> Result<()> {
Err(anyhow!("Only supported on unix targets"))
}
}
fn main() {
if let Err(e) = platform::run() {
eprintln!("error: {e:#}");
exit(1);
}
}