compositor: introduce sub-surfaces
authorPekka Paalanen <ppaalanen@gmail.com>
Thu, 25 Apr 2013 10:57:42 +0000 (13:57 +0300)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 10 May 2013 18:32:51 +0000 (14:32 -0400)
commite67858b9cfe07efd58ea2abafc8e0642f4f46753
treedc800c16f3dc94c6534b69b716649ce98f89bb8b
parent2396aec6842c709a714f3825dbad9fd88478f2e6
compositor: introduce sub-surfaces

Implement the basic protocol for sub-surfaces:
- expose wl_subcompositor global interface
- error checking on protocol calls
- associate a parent wl_surface to a sub-surface
- introduce the sub-surface role, which is exclusive
- an implementation of the wl_subsurface interface
- allow nesting of sub-surfaces
- proper surface transformation inheritance from parent to sub-surfaces
- two different modes of wl_surface.commit for sub-surfaces
- hook sub-surfaces up to repaint by modifying the repaint list code

Struct weston_subsurface is dynamically allocated. For sub-surfaces, it
is completely populated.

For parent surfaces, weston_subsurface acts only as a link for stacking
order purposes. The wl_resource is unused, parent_destroy_listener is
not registered, the transform is not linked, etc.

Sub-surfaces are not added directly into layers for display or input.
Instead, they are hooked up via the sub-surface list present in parent
weston_surface. This way sub-surfaces are inherently linked to the
parent surface, and cannot be displayed unless the parent is mapped,
too. This also eases restacking, as only the parent will be in a layer
list. Also, only the main surface should be subject to shell actions.

The surface list rebuilding in weston_output_repaint() is modified to
process sub-surface lists, if they are non-empty. The sub-surface list
always contains the parent, too, unless empty. The collection of
frame_callback_list is moved to a later loop, to streamline the surface
list rebuild functions.

Features still lacking are:
- full-surface alpha support for compound windows

Changes in v2:
- fix a bug in surface mapping: commit a sub-surface would cause the
  main surface to never be mapped.
- remove debug printfs
- detect attempt of making a surface its own parent
- always zero-alloc weston_subsurface
- apply wl_subsurface.set_position in commit, not immediately
- add weston_surface_to_subsurface()
- implement sub-surface commit modes parent-cached and independent
- implement wl_subcompositor.destroy and wl_subsurface.destroy

Changes in v3:
- rebased, and use the new transform inheritance code
- squashed the commit "add sub-surfaces to repaint list"
- fixed a buffer reference leak in commit_from_cache()
- Rewrite the sub-surface destructor code, and make it leave the
  wl_subsurface protocol object inert, if one destroys the corresponding
  wl_surface.
- replaced set_commit_mode with set_sync and set_desync
- allowed sub-surface nesting, and fixed repaint accordingly
- implemented nested sub-surface commit modes
- Made the sub-surface order changes from wl_subsurface.place_above and
  .place_below to be applied when the parent surface state is applied,
  instead of immediately. This conforms with the protocol specification
  now.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
src/compositor.c
src/compositor.h