summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2015-01-04 23:22:29 (GMT)
committerKevin Walzer <kw@codebykevin.com>2015-01-04 23:22:29 (GMT)
commit3fd4914af5da89ce545fe0857f34a460cf781c0b (patch)
tree4433eab0933d522c5e1679269ed90e072ef75529
parent2f75423051e6eda811bcdfeadd4b5397d12baae2 (diff)
downloadtk-3fd4914af5da89ce545fe0857f34a460cf781c0b.zip
tk-3fd4914af5da89ce545fe0857f34a460cf781c0b.tar.gz
tk-3fd4914af5da89ce545fe0857f34a460cf781c0b.tar.bz2
Improved scrolling for text under Cocoa; thanks to Marc Culler for patch.
-rw-r--r--generic/tkTextDisp.c34
-rw-r--r--macosx/tkMacOSXDraw.c9
2 files changed, 39 insertions, 4 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index f16c45b..ac0b95a 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -3883,6 +3883,21 @@ TkTextUpdateOneLine(
*
*----------------------------------------------------------------------
*/
+#ifdef MAC_OSX_TK
+static void
+RedisplayText(
+ ClientData clientData )
+{
+ register TkText *textPtr = (TkText *) clientData;
+ TextDInfo *dInfoPtr = textPtr->dInfoPtr;
+ TkRegion damageRegion = TkCreateRegion();
+ XRectangle rectangle = {0, 0, dInfoPtr->maxX, dInfoPtr->maxY};
+ TkUnionRectWithRegion(&rectangle, damageRegion, damageRegion);
+
+ TextInvalidateRegion(textPtr, damageRegion);
+ DisplayText(clientData);
+}
+#endif
static void
DisplayText(
@@ -3897,6 +3912,9 @@ DisplayText(
int bottomY = 0; /* Initialization needed only to stop compiler
* warnings. */
Tcl_Interp *interp;
+#ifdef MAC_OSX_TK
+ Tcl_TimerToken macRefreshTimer = NULL;
+#endif
if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
/*
@@ -4099,6 +4117,22 @@ DisplayText(
oldY, dInfoPtr->maxX-dInfoPtr->x, height, 0, y-oldY,
damageRgn)) {
TextInvalidateRegion(textPtr, damageRgn);
+
+#ifdef MAC_OSX_TK
+
+ /*
+ * On OS X large scrolls sometimes leave garbage on the screen.
+ * This attempts to clean it up by redisplaying the Text window
+ * after 200 milliseconds.
+ */
+ if ( abs(y-oldY) > 14 ) {
+ Tcl_DeleteTimerHandler(macRefreshTimer);
+ macRefreshTimer = Tcl_CreateTimerHandler(200,
+ RedisplayText,
+ clientData);
+ }
+#endif
+
}
numCopies++;
TkDestroyRegion(damageRgn);
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index d4b2c85..ecc6c0d 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -1531,10 +1531,11 @@ TkScrollWindow(
}
}
}
-
- /* Redisplay the scrolled area. */
- [view displayRect:scrollDst];
-
+
+ /* Redisplay the scrolled area; hide to reduce flicker after removal of private API calls. */
+ [view setHidden:YES];
+ [view displayRect:scrollDst];
+ [view setHidden:NO];
}
}