1
0
Fork 0

mtk: Add mtk_rectangle_contains_pointf()

This variant works on floating point coordinates, in order
to avoid undesired effects with rounding.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3820>
This commit is contained in:
Carlos Garnacho 2024-06-25 01:38:10 +02:00
parent de2aac7a3d
commit 32cb2ee720
2 changed files with 20 additions and 0 deletions

View file

@ -297,6 +297,22 @@ gboolean
mtk_rectangle_contains_point (const MtkRectangle *rect,
int x,
int y)
{
return mtk_rectangle_contains_pointf (rect, x, y);
}
/**
* mtk_rectangle_contains_pointf:
* @rect: A rectangle
* @x: X coordinate of the point
* @y: Y coordinate of the point
*
* Returns: Whether the rectangle contains the point
*/
gboolean
mtk_rectangle_contains_pointf (const MtkRectangle *rect,
float x,
float y)
{
return (x >= rect->x &&
x < (rect->x + rect->width) &&

View file

@ -131,6 +131,10 @@ MTK_EXPORT
gboolean mtk_rectangle_contains_point (const MtkRectangle *rect,
int x,
int y);
MTK_EXPORT
gboolean mtk_rectangle_contains_pointf (const MtkRectangle *rect,
float x,
float y);
MTK_EXPORT
graphene_rect_t mtk_rectangle_to_graphene_rect (const MtkRectangle *rect);