wayland: implement alpha_modifier_v1
This commit is contained in:
parent
131f0481e8
commit
ff54a8ab96
37 changed files with 655 additions and 89 deletions
49
src/it/test_ifs/test_alpha_modifier.rs
Normal file
49
src/it/test_ifs/test_alpha_modifier.rs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
use {
|
||||
crate::{
|
||||
it::{
|
||||
test_error::TestResult,
|
||||
test_ifs::{
|
||||
test_alpha_modifier_surface::TestAlphaModifierSurface, test_surface::TestSurface,
|
||||
},
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
},
|
||||
wire::{wp_alpha_modifier_v1::*, WpAlphaModifierV1Id},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
pub struct TestAlphaModifier {
|
||||
pub id: WpAlphaModifierV1Id,
|
||||
pub tran: Rc<TestTransport>,
|
||||
}
|
||||
|
||||
impl TestAlphaModifier {
|
||||
pub fn new(tran: &Rc<TestTransport>) -> Self {
|
||||
Self {
|
||||
id: tran.id(),
|
||||
tran: tran.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_surface(&self, surface: &TestSurface) -> TestResult<Rc<TestAlphaModifierSurface>> {
|
||||
let obj = Rc::new(TestAlphaModifierSurface {
|
||||
id: self.tran.id(),
|
||||
tran: self.tran.clone(),
|
||||
destroyed: Cell::new(false),
|
||||
});
|
||||
self.tran.add_obj(obj.clone())?;
|
||||
self.tran.send(GetSurface {
|
||||
self_id: self.id,
|
||||
id: obj.id,
|
||||
surface: surface.id,
|
||||
})?;
|
||||
Ok(obj)
|
||||
}
|
||||
}
|
||||
|
||||
test_object! {
|
||||
TestAlphaModifier, WpAlphaModifierV1;
|
||||
}
|
||||
|
||||
impl TestObject for TestAlphaModifier {}
|
||||
41
src/it/test_ifs/test_alpha_modifier_surface.rs
Normal file
41
src/it/test_ifs/test_alpha_modifier_surface.rs
Normal 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 {}
|
||||
|
|
@ -5,7 +5,8 @@ use {
|
|||
it::{
|
||||
test_error::TestError,
|
||||
test_ifs::{
|
||||
test_compositor::TestCompositor, test_content_type_manager::TestContentTypeManager,
|
||||
test_alpha_modifier::TestAlphaModifier, test_compositor::TestCompositor,
|
||||
test_content_type_manager::TestContentTypeManager,
|
||||
test_cursor_shape_manager::TestCursorShapeManager,
|
||||
test_data_control_manager::TestDataControlManager,
|
||||
test_data_device_manager::TestDataDeviceManager, test_dmabuf::TestDmabuf,
|
||||
|
|
@ -50,6 +51,7 @@ pub struct TestRegistrySingletons {
|
|||
pub zwlr_data_control_manager_v1: u32,
|
||||
pub zwp_linux_dmabuf_v1: u32,
|
||||
pub xdg_toplevel_drag_manager_v1: u32,
|
||||
pub wp_alpha_modifier_v1: u32,
|
||||
}
|
||||
|
||||
pub struct TestRegistry {
|
||||
|
|
@ -73,6 +75,7 @@ pub struct TestRegistry {
|
|||
pub data_control_manager: CloneCell<Option<Rc<TestDataControlManager>>>,
|
||||
pub dmabuf: CloneCell<Option<Rc<TestDmabuf>>>,
|
||||
pub drag_manager: CloneCell<Option<Rc<TestToplevelDragManager>>>,
|
||||
pub alpha_modifier: CloneCell<Option<Rc<TestAlphaModifier>>>,
|
||||
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
|
||||
}
|
||||
|
||||
|
|
@ -140,6 +143,7 @@ impl TestRegistry {
|
|||
zwlr_data_control_manager_v1,
|
||||
zwp_linux_dmabuf_v1,
|
||||
xdg_toplevel_drag_manager_v1,
|
||||
wp_alpha_modifier_v1,
|
||||
};
|
||||
self.singletons.set(Some(singletons.clone()));
|
||||
Ok(singletons)
|
||||
|
|
@ -227,6 +231,13 @@ impl TestRegistry {
|
|||
1,
|
||||
TestToplevelDragManager
|
||||
);
|
||||
create_singleton!(
|
||||
get_alpha_modifier,
|
||||
alpha_modifier,
|
||||
wp_alpha_modifier_v1,
|
||||
1,
|
||||
TestAlphaModifier
|
||||
);
|
||||
|
||||
pub fn bind<O: TestObject>(
|
||||
&self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue