1
0
Fork 0
forked from wry/wry

wayland: implement alpha_modifier_v1

This commit is contained in:
Julian Orth 2024-03-18 19:18:30 +01:00
parent 131f0481e8
commit ff54a8ab96
37 changed files with 655 additions and 89 deletions

View file

@ -0,0 +1,41 @@
use {
crate::{
it::{test_error::TestError, test_object::TestObject, test_transport::TestTransport},
wire::{wp_alpha_modifier_surface_v1::*, WpAlphaModifierSurfaceV1Id},
},
std::{cell::Cell, rc::Rc},
};
pub struct TestAlphaModifierSurface {
pub id: WpAlphaModifierSurfaceV1Id,
pub tran: Rc<TestTransport>,
pub destroyed: Cell<bool>,
}
impl TestAlphaModifierSurface {
pub fn destroy(&self) -> Result<(), TestError> {
if !self.destroyed.replace(true) {
self.tran.send(Destroy { self_id: self.id })?;
}
Ok(())
}
pub fn set_multiplier(&self, factor: f64) -> Result<(), TestError> {
self.tran.send(SetMultiplier {
self_id: self.id,
factor: (factor * u32::MAX as f64) as u32,
})
}
}
impl Drop for TestAlphaModifierSurface {
fn drop(&mut self) {
let _ = self.destroy();
}
}
test_object! {
TestAlphaModifierSurface, WpAlphaModifierSurfaceV1;
}
impl TestObject for TestAlphaModifierSurface {}