gtk_grab_notify() bottleneck



Hello all,

I noticed that my gtk program becomes unusable when there is a big number of
widgets whether or not they are visible.

The reason is that whenever a mouse button is pressed in the app, gtk notifies
the others widgets of the grab (gtk_grab_add()=>gtk_grab_notify()).  And the
problem is that it is realized by iterating through every widget of the same
GtkWindowGroup, that is, all widgets on typical gtk apps.  As a side note, this
is repeated when the button is released (gtk_grab_remove()=>gtk_grab_notify()).

Furthermore, most widgets do not care about the grab_notify signals.  I don't
pretend to be exhaustive but the only usages I found are within gtk itself, by
the GtkSocket and the GtkSpinButton.
So, gtk_grab_notify() is called every time a mouse button is pressed or
released, it usually does nothing interesting and on typical gtk apps the time
taken is linear (or worse) with respect to the total number of widgets.

As far as I understand, GtkSpinButton uses the grab_notify signal to prevent
problems when the user keeps pressing the arrow button and a modal window
appears.  Then I wonder why the GtkRange does not use the grab_notify since it
has the same problem when an arrow button is pressed.

And now, my suggestion:
Why not keeping a list of widgets interested by the grab notifies.  This way,
users could still be informed of the grab, every GtkSocket would appear on the
list, as well as the GtkSpinButton when one of its button is pressed.
As the GtkSocket is seldom used, and usually only one GtkSpinButton is used at a
time the list would stay very small (less than 2 elements) and the bottleneck
would disappear.

The only problem is that it requires an API change, that's why I ask the
question: which is worst? changing a very rarely used API (grab_notify) or
preventing hungry apps from running whereas they could?


Thanks
Guillaume

P.S. If you wonder how I manage to use as many widgets to see the slowdown, the
answer is that I use a menu based browser, which results in more than one
widget for each file, and there can be many files.
The temporary solution I may use is to totally get rid of the grab_notify
feature by overriding gtk_grab_add() and gtk_grab_remove() with a copy/paste
of themselves without the call to gtk_grab_notify(), but I don't really
like this...

P.P.S. Any idea of where I can find some doc about the glib Marshallers?
That is, how is it possible that I can pass as a callback a function with a
different prototype than the expected one?






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