Skip to content

Wayland: a decorated window's bottom corners round under the client-side frame - #1188

Merged
thdxr merged 3 commits into
devfrom
fix-csd-bottom-corners
Nov 19, 2026
Merged

thdxr merged 3 commits into
devfrom
fix-csd-bottom-corners

Conversation

@thdxr

@thdxr thdxr commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

on GNOME Wayland (no server-side decorations) winit draws the sctk-adwaita client-side frame. its headerbar rounds the top two corners and its shadow has always cut a 10-point rounded window, but the frame's visible one-point border was straight rects on the left, right and bottom, and the content's surface is a rectangle, so every decorated window showed square bottom corners over a rounded shadow.

this makes all four corners round together while the window floats, and square while it's maximized, tiled or fullscreen.

what changed

  • vendor/sctk-adwaita (new crate, 0.10.1 + vendor/sctk-adwaita.patch, re-made by scripts/vendor-sctk-adwaita.sh): the bottom part reaches a corner radius above the window's bottom edge and the visible border is drawn as a ring whose outer edge is the shadow's disc, so it joins the straight bands at each tangent and sits exactly over the shadow's cut-out. the part draws the shadow's crescents only inside the content's own corner squares — outside them the side parts already draw the shadow down to the window's edge, and a second copy there would composite over theirs (the parts stack) and double it — and the shadow below the window is a square frame's, pixel for pixel. the side parts' bottom corner pieces reach the border's own column, where no border is drawn below the arc's tangent. square when the state intersects MAXIMIZED | TILED | FULLSCREEN, the same rule the headerbar uses. AdwaitaFrame::content_corner_radius and CONTENT_CORNER_RADIUS say what radius the content leaves the corners to.
  • vendor/winit (vendor/winit.patch): platform::wayland::WindowExtWayland::content_corner_radius returns the radius the content's bottom corners take, in logical points. it's CORNER_RADIUS - VISIBLE_BORDER_SIZE (9), not 10, because the frame's 1pt border is drawn outside the content's arc: the app can then clip a plain rounded rect of that radius on its own surface. zero when there is no client-side frame (server decorations, decorations off), when the frame is square (maximized, tiled, fullscreen), and on X11. has_client_side_frame says whether the window's decorations are a client-side frame's at all — true in fullscreen too, where the frame draws square corners — so an app only asks its surface to keep alpha when there is a frame to round; and the opaque region an opaque window gets is cut to everything but the two corner squares the arcs cross, reloaded at the end of configure when the frame appears, goes or changes state.
  • rune: window/corners.rs owns the radius (wayland + a client-side frame + a premultiplied surface) and the pass; render/csd_corners.rs fades the composition outside the two bottom arcs after the frame is drawn (one draw of two corner squares, Zero/OneMinusSrcAlpha, a pixel of fade across the arc so it meets the frame's antialiased ring without a seam, the same on the sRGB and the linear view). a window with a client-side frame keeps its surface's pixels' alpha, but the window stays opaque to rune: rt.transparent, the clear colour, the device and GPU choice are the ones an opaque window had, and only those corner pixels are transparent. the surface's alpha mode comes from create::alpha_mode: an app that asked for a translucent window keeps every mode it always had (PostMultiplied included, Metal's only one), and PreMultiplied alone is for a window that only needs its corner pixels; a window under a compositor that draws the decorations itself (KDE, sway, Hyprland) never has a frame, so it keeps exactly the surface config it had — Opaque, no fade, full opaque region. also fixed: rt.transparent follows a new surface's alpha mode on reattach, corner/height never go negative on the square path, and shapes are clamped or skipped for tiny windows.

testing

  • vendor/sctk-adwaita has nine unit tests kept in the patch: the radius by state (9/10 floating, 0 for maximized, tiled and fullscreen), the border along the bottom arcs, the shadow below the window against a square frame's (every pixel within 1/255), the side and bottom parts composited at their window positions against the square frame outside the content rect and the corner squares (within 2/255, and the worst pixel reported), the crescent's continuity with the shadow across the window's edges, a square window's straight band and untouched corners, the bottom part's input zone starting at the window's edge, and a narrow window's clamped arcs. the composite test fails on the previous commit (the worst pixel is (-2, 110): round corners composite 72, the square frame 39) and passes now.
  • rune: create::alpha_mode is unit-tested over every mode a surface can offer (transparent windows keep PostMultiplied/Inherit/PreMultiplied, corner-only windows take PreMultiplied or opaque), and render::csd_corners has GPU tests on an offscreen target: both bottom corners fade, the foot inside each arc stays, nothing above the arc centres or at the top corners changes, a wider radius clears more, a square window prepares and draws nothing, and the fade's colour and alpha hold in both target views.
  • cargo check --workspace --all-targets, cargo test -p sctk-adwaita (ten tests), cargo test -p rune --lib render::csd_corners, cargo test -p rune --lib window::tests, cargo clippy -p rune --lib and cargo clippy -p sctk-adwaita --all-targets (no new warnings in the changed files), bash scripts/file-size.sh, and both vendor scripts re-run to confirm each vendored tree equals its script output.
  • rebased onto the window/ reorganisation (window::Host type-erased, host/, surface/, win32/); the corner pass lives in window::surface::corners, and the alpha-mode test in window/tests. the branch also carries one unrelated Linux build fix, Linux: an overlay's scale is read before the type-erased app is reborrowed: the type-erasure commit passes app mutably to rescale and reads app.rt().env.scale in the same call, which the borrow checker refuses on the Linux-only layer-overlay path, so cargo check --workspace --all-targets fails on dev without it (macOS never compiles that path).
  • headless, no real display: Xvfb plus a nested headless weston (pixman renderer) on its own socket and runtime dir, with a solid desktop background so shadow pixels can be compared, and a second capture of the same probe built with the corner radius forced to zero (the square frame). beside the bottom-left corner the two composites are identical at every probed pixel — columns x = -2, -4, -10 and rows h - 15 … h + 5, e.g. srgb(47,51,60), (49,53,63), (53,58,69) in both — with no step at the window's edge or a corner radius above it; the right side matches the same way. the floating window's corners are the shadow (srgb(48,53,63), desktop srgb(58,63,75)), the crescent just outside the arc is srgb(47,51,61), and maximized, fullscreen and under sway (server-side decorations, get_subsurface never sent) the corner pixels are the content colour srgb(69,124,253) with set_opaque_region(wl_region…) never nil.

limits

  • if a surface offers no premultiplied alpha mode the corners stay square and the frame draws its square border (radius 0), as before.
  • a floating decorated window's surface is premultiplied rather than opaque (the corners need it); the compositor blends the two corner squares and treats the rest of the window as opaque. a window under server-side decorations keeps the opaque surface it always had.
  • only the sctk-adwaita frame is handled; compositors that draw a different client-side frame are unchanged.
  • verified on weston's adwaita frame and under sway's server-side decorations, not on a real GNOME session: a GNOME check of a floating, a maximized and a fullscreen window would still be worth doing.

— from 𝕆𝕡𝕖𝕟𝕮𝖔𝖉𝖊

… the client-side frame

The adwaita frame's headerbar rounds the top two corners and its shadow has always cut a
10-point rounded window, but the frame's visible one-point border was straight on the left,
right and bottom, and the content's surface is a rectangle, so every decorated window showed
square bottom corners over a rounded shadow.

- vendor/sctk-adwaita (new, 0.10.1 + vendor/sctk-adwaita.patch): the bottom part reaches a
  corner radius above the window's bottom edge and the border is drawn as a ring whose outer
  edge is the shadow's disc, square while maximized, tiled or fullscreen like the headerbar.
  The part draws the shadow's crescents only inside the content's own corner squares, so the
  composite beside a corner is a square frame's pixel for pixel and nothing is doubled, and its
  `content_corner_radius` says what radius the content leaves the corners to.
- vendor/winit (`content_corner_radius`, `has_client_side_frame`): the radius the content's
  bottom corners take, and whether the window's decorations are a client-side frame's at all,
  so an app only asks its surface to keep alpha when there is a frame to round, and the opaque
  region keeps every pixel but the two corner squares.
- rune: `window::surface::corners` owns the radius and the pass; `render::csd_corners` fades
  the composition outside the two bottom arcs by coverage, before a straight-alpha surface
  converts it. An app's own transparency keeps the alpha mode it always had; a window that only
  needs its corners takes premultiplied alpha or keeps square ones. Every other platform, a
  borderless window, a square frame and a surface without alpha paint what they did.
…rowed

The type-erasure change passes `app` mutably to `rescale` and reads `app.rt().env.scale` in the
same call, which the borrow checker refuses on the Linux-only layer-overlay path (`cargo check
--workspace --all-targets` fails there; macOS never compiles it). Reads the scale first.
@thdxr
thdxr force-pushed the fix-csd-bottom-corners branch from 37f3398 to 6e73734 Compare November 19, 2026 01:17
…e window reorganisation

`Cargo.toml`'s sctk-adwaita comment and `window::surface::corners` still named the pre-rebase
paths.
@thdxr
thdxr merged commit 5f68f57 into dev Nov 19, 2026
1 check passed
thdxr added a commit to anomalyco/hex that referenced this pull request Nov 19, 2026
Bump Rune to 5f68f577 (anomalyco/rune#1188). Under GNOME Wayland winit
draws the client-side frame, whose headerbar rounds the top corners and
whose shadow cuts a 10-point rounded window, but the content's surface
stayed square: the bottom corners showed past the frame's border and the
border's straight bands crossed the shadow's cut-out (#1779).

Rune rounds the content's bottom corners with the frame while the window
floats, and keeps them square when it is maximized, tiled or fullscreen;
a compositor that draws the decorations itself (KDE, sway, Hyprland)
keeps the surface it had. Patch sctk-adwaita from the same rev as winit,
since Rune's winit calls the vendored frame's
`AdwaitaFrame::content_corner_radius`.

The bump also brings the type-erased `window::Host` and window/
reorganisation, the rune-core/rune-gpu/rune-image/rune-spell extraction
and non-generic `RuntimeCore`, windows-sys 0.61, deep Taffy stack
segments, the new wheel distance and chaining, and text, markdown and
scroll fixes. One wheel test position moves 24 pt inside the list's
right edge, where Rune's new overlay scroll bar doesn't take the wheel
(anomalyco/rune#1200). Goldens are refreshed for Rune's icon catalog and
glyphs.

cargo check --all-targets, cargo test (2775 passed), cargo clippy
--all-targets --all-features, cargo fmt --check, code-shape.py and
check-nix-git-pins.py pass.
@thdxr
thdxr deleted the fix-csd-bottom-corners branch November 19, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant