Tk Source Code

Check-in [50de0a3a]
Login
EuroTcl/OpenACS 11 - 12 JULY 2024, VIENNA

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Remove inner loop in setFrameSize, tame the chaos with UpdateClipRgn, deal with the artifacts later.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | cgimage_with_crossing
Files: files | file ages | folders
SHA3-256: 50de0a3a741ac0a57323880d71415127ed705706938e5b570d9fc6a39a480976
User & Date: culler 2024-06-18 12:17:43
Context
2024-06-19
14:30
Clean up setFrameSize. check-in: acb0217c user: culler tags: cgimage_with_crossing
2024-06-18
12:17
Remove inner loop in setFrameSize, tame the chaos with UpdateClipRgn, deal with the artifacts later. check-in: 50de0a3a user: culler tags: cgimage_with_crossing
2024-06-15
12:36
Merge main check-in: cb59e6b2 user: culler tags: cgimage_with_crossing
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to macosx/tkMacOSXDraw.c.

1534
1535
1536
1537
1538
1539
1540


1541
1542
1543
1544

1545
1546
1547
1548
1549
1550
1551
1552
1553
1554


1555
1556
1557
1558
1559
1560
1561
	CGContextSetRGBFillColor(context, 0.0, 1.0, 0.0, 0.1);
	CGContextEOFillPath(context);
	CGContextRestoreGState(context);
#endif /* TK_MAC_DEBUG_DRAWING */
    }

    if (macDraw->drawRgn) {


	clipRgn = HIShapeCreateCopy(macDraw->drawRgn);
    } else if (macDraw->visRgn) {
	clipRgn = HIShapeCreateCopy(macDraw->visRgn);
    }

    return clipRgn;
}

/*
 *----------------------------------------------------------------------
 *
 * Tk_ClipDrawableToRect --
 *
 *	Clip all drawing into the drawable d to the given rectangle. If width
 *	or height are negative, reset to no clipping.


 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Subsequent drawing into d is offset and clipped as specified.
 *







>
>




>









|
>
>







1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
	CGContextSetRGBFillColor(context, 0.0, 1.0, 0.0, 0.1);
	CGContextEOFillPath(context);
	CGContextRestoreGState(context);
#endif /* TK_MAC_DEBUG_DRAWING */
    }

    if (macDraw->drawRgn) {
	// The drawRgn is the visRgn intersected with a rectangle which
	// may be smaller than the widget bounds.
	clipRgn = HIShapeCreateCopy(macDraw->drawRgn);
    } else if (macDraw->visRgn) {
	clipRgn = HIShapeCreateCopy(macDraw->visRgn);
    }
    // A NULL clipRgn does not allow any drawing at all.
    return clipRgn;
}

/*
 *----------------------------------------------------------------------
 *
 * Tk_ClipDrawableToRect --
 *
 *	Clip all drawing into the drawable d to the given rectangle. If width
 *	or height are negative, reset to no clipping.bThis is called by the
 *      Text widget to display each DLine, and by the Canvas widget when it
 *      is updating a sub rectangle in the canvas.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Subsequent drawing into d is offset and clipped as specified.
 *
1576
1577
1578
1579
1580
1581
1582



1583
1584
1585
1586
1587
1588
1589
1590
	macDraw->drawRgn = NULL;
    }
    if (width >= 0 && height >= 0) {
	CGRect clipRect = CGRectMake(x + macDraw->xOff, y + macDraw->yOff,
		width, height);
	HIShapeRef drawRgn = HIShapeCreateWithRect(&clipRect);




	if (macDraw->winPtr && macDraw->flags & TK_CLIP_INVALID) {
	    TkMacOSXUpdateClipRgn(macDraw->winPtr);
	}
	if (macDraw->visRgn) {
	    macDraw->drawRgn = HIShapeCreateIntersection(macDraw->visRgn,
		    drawRgn);
	    CFRelease(drawRgn);
	} else {







>
>
>
|







1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
	macDraw->drawRgn = NULL;
    }
    if (width >= 0 && height >= 0) {
	CGRect clipRect = CGRectMake(x + macDraw->xOff, y + macDraw->yOff,
		width, height);
	HIShapeRef drawRgn = HIShapeCreateWithRect(&clipRect);

	// When drawing a Text widget we can reuse the
	// clipping region for different DLines, so we don't want to
	// update unless necessary.
	if (macDraw->winPtr && (macDraw->flags & TK_CLIP_INVALID)) {
	    TkMacOSXUpdateClipRgn(macDraw->winPtr);
	}
	if (macDraw->visRgn) {
	    macDraw->drawRgn = HIShapeCreateIntersection(macDraw->visRgn,
		    drawRgn);
	    CFRelease(drawRgn);
	} else {

Changes to macosx/tkMacOSXSubwindows.c.

363
364
365
366
367
368
369

370
371
372
373
374
375
376
377

	/*
	 * Rebuild the clip regions for the parent so it will be allowed
	 * to draw in the space from which this subwindow was removed and then
	 * redraw the window.
	 */


	TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
	// if (parentPtr && parentPtr->privatePtr->visRgn) {
	//     TkMacOSXInvalidateViewRegion(
	// 	    TkMacOSXGetNSViewForDrawable(parentPtr->window),
	// 	    parentPtr->privatePtr->visRgn);
	// }
	//TkMacOSXInvalClipRgns((Tk_Window)parentPtr);
	//TkMacOSXUpdateClipRgn(parentPtr);







>
|







