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:
parent
de2aac7a3d
commit
32cb2ee720
@ -297,6 +297,22 @@ gboolean
|
|||||||
mtk_rectangle_contains_point (const MtkRectangle *rect,
|
mtk_rectangle_contains_point (const MtkRectangle *rect,
|
||||||
int x,
|
int x,
|
||||||
int y)
|
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 &&
|
return (x >= rect->x &&
|
||||||
x < (rect->x + rect->width) &&
|
x < (rect->x + rect->width) &&
|
||||||
|
@ -131,6 +131,10 @@ MTK_EXPORT
|
|||||||
gboolean mtk_rectangle_contains_point (const MtkRectangle *rect,
|
gboolean mtk_rectangle_contains_point (const MtkRectangle *rect,
|
||||||
int x,
|
int x,
|
||||||
int y);
|
int y);
|
||||||
|
MTK_EXPORT
|
||||||
|
gboolean mtk_rectangle_contains_pointf (const MtkRectangle *rect,
|
||||||
|
float x,
|
||||||
|
float y);
|
||||||
|
|
||||||
MTK_EXPORT
|
MTK_EXPORT
|
||||||
graphene_rect_t mtk_rectangle_to_graphene_rect (const MtkRectangle *rect);
|
graphene_rect_t mtk_rectangle_to_graphene_rect (const MtkRectangle *rect);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user