compositor: simple menu transform
authorPekka Paalanen <ppaalanen@gmail.com>
Tue, 7 Feb 2012 12:19:01 +0000 (14:19 +0200)
committerPekka Paalanen <ppaalanen@gmail.com>
Tue, 7 Feb 2012 12:19:01 +0000 (14:19 +0200)
Transform a menu popup the same as its parent surface.

The parent's transformation is snapshotted at the popup map() time, and
does not follow further parent motion.

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

index 78120ef..53b192c 100644 (file)
@@ -103,6 +103,7 @@ struct shell_surface {
                struct wl_grab grab;
                uint32_t time;
                int32_t x, y;
+               struct weston_transform parent_transform;
                int32_t initial_up;
        } popup;
 
@@ -521,8 +522,22 @@ shell_map_popup(struct shell_surface *shsurf, uint32_t time)
        shsurf->popup.grab.interface = &popup_grab_interface;
        device = es->compositor->input_device;
 
-       es->geometry.x = shsurf->parent->surface->geometry.x + shsurf->popup.x;
-       es->geometry.y = shsurf->parent->surface->geometry.y + shsurf->popup.y;
+       weston_surface_update_transform(parent);
+       if (parent->transform.enabled) {
+               shsurf->popup.parent_transform.matrix =
+                       parent->transform.matrix;
+       } else {
+               /* construct x, y translation matrix */
+               weston_matrix_init(&shsurf->popup.parent_transform.matrix);
+               shsurf->popup.parent_transform.matrix.d[12] =
+                       parent->geometry.x;
+               shsurf->popup.parent_transform.matrix.d[13] =
+                       parent->geometry.y;
+       }
+       wl_list_insert(es->geometry.transformation_list.prev,
+                      &shsurf->popup.parent_transform.link);
+       es->geometry.x = shsurf->popup.x;
+       es->geometry.y = shsurf->popup.y;
        es->geometry.dirty = 1;
 
        shsurf->popup.grab.input_device = device;