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 <ppaalanen@gmail.com>
dev
Pekka Paalanen 13 years ago
parent 5c97ae7b82
commit a4f80f34e2
  1. 16
      src/compositor.c

@ -1073,7 +1073,7 @@ weston_surface_assign_output(struct weston_surface *es)
static void static void
surface_attach(struct wl_client *client, surface_attach(struct wl_client *client,
struct wl_resource *resource, 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_surface *es = resource->data;
struct weston_shell *shell = es->compositor->shell; struct weston_shell *shell = es->compositor->shell;
@ -1101,12 +1101,18 @@ surface_attach(struct wl_client *client,
if (es->visual == WESTON_NONE_VISUAL) { if (es->visual == WESTON_NONE_VISUAL) {
shell->map(shell, es, buffer->width, buffer->height); 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.width != buffer->width ||
es->geometry.height != buffer->height) { es->geometry.height != buffer->height) {
/* FIXME: the x,y delta should be in surface-local coords */ int32_t from_x, from_y;
shell->configure(shell, es, es->geometry.x + x, int32_t to_x, to_y;
es->geometry.y + 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); buffer->width, buffer->height);
} }

Loading…
Cancel
Save