From 18a0842ba8c41cedaa8621ca6bad17d537ec9106 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 25 Oct 2017 19:10:03 +0000 Subject: Make a small change in the logic of DisplayText (for Mac only) which causes all visible embedded windows to be redisplayed when they move. This obviates the need for TkScrollWindow to generate expose events. --- generic/tkTextDisp.c | 24 +++++++++++++++++++++--- library/demos/twind.tcl | 5 ++--- macosx/tkMacOSXDraw.c | 19 ------------------- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 623882d..a4d190b 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4274,7 +4274,6 @@ DisplayText( } dlPtr = dlPtr->nextPtr; } - /* * Scan through the lines following the copied ones to see if we are * going to overwrite them with the copy operation. If so, mark them @@ -4440,11 +4439,31 @@ DisplayText( } dlPtr->oldY = dlPtr->y; dlPtr->flags &= ~(NEW_LAYOUT | OLD_Y_INVALID); +#ifdef MAC_OSX_TK + } else if (dlPtr->chunkPtr != NULL) { + /* + * On the Mac we need to redisplay all embedded windows which + * were moved in order to make sure that the clipping region + * for the Text widget is maintained correctly. If an embedded + * window is moved but its bounding rectangle is not added back + * to the clipping region of the Text widget then drawing into + * the old bounding rectangle will not be allowed, causing an + * image of the embedded window to remain on the screen in the + * old position. In other words, a "ghost window" will appear. + * + * Perhaps all platforms should do this, rather than allow the + * embedded window to have incorrect values for Tk_X and TK_Y. + * But apparently this is not known to cause problems. + */ +#else } else if (dlPtr->chunkPtr != NULL && ((dlPtr->y < 0) || (dlPtr->y + dlPtr->height > dInfoPtr->maxY))) { +#endif register TkTextDispChunk *chunkPtr; - /* + /* + * On platforms other than the Mac: + * * It's the first or last DLine which are also overlapping the * top or bottom of the window, but we decided above it wasn't * necessary to display them (we were able to update them by @@ -4486,7 +4505,6 @@ DisplayText( dlPtr->baseline - dlPtr->spaceAbove, NULL, (Drawable) None, dlPtr->y + dlPtr->spaceAbove); } - } } #ifndef TK_NO_DOUBLE_BUFFERING diff --git a/library/demos/twind.tcl b/library/demos/twind.tcl index 2803585..39e5110 100644 --- a/library/demos/twind.tcl +++ b/library/demos/twind.tcl @@ -85,9 +85,8 @@ $t insert end " widget. Notice how peer widgets can have different " $t insert end "font settings, and by default contain all the images " $t insert end "of the 'parent', but that the embedded windows, " $t insert end "such as buttons may not appear in the peer. To ensure " -$t insert end "that embedded windows appear in all peers you can either " -$t insert end "use a script as the '-create' option or use a string " -$t insert end "containing %W as the '-window' option. " +$t insert end "that embedded windows appear in all peers you can set the " +$t insert end "'-create' option to a script or a string containing %W. " $t insert end "(The plot above and the 'Make A Peer' button are " $t insert end "designed to show up in all peers.) A good use of " $t insert end "peers is for " diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 91cfd03..c25f478 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1533,7 +1533,6 @@ TkScrollWindow( Drawable drawable = Tk_WindowId(tkwin); MacDrawable *macDraw = (MacDrawable *) drawable; TKContentView *view = (TKContentView *)TkMacOSXDrawableView(macDraw); - TkWindow *winPtr = (TkWindow *)tkwin; CGRect srcRect, dstRect; HIShapeRef dmgRgn = NULL, extraRgn = NULL; NSRect bounds, visRect, scrollSrc, scrollDst; @@ -1575,24 +1574,6 @@ TkScrollWindow( /* Scroll the rectangle. */ [view scrollRect:scrollSrc by:NSMakeSize(dx, -dy)]; - - /* - * If there are any subwindows we invalidate the window, in order - * to generate an expose event for the entire window. This is - * needed because the Text widget, which is the only one that calls - * TkScrollWindow, does not maintain correct position data or - * correctly map and unmap its subwindows while it is scrolling. - * This makes it impossible for us to maintain valid clipping - * regions for the Text widget, leading to "ghost windows" - * appearing in former locations of subwindows where drawing is - * still clipped after the subwindow has been moved somewhere else. - * It seems that the only way to bring the subwindow position data - * back into sync is to force a redraw of the entire window with - * the expose event that will be issued here. - */ - if (winPtr->childList != NULL) { - TkMacOSXInvalidateWindow(macDraw, TK_WINDOW_ONLY); - } } } else { dmgRgn = HIShapeCreateEmpty(); -- cgit v0.12