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
@@ -33,6 +33,20 @@ pub(all) enum CompositorEvent {
|
||||
/// xdg_surface.set_window_geometry on a popup: (id, x, y) of the visible menu inside its
|
||||
/// buffer. The positioner places that point, so the buffer is drawn this much up/left.
|
||||
PopupGeometry(UInt64, Int, Int)
|
||||
/// A wl_subsurface of a window committed or moved: (window, child wl_surface id, x, y, buffer)
|
||||
/// with (x, y) relative to the window's surface (nested subsurfaces added up). The buffer is
|
||||
/// None when only the position changed. Chrome draws its toolbar bubbles (bookmark star,
|
||||
/// downloads, extensions) this way.
|
||||
SubsurfaceCommitted(UInt64, UInt, Int, Int, @scene.ShmBufferSnapshot?)
|
||||
/// The subsurface was unmapped (null buffer) or destroyed: (window, child wl_surface id).
|
||||
SubsurfaceUnmapped(UInt64, UInt)
|
||||
}
|
||||
|
||||
///| wl_subsurface state, keyed by the child wl_surface id.
|
||||
struct SubState {
|
||||
parent : UInt
|
||||
mut x : Int
|
||||
mut y : Int
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -64,7 +78,7 @@ enum ObjKind {
|
||||
/// wl_output with the version the client bound (done and scale are since version 2).
|
||||
ObjOutput(UInt)
|
||||
ObjSubcompositor
|
||||
ObjSubsurface
|
||||
ObjSubsurface(UInt)
|
||||
ObjDataManager
|
||||
ObjDataSource
|
||||
ObjDataDevice
|
||||
@@ -104,6 +118,8 @@ struct SurfaceState {
|
||||
mut window_id : UInt64?
|
||||
/// wl_surface.set_buffer_scale: the buffer is this many times the window's size.
|
||||
mut buffer_scale : Int
|
||||
/// The pending attach is a null buffer (the surface is being unmapped).
|
||||
mut attached_null : Bool
|
||||
/// org_kde_kwin_server_decoration mode Server: Chandra draws this window's frame (GTK 3 apps
|
||||
/// without their own header bar, like Webby).
|
||||
mut kde_ssd : Bool
|
||||
@@ -182,6 +198,7 @@ struct ClientConn {
|
||||
shm_pools : Map[UInt, ShmPoolState]
|
||||
shm_buffers : Map[UInt, ShmBufferState]
|
||||
xdg_surfaces : Map[UInt, XdgSurfaceState]
|
||||
subsurfaces : Map[UInt, SubState]
|
||||
toplevels : Map[UInt64, ToplevelState]
|
||||
positioners : Map[UInt, PosState]
|
||||
pointer_ids : Array[UInt]
|
||||
@@ -212,6 +229,7 @@ fn ClientConn::new(client_id : UInt, fd : Int) -> ClientConn {
|
||||
shm_pools: {},
|
||||
shm_buffers: {},
|
||||
xdg_surfaces: {},
|
||||
subsurfaces: {},
|
||||
toplevels: {},
|
||||
positioners: {},
|
||||
pointer_ids: [],
|
||||
@@ -606,6 +624,7 @@ fn WaylandServer::dispatch_msg(
|
||||
window_id: None,
|
||||
buffer_scale: 1,
|
||||
kde_ssd: false,
|
||||
attached_null: false,
|
||||
})
|
||||
} else if opcode == 1U {
|
||||
let rid = reader.u32()
|
||||
@@ -617,6 +636,12 @@ fn WaylandServer::dispatch_msg(
|
||||
Some(surf) =>
|
||||
if opcode == 0U {
|
||||
// destroy
|
||||
if c.subsurfaces.contains(sid) {
|
||||
match sub_root(c, sid) {
|
||||
Some((wid, _, _)) => events.push(SubsurfaceUnmapped(wid, sid))
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
c.surfaces.remove(sid)
|
||||
c.objects.remove(sid)
|
||||
send_delete_id(c, sid)
|
||||
@@ -625,6 +650,7 @@ fn WaylandServer::dispatch_msg(
|
||||
let buf_id = reader.u32()
|
||||
let _x = reader.i32()
|
||||
let _y = reader.i32()
|
||||
surf.attached_null = buf_id == 0U
|
||||
surf.attached_buffer = if buf_id == 0U {
|
||||
None
|
||||
} else {
|
||||
@@ -640,6 +666,25 @@ fn WaylandServer::dispatch_msg(
|
||||
surf.buffer_scale = if sc > 0 { sc } else { 1 }
|
||||
} else if opcode == 6U {
|
||||
// commit
|
||||
if surf.window_id is None && c.subsurfaces.contains(sid) {
|
||||
match sub_root(c, sid) {
|
||||
Some((wid, ax, ay)) =>
|
||||
if surf.attached_null {
|
||||
events.push(SubsurfaceUnmapped(wid, sid))
|
||||
} else {
|
||||
match surf.attached_buffer {
|
||||
Some(bid) =>
|
||||
match snapshot_shm_buffer(c, bid) {
|
||||
Some(snap) => events.push(SubsurfaceCommitted(wid, sid, ax, ay, Some(snap)))
|
||||
None => ()
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
surf.attached_null = false
|
||||
match surf.window_id {
|
||||
Some(wid) =>
|
||||
match c.toplevels.get(wid) {
|
||||
@@ -722,9 +767,12 @@ fn WaylandServer::dispatch_msg(
|
||||
c.objects.remove(obj_id)
|
||||
send_delete_id(c, obj_id)
|
||||
} else if opcode == 1U {
|
||||
// get_subsurface(id: new_id, surface, parent): accepted, not composited yet
|
||||
// get_subsurface(id: new_id, surface, parent)
|
||||
let sub_id = reader.u32()
|
||||
c.objects.set(sub_id, ObjSubsurface)
|
||||
let child = reader.u32()
|
||||
let parent = reader.u32()
|
||||
c.objects.set(sub_id, ObjSubsurface(child))
|
||||
c.subsurfaces.set(child, { parent, x: 0, y: 0 })
|
||||
}
|
||||
ObjDataManager =>
|
||||
if opcode == 0U {
|
||||
@@ -836,10 +884,30 @@ fn WaylandServer::dispatch_msg(
|
||||
let _serial = reader.u32()
|
||||
c.cursor_shape = reader.u32()
|
||||
}
|
||||
ObjSubsurface =>
|
||||
ObjSubsurface(child) =>
|
||||
if opcode == 0U {
|
||||
match sub_root(c, child) {
|
||||
Some((wid, _, _)) => events.push(SubsurfaceUnmapped(wid, child))
|
||||
None => ()
|
||||
}
|
||||
c.subsurfaces.remove(child)
|
||||
c.objects.remove(obj_id)
|
||||
send_delete_id(c, obj_id)
|
||||
} else if opcode == 1U {
|
||||
// set_position(x, y): taken at once (the parent's next commit would apply it).
|
||||
let x = reader.i32()
|
||||
let y = reader.i32()
|
||||
match c.subsurfaces.get(child) {
|
||||
Some(st) => {
|
||||
st.x = x
|
||||
st.y = y
|
||||
match sub_root(c, child) {
|
||||
Some((wid, ax, ay)) => events.push(SubsurfaceCommitted(wid, child, ax, ay, None))
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
ObjShm =>
|
||||
if opcode == 0U {
|
||||
@@ -1667,14 +1735,15 @@ fn fixed(v : Double) -> Int {
|
||||
}
|
||||
|
||||
///| wl_pointer.enter at surface-local (x, y).
|
||||
pub fn WaylandServer::pointer_enter(self : WaylandServer, win_id : UInt64, x : Double, y : Double) -> Unit {
|
||||
///| `sub`: the window's subsurface (its wl_surface id) under the pointer, 0 for the window itself.
|
||||
pub fn WaylandServer::pointer_enter(self : WaylandServer, win_id : UInt64, x : Double, y : Double, sub? : UInt = 0U) -> Unit {
|
||||
match self.win_client(win_id) {
|
||||
None => ()
|
||||
Some((c, tl)) =>
|
||||
for pid in c.pointer_ids {
|
||||
let w = WireWriter::new()
|
||||
w.u32(self.next_serial())
|
||||
w.u32(tl.wl_surface_id)
|
||||
w.u32(if sub != 0U && c.surfaces.contains(sub) { sub } else { tl.wl_surface_id })
|
||||
w.i32(fixed(x))
|
||||
w.i32(fixed(y))
|
||||
c.send_msg(w.finish_msg(pid, 0U))
|
||||
@@ -1684,14 +1753,17 @@ pub fn WaylandServer::pointer_enter(self : WaylandServer, win_id : UInt64, x : D
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn WaylandServer::pointer_leave(self : WaylandServer, win_id : UInt64) -> Unit {
|
||||
pub fn WaylandServer::pointer_leave(self : WaylandServer, win_id : UInt64, sub? : UInt = 0U) -> Unit {
|
||||
match self.win_client(win_id) {
|
||||
None => ()
|
||||
Some((c, tl)) =>
|
||||
for pid in c.pointer_ids {
|
||||
if sub != 0U && !c.surfaces.contains(sub) {
|
||||
continue // the subsurface is gone: nothing to leave
|
||||
}
|
||||
let w = WireWriter::new()
|
||||
w.u32(self.next_serial())
|
||||
w.u32(tl.wl_surface_id)
|
||||
w.u32(if sub != 0U { sub } else { tl.wl_surface_id })
|
||||
c.send_msg(w.finish_msg(pid, 1U))
|
||||
self.pointer_frame(c, pid)
|
||||
}
|
||||
@@ -2117,3 +2189,26 @@ pub fn WaylandServer::pump_transfers(self : WaylandServer) -> Unit {
|
||||
pub fn WaylandServer::pending_transfers(self : WaylandServer) -> Int {
|
||||
self.transfers.length()
|
||||
}
|
||||
|
||||
///| The window a subsurface belongs to, and its position relative to that window's surface
|
||||
/// (nested subsurfaces added up). None while it hangs off a surface with no window yet.
|
||||
fn sub_root(c : ClientConn, child : UInt) -> (UInt64, Int, Int)? {
|
||||
let mut x = 0
|
||||
let mut y = 0
|
||||
let mut cur = child
|
||||
for _depth = 0; _depth < 16; _depth = _depth + 1 {
|
||||
match c.subsurfaces.get(cur) {
|
||||
Some(st) => {
|
||||
x = x + st.x
|
||||
y = y + st.y
|
||||
cur = st.parent
|
||||
}
|
||||
None =>
|
||||
return match c.surfaces.get(cur) {
|
||||
Some({ window_id: Some(wid), .. }) => Some((wid, x, y))
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
Reference in new issue
Block a user