tree: never focus wl-subsurface surfaces
This commit is contained in:
parent
5afde58086
commit
4584dee160
15 changed files with 150 additions and 35 deletions
|
|
@ -234,6 +234,19 @@ impl Connector for TestConnector {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct TestMouseClick {
|
||||
pub mouse: Rc<TestBackendMouse>,
|
||||
pub button: u32,
|
||||
}
|
||||
|
||||
impl Drop for TestMouseClick {
|
||||
fn drop(&mut self) {
|
||||
self.mouse
|
||||
.common
|
||||
.event(InputEvent::Button(self.button, KeyState::Released));
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TestBackendMouse {
|
||||
pub common: TestInputDeviceCommon,
|
||||
pub transform_matrix: Cell<TransformMatrix>,
|
||||
|
|
@ -252,6 +265,15 @@ impl TestBackendMouse {
|
|||
dy_unaccelerated: Fixed::from_f64(dy),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn click(self: &Rc<Self>, button: u32) -> TestMouseClick {
|
||||
self.common
|
||||
.event(InputEvent::Button(button, KeyState::Pressed));
|
||||
TestMouseClick {
|
||||
mouse: self.clone(),
|
||||
button,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TestBackendKb {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,8 @@ impl TestClient {
|
|||
}
|
||||
|
||||
pub async fn sync(&self) {
|
||||
self.tran.sync().await
|
||||
self.run.sync().await;
|
||||
self.tran.sync().await;
|
||||
}
|
||||
|
||||
pub async fn take_screenshot(&self) -> Result<Vec<u8>, TestError> {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use {
|
|||
ifs::wl_seat::wl_pointer::WlPointer,
|
||||
it::{
|
||||
test_error::TestResult, test_object::TestObject, test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
test_utils::test_expected_event::TEEH, testrun::ParseFull,
|
||||
},
|
||||
utils::{buffd::MsgParser, clonecell::CloneCell},
|
||||
wire::{wl_pointer::*, WlPointerId},
|
||||
|
|
@ -16,6 +16,9 @@ pub struct TestPointer {
|
|||
pub tran: Rc<TestTransport>,
|
||||
pub server: CloneCell<Option<Rc<WlPointer>>>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub leave: TEEH<Leave>,
|
||||
pub enter: TEEH<Enter>,
|
||||
pub motion: TEEH<Motion>,
|
||||
}
|
||||
|
||||
impl TestPointer {
|
||||
|
|
@ -27,17 +30,20 @@ impl TestPointer {
|
|||
}
|
||||
|
||||
fn handle_enter(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Enter::parse_full(parser)?;
|
||||
let ev = Enter::parse_full(parser)?;
|
||||
self.enter.push(ev);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_leave(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Leave::parse_full(parser)?;
|
||||
let ev = Leave::parse_full(parser)?;
|
||||
self.leave.push(ev);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_motion(&self, parser: MsgParser<'_, '_>) -> TestResult {
|
||||
let _ev = Motion::parse_full(parser)?;
|
||||
let ev = Motion::parse_full(parser)?;
|
||||
self.motion.push(ev);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ impl TestSeat {
|
|||
tran: self.tran.clone(),
|
||||
server: Default::default(),
|
||||
destroyed: Default::default(),
|
||||
leave: Rc::new(Default::default()),
|
||||
enter: Rc::new(Default::default()),
|
||||
motion: Rc::new(Default::default()),
|
||||
});
|
||||
self.tran.add_obj(pointer.clone())?;
|
||||
self.tran.sync().await;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
use {
|
||||
crate::{
|
||||
format::ARGB8888,
|
||||
it::{
|
||||
test_error::TestError, test_ifs::test_shm_pool::TestShmPool, test_mem::TestMem,
|
||||
test_object::TestObject, test_transport::TestTransport, testrun::ParseFull,
|
||||
test_error::{TestError, TestResult},
|
||||
test_ifs::{test_shm_buffer::TestShmBuffer, test_shm_pool::TestShmPool},
|
||||
test_mem::TestMem,
|
||||
test_object::TestObject,
|
||||
test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
utils::{buffd::MsgParser, clonecell::CloneCell, copyhashmap::CopyHashMap},
|
||||
wire::{wl_shm::*, WlShmId},
|
||||
|
|
@ -43,6 +48,11 @@ impl TestShm {
|
|||
Ok(pool)
|
||||
}
|
||||
|
||||
pub fn create_buffer(&self, width: i32, height: i32) -> TestResult<Rc<TestShmBuffer>> {
|
||||
let pool = self.create_pool((width * height * 4) as _)?;
|
||||
pool.create_buffer(0, width, height, width * 4, ARGB8888)
|
||||
}
|
||||
|
||||
fn handle_format(&self, parser: MsgParser<'_, '_>) -> Result<(), TestError> {
|
||||
let ev = Format::parse_full(parser)?;
|
||||
self.formats.set(ev.format, ());
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ mod t0008_map_focus;
|
|||
mod t0009_tab_focus;
|
||||
mod t0010_fullscreen_focus;
|
||||
mod t0011_set_keymap;
|
||||
mod t0012_subsurface_focus;
|
||||
|
||||
pub trait TestCase: Sync {
|
||||
fn name(&self) -> &'static str;
|
||||
|
|
@ -66,5 +67,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
|
|||
t0009_tab_focus,
|
||||
t0010_fullscreen_focus,
|
||||
t0011_set_keymap,
|
||||
t0012_subsurface_focus,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
69
src/it/tests/t0012_subsurface_focus.rs
Normal file
69
src/it/tests/t0012_subsurface_focus.rs
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::wl_seat::BTN_LEFT,
|
||||
it::{
|
||||
test_error::{TestErrorExt, TestResult},
|
||||
testrun::TestRun,
|
||||
},
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
testcase!();
|
||||
|
||||
/// Test that clicking on a subsurface keeps the toplevel surface focused
|
||||
async fn test(run: Rc<TestRun>) -> TestResult {
|
||||
let ds = run.create_default_setup().await?;
|
||||
ds.mouse.rel(1.0, 1.0);
|
||||
run.sync().await;
|
||||
|
||||
let client = run.create_client().await?;
|
||||
let cds = client.get_default_seat().await?;
|
||||
|
||||
let window = client.create_window().await?;
|
||||
window.map().await?;
|
||||
window.map().await?;
|
||||
|
||||
let ns = client.comp.create_surface().await?;
|
||||
let nss = client.sub.get_subsurface(ns.id, window.surface.id).await?;
|
||||
nss.set_position(100, 100)?;
|
||||
let buffer = client.shm.create_buffer(100, 100)?;
|
||||
ns.attach(buffer.id)?;
|
||||
|
||||
run.cfg.set_fullscreen(ds.seat.id(), true)?;
|
||||
client.sync().await;
|
||||
window.map().await;
|
||||
|
||||
ds.mouse.rel(-1000.0, -1000.0);
|
||||
|
||||
client.sync().await;
|
||||
|
||||
let motions = cds.pointer.motion.expect()?;
|
||||
let enters = cds.pointer.enter.expect()?;
|
||||
let leaves = cds.pointer.leave.expect()?;
|
||||
|
||||
ds.mouse.rel(150.0, 150.0);
|
||||
|
||||
client.sync().await;
|
||||
|
||||
tassert!(motions.next().is_err());
|
||||
let leave = leaves.next().with_context(|| "leaves")?;
|
||||
tassert_eq!(leave.surface, window.surface.id);
|
||||
let enter = enters.next().with_context(|| "enters")?;
|
||||
tassert_eq!(enter.surface, ns.id);
|
||||
|
||||
tassert!(leaves.next().is_err());
|
||||
tassert!(enters.next().is_err());
|
||||
|
||||
let kenters = cds.kb.enter.expect()?;
|
||||
let kleaves = cds.kb.leave.expect()?;
|
||||
|
||||
ds.mouse.click(BTN_LEFT);
|
||||
|
||||
client.sync().await;
|
||||
|
||||
tassert!(kleaves.next().is_err());
|
||||
tassert!(kenters.next().is_err());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue