Avoid parenting popups to other popups

Fixes #36
This commit is contained in:
Shawn Wallace 2025-04-22 21:39:20 -04:00
parent 2b5288b4b9
commit c31679aa41
3 changed files with 47 additions and 6 deletions

View file

@ -703,6 +703,7 @@ impl TestFixture {
(surface, id)
}
#[track_caller]
fn create_popup(
&mut self,
comp: &Compositor,
@ -746,13 +747,13 @@ impl TestFixture {
surface_data.role
);
let toplevel_xdg = &self
let parent_xdg = &self
.testwl
.get_surface_data(parent_surface)
.unwrap()
.xdg()
.surface;
assert_eq!(&surface_data.popup().parent, toplevel_xdg);
assert_eq!(surface_data.popup().parent.id(), parent_xdg.id());
let pos = &surface_data.popup().positioner_state;
if check_size_and_pos {
@ -2146,6 +2147,43 @@ fn toplevel_size_limits_scaled() {
assert_eq!(toplevel.max_size, Some(testwl::Vec2 { x: 100, y: 100 }));
}
#[test]
fn subpopup_positioning() {
let (mut f, comp) = TestFixture::new_with_compositor();
TestObject::<WlPointer>::from_request(&comp.seat.obj, wl_seat::Request::GetPointer {});
let win_toplevel = unsafe { Window::new(1) };
let (_, id_toplevel) = f.create_toplevel(&comp, win_toplevel);
f.testwl.move_pointer_to(id_toplevel, 0.0, 0.0);
f.run();
let win_popup = unsafe { Window::new(2) };
let (_, id_popup) = f.create_popup(
&comp,
PopupBuilder::new(win_popup, win_toplevel, id_toplevel)
.x(25)
.y(25),
);
f.testwl.move_pointer_to(id_popup, 1.0, 1.0);
f.run();
println!("{:?}", f.satellite.last_hovered);
let win_subpopup = unsafe { Window::new(3) };
f.create_popup(
&comp,
PopupBuilder::new(win_subpopup, win_toplevel, id_toplevel)
.x(50)
.y(50),
);
let dims = f.connection().window(win_subpopup).dims;
assert_eq!(dims.x, 50);
assert_eq!(dims.y, 50);
}
/// See Pointer::handle_event for an explanation.
#[test]
fn popup_pointer_motion_workaround() {}