[PATCH] shell: correct position of a surface before rotating it.

Kristian Hoegsberg hoegsberg at gmail.com
Tue Mar 20 17:04:23 PDT 2012


On Tue, Mar 20, 2012 at 12:14:33AM +0100, Rafał Mielniczuk wrote:
> From: Rafal Mielniczuk <rafal.mielniczuk2 at gmail.com>
> 
> How to reproduce: rotate the surface to something like 45 degrees,
> resize it drastically, continue to rotate. The surface will jump
> some space and the rotation point will not be in the center
> of the surface.
> 
> Fix is to shift the surface position to match the rotation point

Yup, I see the problem and it would be good to fix that.  git wont
apply your patch though, there's some whitespace damage.  Could you
resend it using git send-email or perhaps just attach the output of
git format-patch -1?

thanks,
Kristian

> ---
>  src/shell.c |   16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/src/shell.c b/src/shell.c
> index 765b0a4..66cdb77 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -1284,7 +1284,7 @@ rotate_binding(struct wl_input_device *device,
> uint32_t time,
>          (struct weston_surface *) device->pointer_focus;
>      struct shell_surface *surface;
>      struct rotate_grab *rotate;
> -    GLfloat dx, dy;
> +    GLfloat dx, dy, cx, cy, cposx, cposy, dposx, dposy;
>      GLfloat r;
> 
>      if (base_surface == NULL)
> @@ -1334,6 +1334,20 @@ rotate_binding(struct wl_input_device
> *device, uint32_t time,
>          weston_matrix_init(&surface->rotation.rotation);
>          weston_matrix_init(&rotate->rotation);
>      }
> +
> +    /* We need to adjust the position of the surface
> +     * in case it was resized in a rotated state before */
> +    cx = 0.5f * surface->surface->geometry.width;
> +    cy = 0.5f * surface->surface->geometry.height;
> +    cposx = surface->surface->geometry.x + cx;
> +    cposy = surface->surface->geometry.y + cy;
> +    dposx = rotate->center.x - cposx;
> +    dposy = rotate->center.y - cposy;
> +    if (dposx != 0 || dposy != 0) {
> +        weston_surface_set_position(base_surface,
> +                    base_surface->geometry.x + dposx,
> +                    base_surface->geometry.y + dposy);
> +    }
> 
>      wl_input_device_set_pointer_focus(device, NULL, time, 0, 0);
>  }
> -- 
> 1.7.9.4
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list