Subsurfaces are drawn and get the pointer: Chrome's toolbar bubbles work
CI / test (push) Canceled after 14m47s
CI / test (push) Canceled after 14m47s
Chrome draws the bubbles of its toolbar buttons (bookmark star, downloads, extensions) as wl_subsurfaces of the window, not xdg_popups. Chandra accepted wl_subcompositor.get_subsurface but never drew a subsurface or sent it input, so those buttons seemed to do nothing (the bookmark was even added, with no bubble). Menus (xdg_popup) were unaffected. - Server: subsurface state (parent, position) per child surface; a child commit or set_position reports SubsurfaceCommitted(window, child, x, y, buffer) with the position added up to the window's surface, and a null buffer or destroy reports SubsurfaceUnmapped. - Host: HostWindow.subs, drawn above the window as undecorated scene nodes (no change to any renderer); the pointer enters the topmost subsurface under it (ptr_sub) with its own coordinates, so clicks reach the bubble. Checked headless with Chromium 158 on Ozone Wayland, in both frame modes: the star bubble opens and its Remove button works. Test in csd_test.mbt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hkfW5ttNd831XmdsC5
This commit is contained in:
3 files changed
+371
-83
No files matched your search
@@ -320,3 +320,79 @@ test "a maximized GTK window has no resize zones, and restores to its size" {
|
||||
assert_false(comp.windows.get(1UL).unwrap().maximized)
|
||||
assert_eq((after.w, after.h), (before.w, before.h))
|
||||
}
|
||||
|
||||
///| A solid 0xBBGGRR buffer of `w` x `h` in its own pool.
|
||||
fn solid_buffer(c : TestWaylandClient, shm : UInt, w : Int, h : Int, b : Byte, g : Byte, r : Byte) -> UInt {
|
||||
let fd = solid_memfd(w, h, b, g, r)
|
||||
let pool = c.alloc_id()
|
||||
let p = @wayland.WireWriter::new()
|
||||
p.u32(pool)
|
||||
p.i32(w * h * 4)
|
||||
c.send(p.finish_msg(shm, 0U), send_fd=fd)
|
||||
@sys.close_fd(fd)
|
||||
let buf = c.alloc_id()
|
||||
let cb = @wayland.WireWriter::new()
|
||||
cb.u32(buf)
|
||||
cb.i32(0)
|
||||
cb.i32(w)
|
||||
cb.i32(h)
|
||||
cb.i32(w * 4)
|
||||
cb.u32(0U)
|
||||
c.send(cb.finish_msg(pool, 0U))
|
||||
buf
|
||||
}
|
||||
|
||||
///|
|
||||
test "a subsurface (Chrome's toolbar bubbles) is drawn over its window and gets the pointer" {
|
||||
// Chrome draws the bookmark-star, downloads and extensions bubbles as wl_subsurfaces of the
|
||||
// window. Chandra accepted them but never drew them or sent them input: the buttons seemed
|
||||
// to do nothing.
|
||||
let socket_path = "/tmp/wayland-moon-csd-sub-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
comp.set_layout_mode(@wm.LayoutMode::Floating)
|
||||
let (c, shm, surf, xdg, tl, _) = open_and_configure_client(comp, socket_path, "Chrome", "chromium")
|
||||
ignore(answer_configures(comp, c, shm, surf, xdg, tl, fn(w, h, _m) { (w, h) }))
|
||||
// wl_registry is object 2; wl_compositor and wl_subcompositor by name.
|
||||
let comp_id = bind_global(c, 2U, "wl_compositor", 5U)
|
||||
let subc = bind_global(c, 2U, "wl_subcompositor", 1U)
|
||||
let child = c.alloc_id()
|
||||
let cs = @wayland.WireWriter::new()
|
||||
cs.u32(child)
|
||||
c.send(cs.finish_msg(comp_id, 0U))
|
||||
let sub = c.alloc_id()
|
||||
let gs = @wayland.WireWriter::new()
|
||||
gs.u32(sub)
|
||||
gs.u32(child)
|
||||
gs.u32(surf)
|
||||
c.send(gs.finish_msg(subc, 1U))
|
||||
let sp = @wayland.WireWriter::new()
|
||||
sp.i32(100)
|
||||
sp.i32(50)
|
||||
c.send(sp.finish_msg(sub, 1U)) // set_position
|
||||
let buf = solid_buffer(c, shm, 40, 30, b'\xff', b'\x00', b'\x00')
|
||||
attach_commit(comp, c, child, Some(buf))
|
||||
|
||||
let win = comp.windows.get(1UL).unwrap()
|
||||
assert_eq(win.subs.length(), 1)
|
||||
let (ox, oy) = win.surface_origin()
|
||||
let blue = Some(@scene.Rgba::new(0, 0, 0xff, 0xff))
|
||||
assert_eq(comp.compose_frame().pixel(ox + 110, oy + 60), blue)
|
||||
assert_true(comp.compose_frame().pixel(ox + 90, oy + 60) != blue)
|
||||
|
||||
// The pointer over it enters the subsurface, at its own coordinates.
|
||||
comp.handle_input(@nested.InputEvent::PointerMove((ox + 110).to_double(), (oy + 60).to_double()), 10U)
|
||||
assert_eq(comp.ptr_win, Some(1UL))
|
||||
assert_eq(comp.ptr_sub, child)
|
||||
comp.handle_input(@nested.InputEvent::PointerMove((ox + 90).to_double(), (oy + 60).to_double()), 11U)
|
||||
assert_eq(comp.ptr_sub, 0U)
|
||||
|
||||
// A null buffer unmaps it.
|
||||
let a = @wayland.WireWriter::new()
|
||||
a.u32(0U)
|
||||
a.i32(0)
|
||||
a.i32(0)
|
||||
c.send(a.finish_msg(child, 1U))
|
||||
attach_commit(comp, c, child, None)
|
||||
assert_eq(comp.windows.get(1UL).unwrap().subs.length(), 0)
|
||||
assert_true(comp.compose_frame().pixel(ox + 110, oy + 60) != blue)
|
||||
}
|
||||
Reference in new issue
Block a user