From a96d8432b0d060a224e085c330dfc9ae9b9537de Mon Sep 17 00:00:00 2001
From: Christopher Chavez <chrischavez@gmx.us>
Date: Sun, 16 Jul 2023 00:06:12 -0500
Subject: [PATCH 1/6] Add TkpCopyRegion()

---
 generic/tkInt.h         |  2 ++
 macosx/tkMacOSXRegion.c | 24 ++++++++++++++++++++++++
 unix/tkUnix.c           | 26 ++++++++++++++++++++++++++
 win/tkWinRegion.c       | 24 ++++++++++++++++++++++++
 4 files changed, 76 insertions(+)

diff --git generic/tkInt.h generic/tkInt.h
index 7568585fa..e31bc1b1e 100644
--- generic/tkInt.h
+++ generic/tkInt.h
@@ -1337,6 +1337,8 @@ MODULE_SCOPE Status TkParseColor (Display * display,
 MODULE_SCOPE void	TkUnixSetXftClipRegion(TkRegion clipRegion);
 #endif
 
+MODULE_SCOPE void	TkpCopyRegion(TkRegion dst, TkRegion src);
+
 #if !defined(__cplusplus) && !defined(c_plusplus)
 # define c_class class
 #endif
diff --git macosx/tkMacOSXRegion.c macosx/tkMacOSXRegion.c
index fbb41cb95..043038c5d 100644
--- macosx/tkMacOSXRegion.c
+++ macosx/tkMacOSXRegion.c
@@ -23,6 +23,30 @@ static int totalRegionRetainCount = 0;
 #define DebugLog(msg, ...)
 #endif
 
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpCopyRegion --
+ *
+ *  Makes the destination region a copy of the source region.
+ *
+ * Results:
+ *	None.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpCopyRegion(
+    TkRegion dst,
+    TkRegion src)
+{
+    ChkErr(HIShapeSetWithShape, (HIMutableShapeRef) dst, (HIShapeRef) src);
+}
 
 /*
  *----------------------------------------------------------------------
diff --git unix/tkUnix.c unix/tkUnix.c
index ed024d122..23e89a998 100644
--- unix/tkUnix.c
+++ unix/tkUnix.c
@@ -113,6 +113,32 @@ Tk_UpdatePointer(
    */
 }
 
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpCopyRegion --
+ *
+ *  Makes the destination region a copy of the source region.
+ *	Currently unused on X11.
+ *
+ * Results:
+ *	None.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpCopyRegion(
+    TkRegion dst,
+    TkRegion src)
+{
+    /* XUnionRegion() in Xlib is optimized to detect copying */
+    XUnionRegion(src, src, dst);
+}
+
 /*
  *----------------------------------------------------------------------
  *
diff --git win/tkWinRegion.c win/tkWinRegion.c
index a2f6fd7cf..dae248a67 100644
--- win/tkWinRegion.c
+++ win/tkWinRegion.c
@@ -19,6 +19,30 @@
 #undef TkRectInRegion
 #undef TkSubtractRegion
 
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpCopyRegion --
+ *
+ *  Makes the destination region a copy of the source region.
+ *
+ * Results:
+ *	None.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpCopyRegion(
+    TkRegion dst,
+    TkRegion src)
+{
+    CombineRgn((HRGN) dst, (HRGN) src, NULL, RGN_COPY);
+}
+
 /*
  *----------------------------------------------------------------------
  *
-- 
2.39.2 (Apple Git-144)

