Chrome's own frame: honor zxdg_toplevel_decoration_v1.set_mode(client_side)
CI / test (push) Successful in 2m18s

Chrome with "Use system title bar and borders" off, and its installed web apps (PWAs), ask
for client-side decoration. Chandra always answered server-side, and Chrome kept drawing its
own title bar and shadow anyway (window geometry 10px in), so Chandra's title bar showed above
Chrome's with Chrome's shadow as a gap. Now a client asking for client_side gets it and is
framed like a GTK window (ToplevelFrame client_side); unset_mode or server_side keep Chandra's
frame. Checked with Chromium 158 on Ozone Wayland, headless. 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:
Claude committed 2026-11-26 02:27:05 +00:00
1 parent 81cb8f9a1c
commit 0a9787ae36
2 files changed
+58 -6

No files matched your search

+20 -6
View File
@@ -141,6 +141,9 @@ struct ToplevelState {
mut cfg_retry : Int
/// The last ToplevelFrame sent (client_side, x, y), None before the first.
mut frame_sent : (Bool, Int, Int)?
/// zxdg_toplevel_decoration_v1.set_mode(client_side): the client wants to draw its own frame
/// (Chrome with "Use system title bar and borders" off) and is told it may.
mut wants_csd : Bool
}
///| xdg_positioner state.
@@ -465,7 +468,7 @@ fn send_delete_id(c : ClientConn, id : UInt) -> Unit {
///|
fn send_decoration_mode(c : ClientConn, deco_id : UInt, mode : UInt) -> Unit {
let w = WireWriter::new()
w.u32(mode) // 2 = ServerSide
w.u32(mode) // 1 = ClientSide, 2 = ServerSide
c.send_msg(w.finish_msg(deco_id, 0U))
}
@@ -655,7 +658,7 @@ fn WaylandServer::dispatch_msg(
Some(xs) => (xs.geo_x, xs.geo_y)
None => (0, 0)
}
let frame = (tl.deco_obj_id is None, gx, gy)
let frame = (tl.deco_obj_id is None || tl.wants_csd, gx, gy)
if tl.frame_sent != Some(frame) {
tl.frame_sent = Some(frame)
events.push(ToplevelFrame(wid, frame.0, gx, gy))
@@ -995,6 +998,7 @@ fn WaylandServer::dispatch_msg(
acked_serial: 0U,
cfg_retry: 0,
frame_sent: None,
wants_csd: false,
})
self.win_to_client.set(wid, c.client_id)
} else if opcode == 2U {
@@ -1048,6 +1052,7 @@ fn WaylandServer::dispatch_msg(
acked_serial: 0U,
cfg_retry: 0,
frame_sent: None,
wants_csd: false,
})
self.win_to_client.set(wid, c.client_id)
// xdg_popup.configure(x, y, w, h) then xdg_surface.configure(serial)
@@ -1205,15 +1210,24 @@ fn WaylandServer::dispatch_msg(
if opcode == 0U {
// Without its decoration object the client goes back to drawing its own frame.
match c.toplevels.get(wid) {
Some(tl) if tl.deco_obj_id == Some(obj_id) => tl.deco_obj_id = None
Some(tl) if tl.deco_obj_id == Some(obj_id) => {
tl.deco_obj_id = None
tl.wants_csd = false
}
_ => ()
}
c.objects.remove(obj_id)
send_delete_id(c, obj_id)
} else if opcode == 1U || opcode == 2U {
// Always enforce Server-Side Decoration (2)
ignore(wid)
send_decoration_mode(c, obj_id, 2U)
// set_mode(mode) / unset_mode. A client asking to draw its own frame gets it: Chrome
// (custom frame) keeps drawing its title bar and shadow even when told server-side,
// which showed both frames. Anything else, and unset_mode, gets Chandra's frame.
let csd = opcode == 1U && reader.u32() == 1U
match c.toplevels.get(wid) {
Some(tl) => tl.wants_csd = csd
None => ()
}
send_decoration_mode(c, obj_id, if csd { 1U } else { 2U })
}
ObjSeat =>
if opcode == 0U {