emersion / rootston

Example compositor based on wlroots
MIT License
4 stars 3 forks source link

Refine the ordering of layer-shell surfaces #9

Open dos1 opened 5 years ago

dos1 commented 5 years ago

layer-shell doesn't define in-layer stacking order, so it's up to compositor to come up with a sane behavior.

Ordering layer-shell surfaces in forward order works fine for shell surfaces with exclusive zone (like panels) - however, it leads to surprising results for ones with no exclusive zone, as the oldest surfaces are being rendered on top of the newer ones, which is the opposite of xdg-shell behavior. Example: a widget dashboard rendered on top of lock screen even though the lock screen is created afterwards.

On the other hand, just using a reverse order doesn't work well when stacking surfaces with exclusive zones - a panel with some decorative elements outside of its exclusive zone should get rendered on top (z-index) of the panel stacked on top (vertically) of it. For Phosh, this could result in the keyboard being rendered on top of unfolded home screen, leading to an obviously broken visual result.

Therefore, to follow the principle of least astonishment, layers without exclusive-zone gets rendered first in reverse order, and then the ones stacked to a screen edge with positive exclusive zone follow in forward order.

There's a third case: exclusive-zone set to -1, but I couldn't decide what would be the most obvious behavior in regards to other surfaces on the same layer, so I decided to treat them just like the ones without exclusive-zone.