shell: fix move of transformed surfaces

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>
dev
Pekka Paalanen 13 years ago
parent becfcbfbd2
commit 7b3bd3d8b6
  1. 10
      src/shell.c

@ -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);

Loading…
Cancel
Save