diff options
author | Scott Moreau <oreaus@gmail.com> | 2012-06-07 09:12:31 -0600 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-06-07 17:15:32 -0400 |
commit | 3f79d661a14254a4fedce789a6884b41366ae1af (patch) | |
tree | 2ec1542ad8b9adf5e917f3fe42176cc6a18ffa9f | |
parent | bdc7cd06d1829a46ae4e7bb31955ae251b616241 (diff) |
zoom: Convert wl_fixed_t directly into floats, to avoid truncation.
This fixes center point inaccuracy for rotated surfaces. Thanks to
Pekka Paalanen for spotting it.
-rw-r--r-- | src/compositor.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/compositor.c b/src/compositor.c index 94de667..c6a5260 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2734,24 +2734,24 @@ weston_text_cursor_position_notify(struct weston_surface *surface, WL_EXPORT void weston_output_update_zoom(struct weston_output *output, - wl_fixed_t fx, - wl_fixed_t fy, + wl_fixed_t x, + wl_fixed_t y, uint32_t type) { - int32_t x, y; + float global_x, global_y; float trans_min, trans_max; if (output->zoom.level >= 1.0) return; - x = wl_fixed_to_int(fx); - y = wl_fixed_to_int(fy); + global_x = wl_fixed_to_double(x); + global_y = wl_fixed_to_double(y); output->zoom.trans_x = - (((float)(x - output->x) / output->current->width) * + (((global_x - output->x) / output->current->width) * (output->zoom.level * 2)) - output->zoom.level; output->zoom.trans_y = - (((float)(y - output->y) / output->current->height) * + (((global_y - output->y) / output->current->height) * (output->zoom.level * 2)) - output->zoom.level; if (type == ZOOM_TEXT_CURSOR) { |