From 8b09542fd912b2d97ff9ad1d86ce6f576e67cb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 1 Mar 2019 02:58:13 +0100 Subject: [PATCH] boxes: Crop rectangle converting to integer with grow strategy Reuse meta_rectangle_from_clutter_rect with growing strategy to properly cast the clutter floating rectangle to integer MetaRectangle. https://gitlab.gnome.org/GNOME/mutter/merge_requests/3 --- src/core/boxes.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/boxes.c b/src/core/boxes.c index 7b693e1b1..4ab07d273 100644 --- a/src/core/boxes.c +++ b/src/core/boxes.c @@ -2191,10 +2191,13 @@ meta_rectangle_crop_and_scale (const MetaRectangle *rect, int dst_height, MetaRectangle *dest) { - dest->x = floorf (rect->x * (src_rect->size.width / dst_width) + - src_rect->origin.x); - dest->y = floorf (rect->y * (src_rect->size.height / dst_height) + - src_rect->origin.y); - dest->width = ceilf (rect->width * (src_rect->size.width / dst_width)); - dest->height = ceilf (rect->height * (src_rect->size.height / dst_height)); + ClutterRect tmp = CLUTTER_RECT_INIT (rect->x, rect->y, + rect->width, rect->height); + + clutter_rect_scale (&tmp, + src_rect->size.width / dst_width, + src_rect->size.height / dst_height); + clutter_rect_offset (&tmp, src_rect->origin.x, src_rect->origin.y); + + meta_rectangle_from_clutter_rect (&tmp, META_ROUNDING_STRATEGY_GROW, dest); }