[metacity] util: add meta_xserver_region_equal
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] util: add meta_xserver_region_equal
- Date: Sun, 13 Oct 2019 18:49:31 +0000 (UTC)
commit ce92e34f5b5ae99df76d5dc7778ab553b1c30fa8
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Oct 12 18:18:06 2019 +0300
util: add meta_xserver_region_equal
src/core/util.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/include/util.h | 5 +++++
2 files changed, 66 insertions(+)
---
diff --git a/src/core/util.c b/src/core/util.c
index dbf6f135..193bb82a 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -495,3 +495,64 @@ meta_show_dialog (const char *type,
return child_pid;
}
+
+gboolean
+meta_xserver_region_equal (Display *xdisplay,
+ XserverRegion region1,
+ XserverRegion region2)
+{
+ XRectangle *region1_rects;
+ int region1_nrects;
+ XRectangle *region2_rects;
+ int region2_nrects;
+ int i;
+
+ if (region1 == region2)
+ return TRUE;
+
+ if ((region1 != None && region2 == None) ||
+ (region1 == None && region2 != None))
+ return FALSE;
+
+ region1_rects = XFixesFetchRegion (xdisplay, region1, ®ion1_nrects);
+ region2_rects = XFixesFetchRegion (xdisplay, region2, ®ion2_nrects);
+
+ if ((region1_rects != NULL && region2_rects == NULL) ||
+ (region1_rects == NULL && region2_rects != NULL))
+ {
+ if (region1_rects != NULL)
+ XFree (region1_rects);
+
+ if (region2_rects != NULL)
+ XFree (region2_rects);
+
+ return FALSE;
+ }
+
+ if (region1_nrects != region2_nrects)
+ {
+ XFree (region1_rects);
+ XFree (region2_rects);
+
+ return FALSE;
+ }
+
+ for (i = 0; i < region1_nrects; i++)
+ {
+ if (region1_rects[i].x != region2_rects[i].x ||
+ region1_rects[i].y != region2_rects[i].y ||
+ region1_rects[i].width != region2_rects[i].width ||
+ region1_rects[i].height != region2_rects[i].height)
+ {
+ XFree (region1_rects);
+ XFree (region2_rects);
+
+ return FALSE;
+ }
+ }
+
+ XFree (region1_rects);
+ XFree (region2_rects);
+
+ return TRUE;
+}
diff --git a/src/include/util.h b/src/include/util.h
index 546e79c6..4cca299d 100644
--- a/src/include/util.h
+++ b/src/include/util.h
@@ -24,6 +24,7 @@
#define META_UTIL_H
#include <glib.h>
+#include <X11/extensions/Xfixes.h>
G_BEGIN_DECLS
@@ -97,6 +98,10 @@ GPid meta_show_dialog (const char *type,
GSList *columns,
GSList *entries);
+gboolean meta_xserver_region_equal (Display *xdisplay,
+ XserverRegion region1,
+ XserverRegion region2);
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]