Web lists-archives.com

GTK3 SourceView, "notify::cursor-position" gives too many events

Yesterday I was looking again on the source code of my Nim editor


because I have the feeling that there may hide still a bug somewhere...

As I saw the line

buffer.handlerID = gSignalConnect(buffer, "notify::cursor-position",
gCallback(onCursorMoved), win)

I remembered that I tried once to reduce the number of events.
When I remember correctly, signal "notify::cursor-position" buffers the
events. So when the connected function can process signals only slow,
the events fill the buffer and the function is called still when cursor
is alredy at rest for some time.

What I tried or wanted was processing only the most recent cursor
position and discarding all other events in the queue.

I think I found no working GTK solution at that time. It seems that I
tried something like

obj.signalHandlerBlock(buffer.handlerID) # this will crash for fast backspace, even with gSignalConnectAfter()
while gtk3.eventsPending(): echo "mainIteration"; discard gtk3.mainIteration()

which was not working and I found no other solution.

That was not a big problem for that case, because I processed the
events in a different thread, passing each event through a channel to
that thread, and it was easy to discard all but the most recent event
in that channel.

But I still wonder if GTK itseld does not allow such type of filtering.

gtk-list mailing list