boxes: Add function to create a rectangle from floating clutter rect
Meta rectangles are integer based while clutter works in floating coordinates, so when converting to integers we need a strategy. Implement the shrink strategy by ceiling the coordinates and flooring the width, and the grow strategy reusing clutter facility for this. https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
This commit is contained in:
parent
9d9d455bba
commit
a8c972cd6b
@ -274,6 +274,10 @@ void meta_rectangle_transform (const MetaRectangle *rect,
|
|||||||
int height,
|
int height,
|
||||||
MetaRectangle *dest);
|
MetaRectangle *dest);
|
||||||
|
|
||||||
|
void meta_rectangle_from_clutter_rect (ClutterRect *rect,
|
||||||
|
MetaRoundingStrategy rounding_strategy,
|
||||||
|
MetaRectangle *dest);
|
||||||
|
|
||||||
void meta_rectangle_crop_and_scale (const MetaRectangle *rect,
|
void meta_rectangle_crop_and_scale (const MetaRectangle *rect,
|
||||||
ClutterRect *src_rect,
|
ClutterRect *src_rect,
|
||||||
int dst_width,
|
int dst_width,
|
||||||
|
@ -2151,6 +2151,39 @@ meta_rectangle_transform (const MetaRectangle *rect,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_rectangle_from_clutter_rect (ClutterRect *rect,
|
||||||
|
MetaRoundingStrategy rounding_strategy,
|
||||||
|
MetaRectangle *dest)
|
||||||
|
{
|
||||||
|
switch (rounding_strategy)
|
||||||
|
{
|
||||||
|
case META_ROUNDING_STRATEGY_SHRINK:
|
||||||
|
{
|
||||||
|
*dest = (MetaRectangle) {
|
||||||
|
.x = ceilf (rect->origin.x),
|
||||||
|
.y = ceilf (rect->origin.y),
|
||||||
|
.width = floorf (rect->origin.x + rect->size.width) - dest->x,
|
||||||
|
.height = floorf (rect->origin.y + rect->size.height) - dest->x,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case META_ROUNDING_STRATEGY_GROW:
|
||||||
|
{
|
||||||
|
ClutterRect clamped = *rect;
|
||||||
|
clutter_rect_clamp_to_pixel (&clamped);
|
||||||
|
|
||||||
|
*dest = (MetaRectangle) {
|
||||||
|
.x = clamped.origin.x,
|
||||||
|
.y = clamped.origin.y,
|
||||||
|
.width = clamped.size.width,
|
||||||
|
.height = clamped.size.height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_rectangle_crop_and_scale (const MetaRectangle *rect,
|
meta_rectangle_crop_and_scale (const MetaRectangle *rect,
|
||||||
ClutterRect *src_rect,
|
ClutterRect *src_rect,
|
||||||
|
Loading…
Reference in New Issue
Block a user