Contradiction in wl_surface description
From the description of
Destroying the role object does not remove the role from the wl_surface, but it may stop the wl_surface from "playing the role". For instance, if a wl_subsurface object is destroyed, the wl_surface it was created for will be unmapped and forget its position and z-order. It is allowed to create a wl_subsurface for the same wl_surface again, but it is not allowed to use the wl_surface as a cursor (cursor is a different role than sub-surface, and role switching is not allowed).
However, comparing that to the description of
The sub-surface interface is removed from the wl_surface object that was turned into a sub-surface with a wl_subcompositor.get_subsurface request. The wl_surface's association to the parent is deleted, and the wl_surface loses its role as a sub-surface. The wl_surface is unmapped immediately.
So wl_surface says the role is kept (specifically giving wl_subsurface as an example), while wl_subsurface says it is not. wl_surface is also describing behaviour of forgetting the parent's position and z-order, which is not described anywhere in the wl_subsurface description.
I would personally side with the behaviour wl_surface describes, as I cannot think of a reason why wl_subsurface would need to override the normal wl_surface role behaviour, and leads to a more consistent implementation for compositors.
It also matches that behaviour that weston and wlroots have actually implemented:
[3332352.321] -> email@example.com_surface(new id wl_surface@3) [3332352.333] -> firstname.lastname@example.org_surface(new id wl_surface@7) [3332352.344] -> email@example.com_subsurface(new id wl_subsurface@8, wl_surface@7, wl_surface@3) [3332352.371] -> firstname.lastname@example.org() [3332352.377] -> email@example.com_xdg_surface(new id xdg_surface@9, wl_surface@7) [3332352.396] -> firstname.lastname@example.org_toplevel(new id xdg_toplevel@10) [3332352.509] email@example.com_id(8) [3332352.531] firstname.lastname@example.org(xdg_surface@9, 0, "Cannot assign role xdg_toplevel to wl_surface@7, already has role wl_subsurface
I have not tested any other compositors.