Re: is EVENT_BUFFER_SIZE's default too small? [LONG]



<tang@xxxxxxxxx> wrote in message news:dr320s$4bp$1@xxxxxxxxxxxxxxxxxxxxxx
> In tkBind.c the symbol EVENT_BUFFER_SIZE is set to 30.[1] This value
> governs the number of events that may be buffered in the event ring.
> From my reading of Tk_BindEvent()[2], if the window manager generates
> more events than Tk can handle, the oldest events are lost.
>
> In a note on the tcllib bug tracker donp1 was having problems in which
> double-click events were being lost.[3] I have a program similar to the
> sample code posted by him and I was experiencing similar behaviors.
> After many hours analyzing libtk with gdb I determined the cause.
>
> I have a widget that is nested 13 levels deep. In my window manager
> (sawfish 1.3), a left-click generates two events: the normal button 1
> press and also a window raise event. Tk interprets the window raise as
> an EnterNotify. Coincidentally, the upcoming Fedora Core 5 release will
> have KDE 3.5, whose defaults includes this same left mouse button
> behavior.
>
> I have found that a left double-click under these conditions generates
> too many events for the event ring. The first click gets lost, and thus
> the <Double-Button-1> handler is never triggered. If the layout is
> changed such that the target widget is only 12 levels deep, then the
> ring is just large enough to hold all of the events generated by a
> double-click. The sample code below demonstrates the described
> behaviors. Assuming that your window manage uses click-focus and also
> passes through that click, you will not be able to double-click the top
> button.
Interesting. Indeed it sounds suspicious.

I have also suffered lost double clicks on Windows-XP in the case
where the app had to do a lot of processing potentially on some single
clicks. The work-around was to internally buffer (not act upon) a single
click for say 250 MSec. If a double click arrived in the interim then
process the double and ignore the after call for the single. This approach
"fixed" my problem of lost double clicks at the price of some ugly
coding. Would be nice if larger buffer let me junk the work around.

Roy
>
> So my question is: other than simplifying the layout of my program, how
> else can I reasonably get double-clicks to work? Telling the end-user
> to recompile libtk or to switch window manager is not an option.
>
> -----
>
> #! /usr/bin/wish
>
> package require Tk
> set bwidget_version [package require BWidget]
> puts "Tcl version: $tcl_patchLevel; Tk: $tk_patchLevel, BWidget:
$bwidget_version"
>
> set mainframe [MainFrame .mainframe]
>
> set last [$mainframe getframe]
> for {set i 3} {$i < 12} {incr i} {
> set f [frame $last.f$i]
> pack $f
> set last $f
> }
> set b [button $last.b]
> puts "top button: $b"
> $b configure -text "button [llength [split $b "."]] levels deep"
> pack $b -side top
> bind $b <Double-Button-1> [list puts "got a double click on top"]
>
> set last [$mainframe getframe]
> for {set i 3} {$i < 11} {incr i} {
> set f [frame $last.g$i]
> pack $f
> set last $f
> }
> set b [button $last.b]
> puts "bottom button: $b"
> $b configure -text "button [llength [split $b "."]] levels deep"
> pack $b -side bottom
> bind $b <Double-Button-1> [list puts "got a double click on bottom"]
>
> pack $mainframe
>
> -----
>
> [1] Line 84 of tkBind.c version 1.39, from SourceForge CVS.
>
http://cvs.sourceforge.net/viewcvs.py/tktoolkit/tk/generic/tkBind.c?annotate=1.39
> [2] Starting on line 1366 of tkBind.c.
> [3]
https://sourceforge.net/tracker/?func=detail&atid=112883&aid=795608&group_id=12883
>
> --
> Jason Tang / tang@xxxxxxxxx / http://www.jtang.org/~tang


.