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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

https://github.com/ngtk3/NEd

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()
obj.signalHandlerUnblock(buffer.handlerID)

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
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list



[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux