From a4f80f34e286bb505c9494f5fb1d95c21f645557 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 31 Jan 2012 12:04:54 +0200 Subject: [PATCH] compositor: handle attach request in surface-local coordinates The x, y offsets in attach request are in surface-local coordinates, as that is the only coordinate system the clients know about. The offset must be transformed to global coordinate system to be applied properly. This approximately fixes the top-left resizing of transformed surfaces. However, it suffers from drift due to accumulating rounding errors in continuous resizing. Signed-off-by: Pekka Paalanen --- src/compositor.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index 89981f14..b404dfa6 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -1073,7 +1073,7 @@ weston_surface_assign_output(struct weston_surface *es) static void surface_attach(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *buffer_resource, int32_t x, int32_t y) + struct wl_resource *buffer_resource, int32_t sx, int32_t sy) { struct weston_surface *es = resource->data; struct weston_shell *shell = es->compositor->shell; @@ -1101,12 +1101,18 @@ surface_attach(struct wl_client *client, if (es->visual == WESTON_NONE_VISUAL) { shell->map(shell, es, buffer->width, buffer->height); - } else if (x != 0 || y != 0 || + } else if (sx != 0 || sy != 0 || es->geometry.width != buffer->width || es->geometry.height != buffer->height) { - /* FIXME: the x,y delta should be in surface-local coords */ - shell->configure(shell, es, es->geometry.x + x, - es->geometry.y + y, + int32_t from_x, from_y; + int32_t to_x, to_y; + + /* FIXME: this has serious cumulating rounding errors */ + weston_surface_to_global(es, 0, 0, &from_x, &from_y); + weston_surface_to_global(es, sx, sy, &to_x, &to_y); + shell->configure(shell, es, + es->geometry.x + to_x - from_x, + es->geometry.y + to_y - from_y, buffer->width, buffer->height); }