| 1 | //! High-level wallpaper rendering abstraction |
| 2 | |
| 3 | use anyhow::Result; |
| 4 | use image::RgbaImage; |
| 5 | |
| 6 | use super::Connection; |
| 7 | |
| 8 | /// Wallpaper renderer using X11 pixmaps |
| 9 | pub struct Renderer { |
| 10 | conn: Connection, |
| 11 | } |
| 12 | |
| 13 | impl Renderer { |
| 14 | /// Create a new renderer |
| 15 | pub fn new() -> Result<Self> { |
| 16 | let conn = Connection::new()?; |
| 17 | Ok(Self { conn }) |
| 18 | } |
| 19 | |
| 20 | /// Set a static wallpaper |
| 21 | pub fn set_wallpaper(&mut self, image: &RgbaImage) -> Result<()> { |
| 22 | self.conn.set_wallpaper(image) |
| 23 | } |
| 24 | |
| 25 | /// Get screen dimensions |
| 26 | pub fn screen_dimensions(&self) -> (u16, u16) { |
| 27 | self.conn.screen_dimensions() |
| 28 | } |
| 29 | } |
| 30 |