use std::path::{Path, PathBuf};
use async_trait::async_trait;
use crate::error::Result;
#[async_trait]
pub trait CompositorRuntime: Send + Sync {
async fn start(&mut self) -> Result<()>;
async fn stop(&mut self) -> Result<()>;
fn id(&self) -> &str;
fn wayland_display(&self) -> &str;
fn runtime_dir(&self) -> &Path;
}
#[async_trait]
pub trait InputBackend: Send + Sync {
async fn press_keysym(&self, keysym: u32) -> Result<()>;
async fn pointer_motion_relative(&self, dx: f64, dy: f64) -> Result<()>;
async fn pointer_button(&self, button: u32) -> Result<()>;
}
pub struct PipeWireStream {
pub node_id: u32,
pub token: Box<dyn std::any::Any + Send + Sync>,
}
#[async_trait]
pub trait CaptureBackend: Send + Sync {
async fn start_stream(&self) -> Result<PipeWireStream>;
async fn stop_stream(&self, stream: PipeWireStream) -> Result<()>;
fn pipewire_socket(&self) -> PathBuf;
async fn grab_screenshot(&self, stream: &PipeWireStream) -> Result<Vec<u8>> {
crate::capture::grab_png(stream.node_id, &self.pipewire_socket()).await
}
}