layer-shell: Exclusive zone while sized by the compositor
zwlr_layer_surface_v1
's set_size(width, height)
states:
If you pass 0 for either value, the compositor will assign it and
inform you of the assignment in the configure event. You must set your
anchor to opposite edges in the dimensions you omit; not doing so is a
protocol error. Both values are 0 by default.
Which seems fair - if the surface is going to span the entire available height, it probably makes sense for it to be anchored to both top and bottom edge.
Consider a surface that's meant to work as an unfoldable panel. In its folded state, it takes some vertical space at the bottom of the screen which is meant to not be obstructed by running applications:
When unfolded, it covers the whole available screen space:
To achieve that, the surface can be anchored to all edges and set size of (0,0), hiding its unused portion behind the screen edge by using negative margin:
However, this interacts poorly with how exclusive zones work:
A positive value is only meaningful if the surface is anchored to one
edge or an edge and both perpendicular edges. If the surface is not
anchored, anchored to only two perpendicular edges (a corner), anchored
to only two parallel edges or anchored to all edges, a positive value
will be treated the same as zero.
By setting the anchor to two parallel edges we're losing the information on where to place the exclusive zone.
Above describes the way phosh currently works. Turns out that, when implementing unfolding, we have carelessly violated the protocol by setting the surface's size to (0,0) while not anchoring it to the top edge - which actually turned out to work in expected way on all implementations I tried it on back in the day. The surface covered the whole available space, while the exclusive zone remained anchored to the bottom edge of the screen.
In recent versions, wlroots started to enforce the rule as specified in the protocol, which made me look at how to reimplement this behavior in a conforming way. Unfortunately, I have found no other solutions - managing the surface size by the client has made it impossible for other exclusive zones to influence the surface's size, which is apparent in case of the on-screen keyboard on a higher layer - the whole surface gets "pushed" upwards by the size taken by the keyboard, not given a chance to adjust its size:
On the other hand, letting the compositor manage the surface size makes it impossible for the surface to define its own exclusive zone, because there's no way to specify the screen edge it should be anchored to. This would make all maximized surfaces uselessly change their size every time the panel gets unfolded since there would be no effective exclusive zone anymore, which is disastrous for performance, especially with many surfaces being mapped.
Therefore, here comes the question:
- should the restriction on anchored edges when dimension equals 0 be lifted from the protocol, making wlroots work the same way it did before commit https://github.com/swaywm/wlroots/commit/8dec751a6d84335fb04288b8efab6dd5c90288d3?
- should exclusive zone interface be extended to allow being explicit about the screen edge it should apply to?
- should it stay as is, making it a thing that should be resolved by using other/custom protocols?