Client-drawn window frames: GTK apps (GNOME Files) get no second title bar
CI / test (push) Successful in 2m57s
CI / test (push) Successful in 2m57s
GTK never asks for server-side decoration (it has no xdg-decoration support), so it draws its own header bar plus a transparent shadow margin around it, and says where the real window is with xdg_surface.set_window_geometry. Chandra drew its Breeze frame around every window anyway and blitted the whole buffer from the frame's corner: a second title bar on top, and the content shifted down/right by the shadow (a see-through gap), with the right/bottom cut off. - The server reports per window who draws the frame (ToplevelFrame: client-side when the client never made a zxdg_toplevel_decoration_v1, plus the window-geometry offset). - A client-decorated window gets no Chandra frame and fills the frame's whole box (HostWindow::client_rect): it is configured for that size, drawn with its buffer shifted by the geometry offset (its own shadow drawn around it), and pointer coordinates and popup placement use the same origin. Tiling, title-bar hit areas and resize zones are unchanged. - xdg_toplevel.move / resize (dragging a header bar, a CSD border) start Chandra's move and resize drags; they were ignored before. - Tiled windows get the tiled_left/right/top/bottom states, so GTK drops its shadow and rounded corners there. Checked with real Nautilus 46 and gtk4-demo on the headless native compositor. Tests: compositor/host/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:
5 files changed
+405
-33
No files matched your search
@@ -14,6 +14,14 @@ pub(all) enum CompositorEvent {
|
||||
ToplevelFullscreenRequest(UInt64, Bool)
|
||||
ToplevelMinimizeRequest(UInt64, Bool)
|
||||
ToplevelMoveRequest(UInt64)
|
||||
/// xdg_toplevel.resize from a client-decorated window: (id, edges), the xdg_toplevel
|
||||
/// resize_edge bits (1 top, 2 bottom, 4 left, 8 right).
|
||||
ToplevelResizeRequest(UInt64, UInt)
|
||||
/// Who draws the window's frame, sent with a commit when it changes: (id, client_side, x, y).
|
||||
/// A client that never asked for server-side decoration (GTK: GNOME Files, most GNOME apps)
|
||||
/// draws its own title bar and shadow; (x, y) is where its visible window starts inside the
|
||||
/// buffer (xdg_surface.set_window_geometry), past the shadow.
|
||||
ToplevelFrame(UInt64, Bool, Int, Int)
|
||||
/// xdg_popup created: (id, parent window id, x, y, w, h) relative to the parent's content.
|
||||
PopupOpened(UInt64, UInt64, Int, Int, Int, Int)
|
||||
PopupCommitted(UInt64, @scene.ShmBufferSnapshot?)
|
||||
@@ -131,6 +139,8 @@ struct ToplevelState {
|
||||
/// How far the last configure got with a client drawing another size after acking it:
|
||||
/// 0 not yet, 1 sent again, 2 reported as ToplevelSizeChosen.
|
||||
mut cfg_retry : Int
|
||||
/// The last ToplevelFrame sent (client_side, x, y), None before the first.
|
||||
mut frame_sent : (Bool, Int, Int)?
|
||||
}
|
||||
|
||||
///| xdg_positioner state.
|
||||
@@ -638,6 +648,19 @@ fn WaylandServer::dispatch_msg(
|
||||
Some(bid) => snapshot_shm_buffer(c, bid)
|
||||
None => None
|
||||
}
|
||||
if snap is Some(_) {
|
||||
// Who draws the frame: a client that never made an xdg-decoration
|
||||
// object (GTK) decorates itself.
|
||||
let (gx, gy) = match c.xdg_surfaces.get(tl.xdg_surface_id) {
|
||||
Some(xs) => (xs.geo_x, xs.geo_y)
|
||||
None => (0, 0)
|
||||
}
|
||||
let frame = (tl.deco_obj_id is None, gx, gy)
|
||||
if tl.frame_sent != Some(frame) {
|
||||
tl.frame_sent = Some(frame)
|
||||
events.push(ToplevelFrame(wid, frame.0, gx, gy))
|
||||
}
|
||||
}
|
||||
events.push(ToplevelCommitted(wid, snap))
|
||||
match snap {
|
||||
Some(sn) => self.check_committed_size(c, tl, surf, sn, events)
|
||||
@@ -971,6 +994,7 @@ fn WaylandServer::dispatch_msg(
|
||||
cfg_serial: 0U,
|
||||
acked_serial: 0U,
|
||||
cfg_retry: 0,
|
||||
frame_sent: None,
|
||||
})
|
||||
self.win_to_client.set(wid, c.client_id)
|
||||
} else if opcode == 2U {
|
||||
@@ -1023,6 +1047,7 @@ fn WaylandServer::dispatch_msg(
|
||||
cfg_serial: 0U,
|
||||
acked_serial: 0U,
|
||||
cfg_retry: 0,
|
||||
frame_sent: None,
|
||||
})
|
||||
self.win_to_client.set(wid, c.client_id)
|
||||
// xdg_popup.configure(x, y, w, h) then xdg_surface.configure(serial)
|
||||
@@ -1133,6 +1158,11 @@ fn WaylandServer::dispatch_msg(
|
||||
} else if opcode == 5U {
|
||||
// move
|
||||
events.push(ToplevelMoveRequest(wid))
|
||||
} else if opcode == 6U {
|
||||
// resize(seat, serial, edges)
|
||||
let _seat = reader.u32()
|
||||
let _serial = reader.u32()
|
||||
events.push(ToplevelResizeRequest(wid, reader.u32()))
|
||||
} else if opcode == 8U {
|
||||
// set_min_size
|
||||
let mw = reader.i32()
|
||||
@@ -1173,6 +1203,11 @@ fn WaylandServer::dispatch_msg(
|
||||
}
|
||||
ObjToplevelDeco(wid) =>
|
||||
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
|
||||
_ => ()
|
||||
}
|
||||
c.objects.remove(obj_id)
|
||||
send_delete_id(c, obj_id)
|
||||
} else if opcode == 1U || opcode == 2U {
|
||||
@@ -1345,6 +1380,7 @@ pub fn WaylandServer::send_toplevel_configure(
|
||||
activated : Bool,
|
||||
maximized : Bool,
|
||||
fullscreen : Bool,
|
||||
tiled~ : Bool = false,
|
||||
) -> Unit {
|
||||
let cid = match self.win_to_client.get(win_id) {
|
||||
Some(id) => id
|
||||
@@ -1375,6 +1411,13 @@ pub fn WaylandServer::send_toplevel_configure(
|
||||
if activated {
|
||||
push_state(4U)
|
||||
}
|
||||
if tiled && !maximized && !fullscreen {
|
||||
// tiled_left/right/top/bottom (xdg_toplevel v2+): client-decorated windows drop their
|
||||
// shadow and rounded corners, so neighbouring tiles meet cleanly.
|
||||
for st in [5U, 6U, 7U, 8U] {
|
||||
push_state(st)
|
||||
}
|
||||
}
|
||||
tl.cfg_w = width
|
||||
tl.cfg_h = height
|
||||
tl.cfg_states = states
|
||||
|
||||
Reference in new issue
Block a user