compositor, shell: surface transform inheritance

Implements surface transform inheritance. A 'parent' pointer is added to
weston_surface::geometry, and is automatically used by
weston_surface_update_transform(). When updating the transform, the
parent transform is updated as needed, too.

shell_map_popup() is converted to use the new
weston_surface_set_transform_parent() function. Now, if we moved the
popup's parent surface while the popup is open, the popup surface will
stick to the parent properly.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
diff --git a/src/compositor.h b/src/compositor.h
index f3e54d9..a38559e 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -388,6 +388,11 @@
  * If you want to apply a transformation in local coordinates, add your
  * weston_transform to the head of the list. If you want to apply a
  * transformation in global coordinates, add it to the tail of the list.
+ *
+ * If surface->geometry.parent is set, the total transformation of this
+ * surface will be the parent's total transformation and this transformation
+ * combined:
+ *    Mparent * Mn * ... * M2 * M1
  */
 
 struct weston_surface {
@@ -414,6 +419,12 @@
 
 		/* struct weston_transform */
 		struct wl_list transformation_list;
+
+		/* managed by weston_surface_set_transform_parent() */
+		struct weston_surface *parent;
+		struct wl_listener parent_destroy_listener;
+		struct wl_list child_list; /* geometry.parent_link */
+		struct wl_list parent_link;
 	} geometry;
 
 	/* State derived from geometry state, read-only.
@@ -689,6 +700,10 @@
 weston_surface_set_position(struct weston_surface *surface,
 			    float x, float y);
 
+void
+weston_surface_set_transform_parent(struct weston_surface *surface,
+				    struct weston_surface *parent);
+
 int
 weston_surface_is_mapped(struct weston_surface *surface);