diff options
author | culler <culler> | 2018-12-31 16:58:27 (GMT) |
---|---|---|
committer | culler <culler> | 2018-12-31 16:58:27 (GMT) |
commit | 26ed73cf110821f07dc61cb0e6d0b0b19977a3f4 (patch) | |
tree | 444a4c4ec3dc6f17737b816945697d2a60d00047 /generic | |
parent | 081bea4a01c25d9aecf0c472c2700c5da5346b56 (diff) | |
download | tk-26ed73cf110821f07dc61cb0e6d0b0b19977a3f4.zip tk-26ed73cf110821f07dc61cb0e6d0b0b19977a3f4.tar.gz tk-26ed73cf110821f07dc61cb0e6d0b0b19977a3f4.tar.bz2 |
Make GenerateWidgetSyncEvent save the sync state whenever it sends an event,
and not send an event unless the requested state differs from the saved state.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkText.c | 1 | ||||
-rw-r--r-- | generic/tkText.h | 3 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 20 |
3 files changed, 17 insertions, 7 deletions
diff --git a/generic/tkText.c b/generic/tkText.c index 2dabe4c..5f2abb2 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -533,6 +533,7 @@ CreateWidget( textPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(textPtr->tkwin), TextWidgetObjCmd, textPtr, TextCmdDeletedProc); + textPtr->inSync = 1; if (sharedPtr == NULL) { sharedPtr = ckalloc(sizeof(TkSharedText)); diff --git a/generic/tkText.h b/generic/tkText.h index 5d88784..91abb73 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -785,7 +785,8 @@ typedef struct TkText { * refering to us. */ int insertCursorType; /* 0 = standard insertion cursor, 1 = block * cursor. */ - + int inSync; /* The last value sent as a <<WidgetViewSync>> + event. Initialized to 1.*/ /* * Copies of information from the shared section relating to the undo/redo * functonality diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 03546af..f63cb0c 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3115,8 +3115,14 @@ AsyncUpdateLineMetrics( * GenerateWidgetViewSyncEvent -- * * Send the <<WidgetViewSync>> event related to the text widget - * line metrics asynchronous update. - * This is equivalent to: + * line metrics asynchronous update. These events should only + * be sent when the sync status has changed. So this function + * compares the requested state with the state saved in the + * TkTest structure, and only generates the event if they are + * different. This means that it is safe to call this function + * at any time when the state is known. + * + * If an event is sent, the effect is equivalent to: * event generate $textWidget <<WidgetViewSync>> -data $s * where $s is the sync status: true (when the widget view is in * sync with its internal data) or false (when it is not). @@ -3147,8 +3153,11 @@ GenerateWidgetViewSyncEvent( FORCE_DISPLAY(textPtr->tkwin); } - TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", - Tcl_NewBooleanObj(InSync)); + if (InSync != textPtr->inSync) { + textPtr->inSync = InSync; + TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", + Tcl_NewBooleanObj(InSync)); + } } /* @@ -3531,9 +3540,8 @@ TextInvalidateLineMetrics( /* * The widget is now out of sync: send a <<WidgetViewSync>> event. */ - - GenerateWidgetViewSyncEvent(textPtr, 0); + GenerateWidgetViewSyncEvent(textPtr, 0); } /* |