[gnome-flashback] rectangle: add function to check if rectangle is adjacent to region
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] rectangle: add function to check if rectangle is adjacent to region
- Date: Sat, 23 Oct 2021 18:48:45 +0000 (UTC)
commit 1463e4dee6cb4215f7eb78744a23dcea747fbd44
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Sep 13 14:56:40 2021 +0300
rectangle: add function to check if rectangle is adjacent to region
Based on mutter commit:
https://gitlab.gnome.org/GNOME/mutter/-/commit/58c2f423f761
backends/gf-rectangle-private.h | 11 +++++++----
backends/gf-rectangle.c | 20 ++++++++++++++++++++
2 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/backends/gf-rectangle-private.h b/backends/gf-rectangle-private.h
index acea48c..773f11a 100644
--- a/backends/gf-rectangle-private.h
+++ b/backends/gf-rectangle-private.h
@@ -26,11 +26,14 @@
G_BEGIN_DECLS
-gboolean gf_rectangle_overlaps_with_region (const GList *spanning_rects,
- const GfRectangle *rect);
+gboolean gf_rectangle_overlaps_with_region (const GList *spanning_rects,
+ const GfRectangle *rect);
-gboolean gf_rectangle_is_adjacent_to (const GfRectangle *rect,
- const GfRectangle *other);
+gboolean gf_rectangle_is_adjacent_to_any_in_region (const GList *spanning_rects,
+ GfRectangle *rect);
+
+gboolean gf_rectangle_is_adjacent_to (const GfRectangle *rect,
+ const GfRectangle *other);
G_END_DECLS
diff --git a/backends/gf-rectangle.c b/backends/gf-rectangle.c
index ca71d42..0571c4e 100644
--- a/backends/gf-rectangle.c
+++ b/backends/gf-rectangle.c
@@ -89,6 +89,26 @@ gf_rectangle_overlaps_with_region (const GList *spanning_rects,
return overlaps;
}
+gboolean
+gf_rectangle_is_adjacent_to_any_in_region (const GList *spanning_rects,
+ GfRectangle *rect)
+{
+ const GList *l;
+
+ for (l = spanning_rects; l; l = l->next)
+ {
+ GfRectangle *other = (GfRectangle *) l->data;
+
+ if (rect == other || gf_rectangle_equal (rect, other))
+ continue;
+
+ if (gf_rectangle_is_adjacent_to (rect, other))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
gboolean
gf_rectangle_is_adjacent_to (const GfRectangle *rect,
const GfRectangle *other)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]