1
0
Fork 0
forked from wry/wry

it: test cursor-shape protocol

This commit is contained in:
Julian Orth 2024-04-02 20:06:13 +02:00
parent 9c8131e145
commit 6448a14fb1
10 changed files with 154 additions and 2 deletions

View file

@ -0,0 +1,51 @@
use {
crate::{
it::{
test_error::TestResult,
test_ifs::{
test_cursor_shape_device::TestCursorShapeDevice, test_pointer::TestPointer,
},
test_object::TestObject,
test_transport::TestTransport,
},
wire::{wp_cursor_shape_manager_v1::*, WpCursorShapeManagerV1Id},
},
std::{cell::Cell, rc::Rc},
};
pub struct TestCursorShapeManager {
pub id: WpCursorShapeManagerV1Id,
pub tran: Rc<TestTransport>,
pub destroyed: Cell<bool>,
}
impl TestCursorShapeManager {
#[allow(dead_code)]
pub fn destroy(&self) -> TestResult {
if !self.destroyed.replace(true) {
self.tran.send(Destroy { self_id: self.id })?;
}
Ok(())
}
pub fn get_pointer(&self, pointer: &TestPointer) -> TestResult<Rc<TestCursorShapeDevice>> {
let obj = Rc::new(TestCursorShapeDevice {
id: self.tran.id(),
tran: self.tran.clone(),
destroyed: Cell::new(false),
});
self.tran.send(GetPointer {
self_id: self.id,
cursor_shape_device: obj.id,
pointer: pointer.id,
})?;
self.tran.add_obj(obj.clone())?;
Ok(obj)
}
}
test_object! {
TestCursorShapeManager, WpCursorShapeManagerV1;
}
impl TestObject for TestCursorShapeManager {}