summaryrefslogtreecommitdiffstats
path: root/generic/tkTextDisp.c
diff options
context:
space:
mode:
authorculler <culler>2019-01-02 01:21:48 (GMT)
committerculler <culler>2019-01-02 01:21:48 (GMT)
commitdac8c5e71bad36669aaecfc25e3e82cefef6c1ed (patch)
treeaef73c2a0977a53bea0ef730806f2097659b7407 /generic/tkTextDisp.c
parent27d71c8a9216f3fd97537b0f3aaa6a7650aca3e1 (diff)
downloadtk-dac8c5e71bad36669aaecfc25e3e82cefef6c1ed.zip
tk-dac8c5e71bad36669aaecfc25e3e82cefef6c1ed.tar.gz
tk-dac8c5e71bad36669aaecfc25e3e82cefef6c1ed.tar.bz2
Use a flag bit instead of an int to store the sync state. Avoid running idle
tasks in the sync command if possible.
Diffstat (limited to 'generic/tkTextDisp.c')
-rw-r--r--generic/tkTextDisp.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 4ff9307..ae452c5 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -497,13 +497,15 @@ static TkTextDispChunk *baseCharChunkPtr = NULL;
* different character might be under the mouse
* cursor now). Need to recompute the current
* character before the next redisplay.
+ * OUT_OF_SYNC 1 means that the last <<WidgetViewSync>> event had
+ * value 0, indicating that the widget is out of sync.
*/
#define DINFO_OUT_OF_DATE 1
#define REDRAW_PENDING 2
#define REDRAW_BORDERS 4
#define REPICK_NEEDED 8
-
+#define OUT_OF_SYNC 16
/*
* Action values for FreeDLines:
*
@@ -3152,8 +3154,12 @@ GenerateWidgetViewSyncEvent(
FORCE_DISPLAY(textPtr->tkwin);
}
- if (InSync != textPtr->inSync) {
- textPtr->inSync = InSync;
+ if (InSync == !!(textPtr->dInfoPtr->flags & OUT_OF_SYNC)) {
+ if (InSync) {
+ textPtr->dInfoPtr->flags &= ~OUT_OF_SYNC;
+ } else {
+ textPtr->dInfoPtr->flags |= OUT_OF_SYNC;
+ }
TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync",
Tcl_NewBooleanObj(InSync));
}
@@ -3202,7 +3208,11 @@ TkTextUpdateLineMetrics(
int fullUpdateRequested = (lineNum == 0 &&
endLine == totalLines &&
doThisMuch == -1);
-
+
+ if (fullUpdateRequested && (textPtr->dInfoPtr->flags & REDRAW_PENDING)) {
+ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}
+ }
+
if (totalLines == 0) {
/*
* Empty peer widget.