Stacking subsurface siblings

Bill Spitzak spitzak at
Fri Jun 19 18:07:55 PDT 2015

On Thu, Jun 18, 2015 at 12:14 AM, Pekka Paalanen <ppaalanen at>

> Arnaud's code:
>         surf[BLUE] = surface_create(ctx, NULL, 100, 100, 0, 0, 0xff0000ff);
>         if (!surf[BLUE])
>                 die("failed to create root surface");
>         surf[RED] = surface_create(ctx, surf[BLUE], 100, 100, -100, -100,
>                                    0xffff0000);
>         surf[GREEN] = surface_create(ctx, surf[BLUE], 100, 100, -50, -50,
>                                      0xff00ff00);
> #if 0
>         wl_subsurface_place_below(surf[GREEN]->subsurface,
> surf[BLUE]->surface);
>         wl_subsurface_place_below(surf[RED]->subsurface,
> surf[GREEN]->surface);
> #else
>         wl_subsurface_place_below(surf[RED]->subsurface,
> surf[GREEN]->surface);
>         wl_subsurface_place_below(surf[GREEN]->subsurface,
> surf[BLUE]->surface);
> #endif
> I can't see how you come to your conclusion, would you care to explain?

Arnaud claims the result of this is the order G,R,B.

If place_below(A,B) was implemented as "insert A before B in the list" then
the first statement (place_below(R,G)) would change this to R,G,B. The
second statement (place_below(G,B)) would not change anything as G is
already in the right place.

However if place_below(A,B) was implemented as "insert A at the start of
the list" then the first statement produces R,G,B and then the second one
moves G and produces G,R,B which matches what he is seeing.

Either he did not report correctly what is happening or place_below is not
working as you specified.

I did not realize that the order was defined before the place_below calls.
If you assume the three surfaces are in a random order, then the "insert A
before B" implementation can still produce G,B,R.

I think we all agree that the solution is for the client to start with the
"main" surface and do place_above/below with the adjacent surface, then
place_above/below with the next further surface, etc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the wayland-devel mailing list