diff --git a/src/it/test_ifs/test_xdg_toplevel.rs b/src/it/test_ifs/test_xdg_toplevel.rs index ca9ee1e8..5757ad73 100644 --- a/src/it/test_ifs/test_xdg_toplevel.rs +++ b/src/it/test_ifs/test_xdg_toplevel.rs @@ -7,7 +7,7 @@ use { test_transport::TestTransport, testrun::ParseFull, }, - tree::{ContainerNode, ToplevelNodeBase}, + tree::{ContainerNode, ContainingNode, FloatNode, ToplevelNodeBase}, utils::buffd::MsgParser, wire::{xdg_toplevel::*, XdgToplevelId}, }, @@ -36,16 +36,28 @@ pub struct TestXdgToplevel { } impl TestXdgToplevel { - pub fn container_parent(&self) -> TestResult> { - let parent = match self.server.tl_data().parent.get() { - Some(p) => p, + pub fn parent(&self) -> TestResult> { + match self.server.tl_data().parent.get() { + Some(p) => Ok(p), _ => bail!("toplevel has no parent"), - }; + } + } + + pub fn container_parent(&self) -> TestResult> { + let parent = self.parent()?; match parent.node_into_container() { Some(p) => Ok(p), _ => bail!("toplevel parent is not a container"), } } + + pub fn float_parent(&self) -> TestResult> { + let parent = self.parent()?; + match parent.node_into_float() { + Some(p) => Ok(p), + _ => bail!("toplevel parent is not a float"), + } + } } impl TestXdgToplevelCore { diff --git a/src/it/tests.rs b/src/it/tests.rs index 34c2a60b..018ae928 100644 --- a/src/it/tests.rs +++ b/src/it/tests.rs @@ -58,6 +58,7 @@ mod t0024_foreign_toplevel_list; mod t0025_dnd_focus_change; mod t0026_output_transform; mod t0027_input_region; +mod t0028_top_level_restacking; pub trait TestCase: Sync { fn name(&self) -> &'static str; @@ -104,5 +105,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> { t0025_dnd_focus_change, t0026_output_transform, t0027_input_region, + t0028_top_level_restacking, } } diff --git a/src/it/tests/t0028_top_level_restacking.rs b/src/it/tests/t0028_top_level_restacking.rs new file mode 100644 index 00000000..b02fefb2 --- /dev/null +++ b/src/it/tests/t0028_top_level_restacking.rs @@ -0,0 +1,43 @@ +use { + crate::{ + ifs::wl_seat::BTN_LEFT, + it::{test_error::TestResult, testrun::TestRun}, + }, + std::rc::Rc, +}; + +testcase!(); + +async fn test(run: Rc) -> TestResult { + let ds = run.create_default_setup().await?; + + let client = run.create_client().await?; + + let win1 = client.create_window().await?; + win1.set_color(255, 0, 0, 255); + win1.map2().await?; + run.cfg.set_floating(ds.seat.id(), true)?; + + let win2 = client.create_window().await?; + win2.set_color(0, 255, 0, 255); + win2.map2().await?; + run.cfg.set_floating(ds.seat.id(), true)?; + + { + let parent = win1.tl.float_parent()?; + let rect = parent.position.get(); + parent.position.set(rect.at_point(100, 100)); + parent.schedule_layout(); + } + + client.sync().await; + client.compare_screenshot("1", false).await?; + + ds.move_to(110, 110); + ds.mouse.click(BTN_LEFT); + + client.sync().await; + client.compare_screenshot("2", false).await?; + + Ok(()) +} diff --git a/src/it/tests/t0028_top_level_restacking/screenshot_1.qoi b/src/it/tests/t0028_top_level_restacking/screenshot_1.qoi new file mode 100644 index 00000000..f7bf53bf Binary files /dev/null and b/src/it/tests/t0028_top_level_restacking/screenshot_1.qoi differ diff --git a/src/it/tests/t0028_top_level_restacking/screenshot_2.qoi b/src/it/tests/t0028_top_level_restacking/screenshot_2.qoi new file mode 100644 index 00000000..b454acd3 Binary files /dev/null and b/src/it/tests/t0028_top_level_restacking/screenshot_2.qoi differ diff --git a/src/tree/float.rs b/src/tree/float.rs index 6cc692ca..4b8f1a5c 100644 --- a/src/tree/float.rs +++ b/src/tree/float.rs @@ -136,7 +136,7 @@ impl FloatNode { self.schedule_render_titles(); } - fn schedule_layout(self: &Rc) { + pub fn schedule_layout(self: &Rc) { if !self.layout_scheduled.replace(true) { self.state.pending_float_layout.push(self.clone()); }