Tk Source Code

Artifact [362749e2]
Login

Artifact 362749e22223b9419d7e0550a612777f0b38f388e130088fe0bbe5623e24d154:

Attachment "0005-Implement-XSetClipRectangles-on-Windows.patch" to ticket [f9eddb54] added by chrstphrchvz 2023-07-16 12:03:54.
From 21473714aa1ec5930c21d0b9421ecc82d0387c1a Mon Sep 17 00:00:00 2001
From: Christopher Chavez <[email protected]>
Date: Sun, 16 Jul 2023 00:22:49 -0500
Subject: [PATCH 5/6] Implement XSetClipRectangles() on Windows

---
 generic/tkInt.decls      | 10 ++++------
 generic/tkIntXlibDecls.h | 10 +++++++---
 generic/tkStubInit.c     |  2 +-
 macosx/tkMacOSXXStubs.c  | 25 -------------------------
 xlib/xgc.c               | 27 ++++++++++++++++++++++++++-
 5 files changed, 38 insertions(+), 36 deletions(-)

diff --git generic/tkInt.decls generic/tkInt.decls
index 7f68cf106..8106b83b4 100644
--- generic/tkInt.decls
+++ generic/tkInt.decls
@@ -1335,12 +1335,10 @@ declare 80 win {
 	    Drawable d, GC gc, XImage *image, int src_x, int src_y,
 	    int dest_x, int dest_y, unsigned int width, unsigned int height)
 }
-# This slot is reserved for use by the clipping rectangle patch:
-#  declare 81 win {
-#      XSetClipRectangles(Display *display, GC gc, int clip_x_origin,
-#  	    int clip_y_origin, XRectangle rectangles[], int n, int ordering)
-#  }
-
+declare 81 win {
+    int XSetClipRectangles(Display *display, GC gc, int clip_x_origin,
+	    int clip_y_origin, XRectangle rectangles[], int n, int ordering)
+}
 declare 82 win {
     Status XParseColor(Display *display, Colormap map,
           _Xconst char *spec, XColor *colorPtr)
diff --git generic/tkIntXlibDecls.h generic/tkIntXlibDecls.h
index 9d4200a86..586d6252d 100644
--- generic/tkIntXlibDecls.h
+++ generic/tkIntXlibDecls.h
@@ -275,7 +275,10 @@ EXTERN int		TkPutImage(unsigned long *colors, int ncolors,
 				XImage *image, int src_x, int src_y,
 				int dest_x, int dest_y, unsigned int width,
 				unsigned int height);
-/* Slot 81 is reserved */
+/* 81 */
+EXTERN int		XSetClipRectangles(Display *display, GC gc,
+				int clip_x_origin, int clip_y_origin,
+				XRectangle rectangles[], int n, int ordering);
 /* 82 */
 EXTERN Status		XParseColor(Display *display, Colormap map,
 				_Xconst char *spec, XColor *colorPtr);
@@ -879,7 +882,7 @@ typedef struct TkIntXlibStubs {
     Bool (*xFilterEvent) (XEvent *x, Window w); /* 78 */
     int (*xmbLookupString) (XIC xi, XKeyPressedEvent *xk, char *c, int i, KeySym *k, Status *s); /* 79 */
     int (*tkPutImage) (unsigned long *colors, int ncolors, Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height); /* 80 */
-    void (*reserved81)(void);
+    int (*xSetClipRectangles) (Display *display, GC gc, int clip_x_origin, int clip_y_origin, XRectangle rectangles[], int n, int ordering); /* 81 */
     Status (*xParseColor) (Display *display, Colormap map, _Xconst char *spec, XColor *colorPtr); /* 82 */
     GC (*xCreateGC) (Display *display, Drawable d, unsigned long valuemask, XGCValues *values); /* 83 */
     int (*xFreeGC) (Display *display, GC gc); /* 84 */
@@ -1296,7 +1299,8 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr;
 	(tkIntXlibStubsPtr->xmbLookupString) /* 79 */
 #define TkPutImage \
 	(tkIntXlibStubsPtr->tkPutImage) /* 80 */
-/* Slot 81 is reserved */
+#define XSetClipRectangles \
+	(tkIntXlibStubsPtr->xSetClipRectangles) /* 81 */
 #define XParseColor \
 	(tkIntXlibStubsPtr->xParseColor) /* 82 */
 #define XCreateGC \
diff --git generic/tkStubInit.c generic/tkStubInit.c
index 47742c171..8b12e052c 100644
--- generic/tkStubInit.c
+++ generic/tkStubInit.c
@@ -770,7 +770,7 @@ static const TkIntXlibStubs tkIntXlibStubs = {
     XFilterEvent, /* 78 */
     XmbLookupString, /* 79 */
     TkPutImage, /* 80 */
-    0, /* 81 */
+    XSetClipRectangles, /* 81 */
     XParseColor, /* 82 */
     XCreateGC, /* 83 */
     XFreeGC, /* 84 */
diff --git macosx/tkMacOSXXStubs.c macosx/tkMacOSXXStubs.c
index 1973f5d00..8c54ae388 100644
--- macosx/tkMacOSXXStubs.c
+++ macosx/tkMacOSXXStubs.c
@@ -720,31 +720,6 @@ XSync(
     LastKnownRequestProcessed(display)++;
     return 0;
 }
-
-int
-XSetClipRectangles(
-    Display *d,
-    GC gc,
-    int clip_x_origin,
-    int clip_y_origin,
-    XRectangle* rectangles,
-    int n,
-    TCL_UNUSED(int))
-{
-    TkRegion clipRgn = TkCreateRegion();
-
-    while (n--) {
-    	XRectangle rect = *rectangles;
-
-    	rect.x += clip_x_origin;
-    	rect.y += clip_y_origin;
-    	TkUnionRectWithRegion(&rect, clipRgn, clipRgn);
-    	rectangles++;
-    }
-    TkSetRegion(d, gc, clipRgn);
-    TkDestroyRegion(clipRgn);
-    return 1;
-}
 /*
  *----------------------------------------------------------------------
  *
diff --git xlib/xgc.c xlib/xgc.c
index 13d08cd3d..0562982a5 100644
--- xlib/xgc.c
+++ xlib/xgc.c
@@ -432,7 +432,7 @@ XSetClipOrigin(
 /*
  *----------------------------------------------------------------------
  *
- * TkSetRegion, XSetClipMask --
+ * TkSetRegion, XSetClipMask, XSetClipRectangles --
  *
  *	Sets the clipping region/pixmap for a GC.
  *
@@ -489,6 +489,31 @@ XSetClipMask(
     return Success;
 }
 
+int
+XSetClipRectangles(
+    Display *d,
+    GC gc,
+    int clip_x_origin,
+    int clip_y_origin,
+    XRectangle* rectangles,
+    int n,
+    TCL_UNUSED(int))
+{
+    TkRegion clipRgn = TkCreateRegion();
+
+    while (n--) {
+	XRectangle rect = *rectangles;
+
+	rect.x += clip_x_origin;
+	rect.y += clip_y_origin;
+	TkUnionRectWithRegion(&rect, clipRgn, clipRgn);
+	rectangles++;
+    }
+    TkSetRegion(d, gc, clipRgn);
+    TkDestroyRegion(clipRgn);
+    return 1;
+}
+
 /*
  * Some additional dummy functions (hopefully implemented soon).
  */
-- 
2.39.2 (Apple Git-144)