use crate::{
DesktopError, FinalCommitOutcome, IconId, IconRenderPlan, IconSnapshot, MonitorInfo,
OverlayRenderOptions, Point, SnapshotFrame,
};
pub trait DesktopBackend: Send + 'static {
fn list_icons(&mut self) -> Result<Vec<IconSnapshot>, DesktopError>;
fn get_flags(&mut self) -> Result<u32, DesktopError>;
fn apply_flags(&mut self, mask: u32, values: u32) -> Result<(), DesktopError>;
fn set_positions(
&mut self,
moves: &[(IconId, Point)],
) -> Result<Vec<IconId>, DesktopError>;
fn list_monitors(&mut self) -> Result<Vec<MonitorInfo>, DesktopError>;
fn desktop_info(&mut self, _icons: &[IconSnapshot]) -> Result<crate::DesktopInfo, DesktopError> {
Err(DesktopError::UnsupportedPlatform)
}
fn begin_overlay_session(
&mut self,
plans: &[IconRenderPlan],
render_options: OverlayRenderOptions,
) -> Result<(), DesktopError>;
fn commit_overlay_frame(
&mut self,
positions: &[(IconId, Point)],
) -> Result<(), DesktopError>;
fn commit_visual_frame(&mut self, frame: &[crate::IconFrame]) -> Result<(), DesktopError> {
let positions: Vec<_> = frame.iter().map(|entry| (entry.id.clone(), entry.position)).collect();
self.commit_overlay_frame(&positions)
}
fn discard_overlay_session(&mut self) {}
fn validate_prepared_session(&mut self) -> Result<(), DesktopError> { Ok(()) }
fn prepare_scene_renderer(&mut self, _canvas: crate::Canvas, _plans: &[IconRenderPlan], _options: OverlayRenderOptions) -> Result<Box<dyn crate::SceneRenderer>, DesktopError> {
Err(DesktopError::UnsupportedPlatform)
}
fn capture_overlay(&mut self, _seconds: f64) -> Result<crate::CapturedFrame, DesktopError> {
Err(DesktopError::UnsupportedPlatform)
}
fn set_real_icons_visible(&mut self, _visible: bool) -> Result<(), DesktopError> {
Err(DesktopError::UnsupportedPlatform)
}
fn poll_overlay_session(&mut self) -> Result<(), DesktopError> {
self.validate_prepared_session()
}
fn finalize_overlay_session(
&mut self,
final_positions: &[(IconId, Point)],
) -> Result<FinalCommitOutcome, DesktopError>;
fn render_overlay_snapshot(
&mut self,
width_px: u32,
height_px: u32,
dpi_scale: f32,
positions: &[(IconId, Point)],
render_options: OverlayRenderOptions,
) -> Result<SnapshotFrame, DesktopError> {
let _ = (width_px, height_px, dpi_scale, positions, render_options);
Err(DesktopError::OverlayUnavailable(
"render_overlay_snapshot is not implemented for this backend".into(),
))
}
}