From 81da7830cb098eaccd1d444a8bd5defa37a25b84 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 16 Jul 2023 13:28:34 +0000 Subject: Bug [f9eddb541a] (TkSetRegion(), XSetClipRectangles): Patch 5 from Christopher Chavez - Implement XSetClipRectangles() on Windows by relocating the existing Aqua implementation --- generic/tkInt.decls | 10 ++++------ generic/tkIntXlibDecls.h | 10 +++++++--- generic/tkStubInit.c | 2 +- macosx/tkMacOSXXStubs.c | 24 ------------------------ xlib/xgc.c | 27 ++++++++++++++++++++++++++- 5 files changed, 38 insertions(+), 35 deletions(-) diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 7f68cf1..8106b83 100644 --- a/generic/tkInt.decls +++ b/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 a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 9d4200a..1040c4f 100644 --- a/generic/tkIntXlibDecls.h +++ b/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 a/generic/tkStubInit.c b/generic/tkStubInit.c index 47742c1..8b12e05 100644 --- a/generic/tkStubInit.c +++ b/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 a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 1973f5d..dbf4e09 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -721,30 +721,6 @@ XSync( 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 a/xlib/xgc.c b/xlib/xgc.c index ba186b4..1a5dd81 100644 --- a/xlib/xgc.c +++ b/xlib/xgc.c @@ -432,7 +432,7 @@ XSetClipOrigin( /* *---------------------------------------------------------------------- * - * TkSetRegion, XSetClipMask -- + * TkSetRegion, XSetClipMask, XSetClipRectangles -- * * Sets the clipping region/pixmap for a GC. * @@ -488,6 +488,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). */ -- cgit v0.12