1
0
Fork 0
forked from wry/wry

it: add pointer warp test

This commit is contained in:
Julian Orth 2025-09-03 22:38:45 +02:00
parent 47a09af8f4
commit c51ec4456e
8 changed files with 136 additions and 3 deletions

View file

@ -0,0 +1,62 @@
use {
crate::{
fixed::Fixed,
it::{
test_error::TestResult,
test_ifs::{test_pointer::TestPointer, test_surface::TestSurface},
test_object::TestObject,
test_transport::TestTransport,
},
wire::{WpPointerWarpV1Id, wp_pointer_warp_v1::*},
},
std::{cell::Cell, rc::Rc},
};
pub struct TestPointerWarp {
pub id: WpPointerWarpV1Id,
pub tran: Rc<TestTransport>,
pub destroyed: Cell<bool>,
}
impl TestPointerWarp {
pub fn new(tran: &Rc<TestTransport>) -> Self {
Self {
id: tran.id(),
tran: tran.clone(),
destroyed: Cell::new(false),
}
}
#[expect(dead_code)]
pub fn destroy(&self) -> TestResult {
if !self.destroyed.replace(true) {
self.tran.send(Destroy { self_id: self.id })?;
}
Ok(())
}
pub fn warp_pointer(
&self,
surface: &TestSurface,
pointer: &TestPointer,
x: Fixed,
y: Fixed,
serial: u32,
) -> TestResult {
self.tran.send(WarpPointer {
self_id: self.id,
surface: surface.id,
pointer: pointer.id,
x,
y,
serial,
})?;
Ok(())
}
}
test_object! {
TestPointerWarp, WpPointerWarpV1;
}
impl TestObject for TestPointerWarp {}

View file

@ -13,8 +13,8 @@ use {
test_ext_foreign_toplevel_list::TestExtForeignToplevelList,
test_fifo_manager::TestFifoManager,
test_input_method_manager::TestInputMethodManager,
test_jay_compositor::TestJayCompositor, test_shm::TestShm,
test_single_pixel_buffer_manager::TestSinglePixelBufferManager,
test_jay_compositor::TestJayCompositor, test_pointer_warp::TestPointerWarp,
test_shm::TestShm, test_single_pixel_buffer_manager::TestSinglePixelBufferManager,
test_subcompositor::TestSubcompositor, test_syncobj_manager::TestSyncobjManager,
test_text_input_manager::TestTextInputManager,
test_toplevel_drag_manager::TestToplevelDragManager,
@ -62,6 +62,7 @@ pub struct TestRegistrySingletons {
pub zwp_text_input_manager_v3: u32,
pub wl_fixes: u32,
pub wp_fifo_manager_v1: u32,
pub wp_pointer_warp_v1: u32,
}
pub struct TestRegistry {
@ -91,6 +92,7 @@ pub struct TestRegistry {
pub text_input_manager: CloneCell<Option<Rc<TestTextInputManager>>>,
pub wl_fixes: CloneCell<Option<Rc<TestWlFixes>>>,
pub fifo_manager: CloneCell<Option<Rc<TestFifoManager>>>,
pub pointer_warp: CloneCell<Option<Rc<TestPointerWarp>>>,
pub seats: CopyHashMap<GlobalName, Rc<WlSeatGlobal>>,
}
@ -164,6 +166,7 @@ impl TestRegistry {
zwp_text_input_manager_v3,
wl_fixes,
wp_fifo_manager_v1,
wp_pointer_warp_v1,
};
self.singletons.set(Some(singletons.clone()));
Ok(singletons)
@ -287,6 +290,13 @@ impl TestRegistry {
1,
TestFifoManager
);
create_singleton!(
get_pointer_warp,
pointer_warp,
wp_pointer_warp_v1,
1,
TestPointerWarp
);
pub fn bind<O: TestObject>(
&self,