363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378

	/*
	 * Rebuild the clip regions for the parent so it will be allowed
	 * to draw in the space from which this subwindow was removed and then
	 * redraw the window.
	 */

	TkMacOSXInvalClipRgns((Tk_Window)winPtr->parentPtr);
	//TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
	// if (parentPtr && parentPtr->privatePtr->visRgn) {
	//     TkMacOSXInvalidateViewRegion(
	// 	    TkMacOSXGetNSViewForDrawable(parentPtr->window),
	// 	    parentPtr->privatePtr->visRgn);
	// }
	//TkMacOSXInvalClipRgns((Tk_Window)parentPtr);
	//TkMacOSXUpdateClipRgn(parentPtr);
962
963
964
965
966
967
968

969
970
971
972
973
974
975
	if (!macWin->visRgn) {
	    macWin->visRgn = HIShapeCreateCopy(macWin->aboveVisRgn);
	}
	macWin->flags &= ~TK_CLIP_INVALID;
    }
}


/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXVisableClipRgn --
 *
 *	This function returns the Macintosh clipping region for the given
 *	window. The caller is responsible for disposing of the returned region







>







963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
	if (!macWin->visRgn) {
	    macWin->visRgn = HIShapeCreateCopy(macWin->aboveVisRgn);
	}
	macWin->flags &= ~TK_CLIP_INVALID;
    }
}

// Unused and misspelled stub function
/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXVisableClipRgn --
 *
 *	This function returns the Macintosh clipping region for the given
 *	window. The caller is responsible for disposing of the returned region

Changes to macosx/tkMacOSXWindowEvent.c.

1068
1069
1070
1071
1072
1073
1074

1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
	 /*
	  * Generate and handle a ConfigureNotify event for the new size.
	  */

	TkGenWMConfigureEvent(tkwin, Tk_X(tkwin), Tk_Y(tkwin), width, height,
		TK_SIZE_CHANGED | TK_MACOSX_HANDLE_EVENT_IMMEDIATELY);
    	oldProc = Tk_RestrictEvents(ConfigureRestrictProc, NULL, &oldArg);

    	Tk_RestrictEvents(oldProc, oldArg, &oldArg);

	/*
	 * To make the reconfiguration actually happen we need to process idle
	 * tasks generated when processing the ConfigureNotify events.  We also
	 * process timer events because the Text widget updates line metrics
	 * asynchronously using timer tasks. Skipping those updates can (but
	 * shouldn't) cause crashes when resizing a complex Text widget with
	 * embedded windows. The crash occurs if an embedded window is mapped
	 * for the first time while the window is being resized.
	 */

	while (Tcl_DoOneEvent(TCL_TIMER_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {}

	/*
	 * Now that Tk has configured all subwindows, create the clip regions.
	 */

	TkMacOSXInvalClipRgns(tkwin);
	TkMacOSXUpdateClipRgn(winPtr);
	//TkMacOSXSetDrawingEnabled(winPtr, 1);

	/*
	 * Redraw the entire content view.
	 */

	if ([self inLiveResize]) {
	    [self viewDidChangeBackingProperties];
	    [self setNeedsDisplay:YES];







>


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







1068
1069
1070
1071
1072
1073
1074
1075
1076
1077




















1078
1079
1080
1081
1082
1083
1084
	 /*
	  * Generate and handle a ConfigureNotify event for the new size.
	  */

	TkGenWMConfigureEvent(tkwin, Tk_X(tkwin), Tk_Y(tkwin), width, height,
		TK_SIZE_CHANGED | TK_MACOSX_HANDLE_EVENT_IMMEDIATELY);
    	oldProc = Tk_RestrictEvents(ConfigureRestrictProc, NULL, &oldArg);
	while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {}
    	Tk_RestrictEvents(oldProc, oldArg, &oldArg);





















	/*
	 * Redraw the entire content view.
	 */

	if ([self inLiveResize]) {
	    [self viewDidChangeBackingProperties];
	    [self setNeedsDisplay:YES];

Changes to macosx/tkMacOSXWm.c.

288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
	wmPtr->yInParent = (frameRect.origin.y + frameRect.size.height -
	    contentRect.origin.y - contentRect.size.height);
	wmPtr->parentWidth = winPtr->changes.width + frameRect.size.width -
	    contentRect.size.width;
	wmPtr->parentHeight = winPtr->changes.height + frameRect.size.height -
	    contentRect.size.height;
	TkMacOSXInvalClipRgns((Tk_Window)winPtr);
	TkMacOSXUpdateClipRgn(winPtr);
    }
}
#endif

typedef enum {
    WMATT_ALPHA, WMATT_APPEARANCE, WMATT_BUTTONS, WMATT_FULLSCREEN,
    WMATT_ISDARK, WMATT_MODIFIED, WMATT_NOTIFY, WMATT_TITLEPATH, WMATT_TOPMOST,







<







288
289
290
291
292
293
294

295
296
297
298
299
300
301
	wmPtr->yInParent = (frameRect.origin.y + frameRect.size.height -
	    contentRect.origin.y - contentRect.size.height);
	wmPtr->parentWidth = winPtr->changes.width + frameRect.size.width -
	    contentRect.size.width;
	wmPtr->parentHeight = winPtr->changes.height + frameRect.size.height -
	    contentRect.size.height;
	TkMacOSXInvalClipRgns((Tk_Window)winPtr);

    }
}
#endif

typedef enum {
    WMATT_ALPHA, WMATT_APPEARANCE, WMATT_BUTTONS, WMATT_FULLSCREEN,
    WMATT_ISDARK, WMATT_MODIFIED, WMATT_NOTIFY, WMATT_TITLEPATH, WMATT_TOPMOST,