shell: fix move of transformed surfaces
authorPekka Paalanen <ppaalanen@gmail.com>
Mon, 30 Jan 2012 12:16:34 +0000 (14:16 +0200)
committerPekka Paalanen <ppaalanen@gmail.com>
Tue, 31 Jan 2012 11:12:11 +0000 (13:12 +0200)
In the stack of transformations, change the rotation to be applied
to the surface before the absolute positioning. Doing so avoids having
to undo and redo the absolute positioning, and we can simply use the
surface center in local coordinates as the origin.

This fixes the surface move. Before, the surface moved along the surface
local axis, but the user expects it to move along the global axis with
the pointer.

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

index 168443b..6a9e8b4 100644 (file)
@@ -983,6 +983,8 @@ rotate_grab_motion(struct wl_grab *grab,
                container_of(grab, struct rotate_grab, grab);
        struct wl_input_device *device = grab->input_device;
        struct shell_surface *surface = rotate->surface;
+       GLfloat cx = 0.5f * surface->surface->geometry.width;
+       GLfloat cy = 0.5f * surface->surface->geometry.height;
        GLfloat dx, dy;
        GLfloat r;
 
@@ -1004,15 +1006,13 @@ rotate_grab_motion(struct wl_grab *grab,
                rotate->rotation.d[5] = rotate->rotation.d[0];
 
                weston_matrix_init(matrix);
-               weston_matrix_translate(matrix, -rotate->center.x,
-                                       -rotate->center.y, 0.0f);
+               weston_matrix_translate(matrix, -cx, -cy, 0.0f);
                weston_matrix_multiply(matrix, &surface->rotation.rotation);
                weston_matrix_multiply(matrix, &rotate->rotation);
-               weston_matrix_translate(matrix, rotate->center.x,
-                                       rotate->center.y, 0.0f);
+               weston_matrix_translate(matrix, cx, cy, 0.0f);
 
                wl_list_insert(
-                       surface->surface->geometry.transformation_list.prev,
+                       &surface->surface->geometry.transformation_list,
                        &surface->rotation.transform.link);
        } else {
                wl_list_init(&surface->rotation.transform.link);