diff options
author | fvogel <fvogelnew1@free.fr> | 2015-11-10 21:03:04 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2015-11-10 21:03:04 (GMT) |
commit | b965bde49f462725f54d29e9e8b8008f79fe43b9 (patch) | |
tree | f1476ada050bc4a05b279446f76a83d25829be84 | |
parent | b4ab9d79f99aab6cfb1014e82271308f4d6184c9 (diff) | |
download | tk-b965bde49f462725f54d29e9e8b8008f79fe43b9.zip tk-b965bde49f462725f54d29e9e8b8008f79fe43b9.tar.gz tk-b965bde49f462725f54d29e9e8b8008f79fe43b9.tar.bz2 |
Implementation of TIP #438 - Solution using virtual eventstip_438_events
-rw-r--r-- | generic/tkTextDisp.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 6036222..a275b28 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -590,6 +590,8 @@ static int TextGetScrollInfoObj(Tcl_Interp *interp, Tcl_Obj *CONST objv[], double *dblPtr, int *intPtr); static void AsyncUpdateLineMetrics(ClientData clientData); +static void GenerateMetricsEvent(TkText *textPtr, + CONST char *eventname); static void AsyncUpdateYScrollbar(ClientData clientData); static int IsStartOfNotMergedLine(TkText *textPtr, CONST TkTextIndex *indexPtr); @@ -2944,6 +2946,7 @@ AsyncUpdateLineMetrics( if (textPtr->refCount == 0) { ckfree((char *) textPtr); } + GenerateMetricsEvent(textPtr, "MetricsDone"); return; } dInfoPtr->currentMetricUpdateLine = lineNum; @@ -2960,6 +2963,51 @@ AsyncUpdateLineMetrics( /* *---------------------------------------------------------------------- * + * GenerateMetricsEvent -- + * + * Send an event related to the text widget metrics asynchronous update + * Two events are used: + * - <<MetricsOutdated>>: the asynchronous update of line metrics is + * currently running + * - <<MetricsDone>> : the asynchronous update of line metrics is + * over + * This is equivalent to: + * event generate $textWidget <<MetricsOutdated>> + * or + * event generate $textWidget <<MetricsDone>> + * + * Results: + * None + * + * Side effects: + * May force the text window into existence. + * If corresponding bindings are present, they will trigger. + * + *---------------------------------------------------------------------- + */ + +static void +GenerateMetricsEvent( + TkText *textPtr, /* Information about text widget. */ + CONST char *eventname) /* Name of the virtual event to send. */ +{ + union {XEvent general; XVirtualEvent virtual;} event; + + Tk_MakeWindowExist(textPtr->tkwin); + + memset(&event, 0, sizeof(event)); + event.general.xany.type = VirtualEvent; + event.general.xany.serial = NextRequest(Tk_Display(textPtr->tkwin)); + event.general.xany.send_event = False; + event.general.xany.window = Tk_WindowId(textPtr->tkwin); + event.general.xany.display = Tk_Display(textPtr->tkwin); + event.virtual.name = Tk_GetUid(eventname); + Tk_HandleEvent(&event.general); +} + +/* + *---------------------------------------------------------------------- + * * TkTextUpdateLineMetrics -- * * This function updates the pixel height calculations of a range of @@ -3336,6 +3384,7 @@ TextInvalidateLineMetrics( textPtr->refCount++; dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1, AsyncUpdateLineMetrics, (ClientData) textPtr); + GenerateMetricsEvent(textPtr, "MetricsOutdated"); } } @@ -5040,6 +5089,7 @@ TkTextRelayoutWindow( textPtr->refCount++; dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1, AsyncUpdateLineMetrics, (ClientData) textPtr); + GenerateMetricsEvent(textPtr, "MetricsOutdated"); } } } |