Wayland: on a fractional scale the viewport's destination is one larger than the configured size (a ceil of a ceil), and a window configured at its own size grows a pixel per configure #201
Labels
No labels
claude:blocked
claude:done
claude:failed
claude:in-progress
claude:ready
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Crafter.Graphics#201
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
A configure's logical size becomes the swapchain's size as
ceil(logical * scale), and the viewport's destination is then worked back from that asceil(physical / scale). Whereverlogical * scaleis not a whole number, the second rounding lands one above the size the compositor configured. The surface is then one logical pixel wider and higher than asked and its buffer is shown slightly scaled. And when the compositor next configures the window at the size it now has, the same step is taken again: the window grows a pixel per configure, a swapchain each time, until it reaches a size where both roundings are exact. Line numbers refer toc006519.Details
implementations/Crafter.Graphics-Window.cpp:1923-1926(xdg_surface_handle_configure):newWidth = ceil(pendingLogicalWidth * scale), and the same for the height.:784-788(RebuildSwapchain):wp_viewport_set_destination(ceil(width / scale), ceil(height / scale)).:406: the constructor does the second step on its arguments.fractional-scale-v1 has it the other way about: the destination is the surface's size, and the buffer's size is that times the scale ("For toplevel surfaces, the size is rounded halfway away from zero").
The two roundings done in 32-bit float, as the code does them, for the logical sizes 1 to 3000: at 1.5 every odd size comes out one larger, at 1.25 and 1.75 every size that is not a multiple of 4, at 2.85 all but 127 of them. At 1 and 2 none does.
Concrete case
A Fairphone 6 with Plasma Mobile 6.8.2 (KWin 6.8.2), scale 2.85, running imsd-messages 0.0.0's tree (ca5cd72, the library at
c006519) underWAYLAND_DEBUG=1. The maximized window is configured 392 x 796:392 x 2.85 = 1117.2, so the buffer is 1118 wide; 1118 / 2.85 = 392.28, so the destination is 393. The surface is 393 x 797 where 392 x 796 was configured, and a buffer 1118 pixels wide is laid over 1120.05.
Later in the same trace KWin configures the window at the size it now has, and each answer is one larger (the lines between are left out):
Eight rebuilds in 184 ms. It stops at 400 x 800 because both roundings are exact there (2.85 x 400 = 1140, 2.85 x 800 = 2280). 2.6 s later KWin configured 392 x 796 again. A second trace of the same night, of an earlier build of the app on the same library commit, has the same run of configures from 392 x 796 to 400 x 800.
Not looked into: what made KWin configure the window at its own size at those two moments, and whether the scaling of the buffer shows in the text.
Suggested fix
Keep the configured logical size as the window's state and send that as the destination, unchanged. Work out only the buffer's size from it, rounded as the protocol says. #165's suggested fix keeps the logical size already, for the scale's sake: this is the same state.
Found reading the phone trace taken for #199, 2026-11-18.