1
0
Fork 0
forked from wry/wry

autocommit 2022-05-02 00:00:45 CEST

This commit is contained in:
Julian Orth 2022-05-02 00:00:45 +02:00
parent 04580c4aeb
commit 552c8a9950
8 changed files with 155 additions and 43 deletions

View file

@ -0,0 +1,48 @@
use {
crate::{
format::ARGB8888,
it::{
test_error::TestError,
test_ifs::{
test_shm_buffer::TestShmBuffer, test_shm_pool::TestShmPool,
test_surface::TestSurface, test_xdg_surface::TestXdgSurface,
test_xdg_toplevel::TestXdgToplevel,
},
},
theme::Color,
utils::clonecell::CloneCell,
},
std::{cell::Cell, rc::Rc},
};
pub struct TestWindow {
pub surface: Rc<TestSurface>,
pub xdg: Rc<TestXdgSurface>,
pub tl: Rc<TestXdgToplevel>,
pub shm: Rc<TestShmPool>,
pub buffer: CloneCell<Rc<TestShmBuffer>>,
pub color: Cell<Color>,
}
impl TestWindow {
pub async fn map(&self) -> Result<(), TestError> {
let width = self.tl.width.get();
let height = self.tl.height.get();
let stride = width * 4;
let size = (stride * height) as usize;
self.shm.resize(size)?;
let buffer = self.shm.create_buffer(0, width, height, stride, ARGB8888)?;
buffer.fill(self.color.get());
self.surface.attach(buffer.id);
self.xdg.ack_configure(self.xdg.last_serial.get());
self.surface.commit();
self.buffer.set(buffer);
self.surface.tran.sync().await;
Ok(())
}
#[allow(dead_code)]
pub fn set_color(&self, r: u8, g: u8, b: u8, a: u8) {
self.color.set(Color::from_rgba_straight(r, g, b, a));
}
}