diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2017-05-12 11:46:33 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2017-05-25 16:25:58 +0200 |
commit | fee289cd0632adcc563378c41350834207436648 (patch) | |
tree | a7fbbf75c0e682aac7d1db1939a8d0c229093086 /gdk/gdkrectangle.c | |
parent | 28f8a27d652127b600a6ae1baee3bad5770bfa20 (diff) | |
download | gtk+-fee289cd0632adcc563378c41350834207436648.tar.gz |
gdk: Add gdk_rectangle_contains_point() call
A little helper function for a somewhat common operation.
Diffstat (limited to 'gdk/gdkrectangle.c')
-rw-r--r-- | gdk/gdkrectangle.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gdk/gdkrectangle.c b/gdk/gdkrectangle.c index 491de6c1e5..6e6fa61eb2 100644 --- a/gdk/gdkrectangle.c +++ b/gdk/gdkrectangle.c @@ -137,6 +137,31 @@ gdk_rectangle_intersect (const GdkRectangle *src1, } /** + * gdk_rectangle_contains_point: + * @rect: a #GdkRectangle + * @x: X coordinate + * @y: Y coordinate + * + * Returns #TRUE if @rect contains the point described by @x and @y. + * + * Returns: #TRUE if @rect contains the point + * + * Since: 3.90 + **/ +gboolean +gdk_rectangle_contains_point (const GdkRectangle *rect, + int x, + int y) +{ + g_return_val_if_fail (rect != NULL, FALSE); + + return x >= rect->x && + x < rect->x + rect->width && + y >= rect->y && + y < rect->y + rect->height; +} + +/** * gdk_rectangle_equal: * @rect1: a #GdkRectangle * @rect2: a #GdkRectangle |