aboutsummaryrefslogtreecommitdiffstats
path: root/compositor.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2010-06-08 15:29:14 -0400
committerKristian Høgsberg <krh@bitplanet.net>2010-06-08 15:29:14 -0400
commit0b8646bbd3d824239ef6e4ad05c98137e9c47b1c (patch)
tree1357d59aacb33787f5835c629914f98da6321374 /compositor.c
parentConsolidate more code in clients/window.c (diff)
downloadwayland-0b8646bbd3d824239ef6e4ad05c98137e9c47b1c.tar
wayland-0b8646bbd3d824239ef6e4ad05c98137e9c47b1c.tar.gz
wayland-0b8646bbd3d824239ef6e4ad05c98137e9c47b1c.tar.bz2
wayland-0b8646bbd3d824239ef6e4ad05c98137e9c47b1c.tar.lz
wayland-0b8646bbd3d824239ef6e4ad05c98137e9c47b1c.tar.xz
wayland-0b8646bbd3d824239ef6e4ad05c98137e9c47b1c.tar.zst
wayland-0b8646bbd3d824239ef6e4ad05c98137e9c47b1c.zip
Fix surface picking
Diffstat (limited to 'compositor.c')
-rw-r--r--compositor.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/compositor.c b/compositor.c
index 5af0a15..2a521ee 100644
--- a/compositor.c
+++ b/compositor.c
@@ -319,14 +319,15 @@ static void
wlsc_matrix_transform(struct wlsc_matrix *matrix, struct wlsc_vector *v)
{
int i, j;
- GLfloat t;
+ struct wlsc_vector t;
for (i = 0; i < 4; i++) {
- t = 0;
+ t.f[i] = 0;
for (j = 0; j < 4; j++)
- t += v->f[j] * matrix->d[i + j * 4];
- v->f[i] = t;
+ t.f[i] += v->f[j] * matrix->d[i + j * 4];
}
+
+ *v = t;
}
static void
@@ -694,6 +695,11 @@ surface_map(struct wl_client *client,
wlsc_matrix_init(&es->matrix);
wlsc_matrix_scale(&es->matrix, width, height, 1);
wlsc_matrix_translate(&es->matrix, x, y, 0);
+
+ wlsc_matrix_init(&es->matrix_inv);
+ wlsc_matrix_translate(&es->matrix_inv, -x, -y, 0);
+ wlsc_matrix_scale(&es->matrix_inv, 1.0 / width, 1.0 / height, 1);
+
}
static void
@@ -762,8 +768,8 @@ wlsc_surface_transform(struct wlsc_surface *surface,
struct wlsc_vector v = { { x, y, 0, 1 } };
wlsc_matrix_transform(&surface->matrix_inv, &v);
- *sx = v.f[0];
- *sy = v.f[1];
+ *sx = v.f[0] * surface->width;
+ *sy = v.f[1] * surface->height;
}
static void