util: introduce rectangle packing helper
This helper allows to pack rectangles in such a way that they don't overlap while wasting as little space as possible, which can be used to configure layer surfaces in a more intelligent way compared to what most compositors currently do.
This is especially important with layer-shell v5 which introduces set_exclusive_edge
; ref !4713 (merged).
TODO: the current wlr_layer_surface_v1
helper has suboptimal behavior if the surface responds to a configure with a smaller size than requested. For correct results, the position needs to be adjusted to move the surface closer to the desired anchor point.
Examples
See https://codeberg.org/vyivel/layercheck.
maximize-trap.sh
Before:
After:
squares.sh
Before:
After:
Sway patch: https://github.com/swaywm/sway/pull/8274