Menu

#1730 removal/optimization of scrollbar events?

obsolete: 8.4.6
open
5
2005-06-01
2004-07-15
No

While developing my application, I noticed that in some
cases, I got scroll commands invocations with
exceedingly small first and last range.
For example:

proc echo {args} {
foreach argument $args {puts -nonewline "$argument "}
puts {}
}
.canvas configure -xscrollcommand echo

would, in some cases, give:
0 0.00201613

Since I use this type of code to automatically manage
scrollbars (displayed only when needed), I end up with
scrollbars displayed when they should not, as the event
above implies that a scrollbar is needed (last - first
< 1).

At the time these events happen, and after looking at
the 8.4.6 tkCanvas.c source code, [winfo width .canvas]
= 1, which means that these events are not really
valid, in the sense that the canvas is not really
"displayed" yet (my interpretation).

I traced the problem (if that is indeed one) using
printf() calls, in ConfigureCanvas():

...
printf("canvasPtr->xOrigin = %d,
Tk_Width(canvasPtr->tkwin) = %d\n",
canvasPtr->xOrigin, Tk_Width(canvasPtr->tkwin));
Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
canvasPtr->xOrigin, canvasPtr->yOrigin,
canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin),
canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin));
return TCL_OK;
}

which gives:

canvasPtr->xOrigin = 0, Tk_Width(canvasPtr->tkwin) = 1

followed by, in Tk_CanvasEventuallyRedraw():

...
if (!(canvasPtr->flags & REDRAW_PENDING)) {
printf("canvasPtr->redrawX1 = %d,
canvasPtr->redrawX2 = %d\n", canvasPtr->redrawX1,
canvasPtr->redrawX2);
Tcl_DoWhenIdle(DisplayCanvas, (ClientData) canvasPtr);
canvasPtr->flags |= REDRAW_PENDING;
}
}

which gives:

canvasPtr->redrawX1 = 0, canvasPtr->redrawX2 = 1

followed by the invocation of the X scroll command with
first = 0, last = 0.00201613, as described before.

Now there are quite many "invalid" events of this sort,
which invoke commands at the Tcl level. Filtering these
out at the C code level (when [winfo width/height] = 1,
as I now do at the Tcl level in my automatic scrollbar
code) would possibly improve Tk display performance and
remove some display errors.

What do you think?

Best regards,

Jean-Luc

Discussion

  • Jeffrey Hobbs

    Jeffrey Hobbs - 2005-05-31
    • assigned_to: chengyemao --> dgp
     
  • Don Porter

    Don Porter - 2005-06-01
    • assigned_to: dgp --> hobbs
     
  • Don Porter

    Don Porter - 2005-06-01

    Logged In: YES
    user_id=80530

    must have been a slip of
    the mouse that assigned
    this to me.

     
MongoDB Logo MongoDB