From 8713a1a4977a211504657d65a3d134b7c85bf0d3 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 31 Jul 2021 21:41:51 +0000 Subject: Use the correct coordinates to compute the damage region. This makes the tests pass again. --- macosx/tkMacOSXDraw.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 2830fa1..3d8f26e 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1144,7 +1144,7 @@ TkScrollWindow( TKContentView *view = (TKContentView *)TkMacOSXGetNSViewForDrawable(macDraw); HIShapeRef srcRgn, dstRgn; HIMutableShapeRef dmgRgn = HIShapeCreateMutable(); - NSRect bounds, scrollSrc, scrollDst; + NSRect bounds, viewSrcRect, srcRect, dstRect; int result = 0; if (view) { @@ -1154,29 +1154,31 @@ TkScrollWindow( */ bounds = [view bounds]; - scrollSrc = NSMakeRect(macDraw->xOff + x, + viewSrcRect = NSMakeRect(macDraw->xOff + x, bounds.size.height - height - (macDraw->yOff + y), width, height); - scrollDst = NSOffsetRect(scrollSrc, dx, -dy); /* - * Compute the damage. + * Scroll the rectangle. */ - srcRgn = HIShapeCreateWithRect(&scrollSrc); - dstRgn = HIShapeCreateWithRect(&scrollDst); - ChkErr(HIShapeDifference, srcRgn, dstRgn, dmgRgn); - result = HIShapeIsEmpty(dmgRgn) ? 0 : 1; + [view scrollRect:viewSrcRect by:NSMakeSize(dx, -dy)]; /* - * Scroll the rectangle. + * Compute the damage region, using Tk coordinates (origin at top left). */ - [view scrollRect:scrollSrc by:NSMakeSize(dx, -dy)]; + srcRect = CGRectMake(x, y, width, height); + dstRect = CGRectOffset(srcRect, dx, dy); + srcRgn = HIShapeCreateWithRect(&srcRect); + dstRgn = HIShapeCreateWithRect(&dstRect); + ChkErr(HIShapeDifference, srcRgn, dstRgn, dmgRgn); + result = HIShapeIsEmpty(dmgRgn) ? 0 : 1; + } /* - * Convert dmgRgn to Tk coordinates and store the result. + * Convert the HIShape dmgRgn into a TkRegion and store it. */ TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn); -- cgit v0.12