I know this is likely more of a Python + GTK question, but I'm banging my
head against the wall and was hoping someone could help.

I've written a blog post about it as well:
http://www.maro.net/ossramblings.php?itemid=369

It's regarding the GTK kinetic scrolling widget I released last week.

Basically, without getting too deep into the code, here's what I do:

Create a kinetic scrolling widget.  It's a descendant of a DrawingArea.  I
extend that and I allow the new component to hook to some of it's own events
(probably a bad idea, but oh well) so that the new component knows when the
user clicks or drags.  It watches button_press, button_release and
motion_notify events.  When it's realized, it starts a timer for drawing
itself - kind of a framerate timer.

In the button_release_event, I might pass a callback to the application
telling it the user clicked a selection.

In that callback, I destroy the widget and create a new identical widget.  I
then show the new widget, with a new list.

When the widget gets the "realize" event, it starts an internal timer (which
I remove when the widget is destroyed) using gobject.timeout_add(75,
self.updateme)

I've tested the updateme function and it takes about .04 to .09 seconds to
execute.  Because timeouts don't block other things and don't try to make up
time, I don't get a solid frame rate, but I should get at least .075 seconds
between each event.

Now, when you run the first widget, everything does fine.  I get all the
mousemove events, to the tune of 1 to 15 between each tick.  I set a print
statement in the updateme event so I get a line printed every tick, and you
can watch them fly by.

When you click an item, it triggers the callback in the application that
destroys the widget (which removes the timer just fine).  Then new widget
will then get realized and works almost as expected, except that you can
visibly see that the updateme routine is being called at about half the
speed that it was called the first time, and you only get one pointer motion
event between every tick.  This means that as much as 30 seconds after you
let go of the screen, the app might be getting notified of pointer motion
events still.

Have I gone wrong at some basic level somewhere?  The widget creation is
done identically both times.

Here's the sample code from the application (not the widget):
http://pastebin.org/2151

The only thing I can think of is that it must have something to do with
deleting and creating a new widget from inside the callback of the first
widget.  If I start the process all over again with the same instance of the
app, it's back to normal speed with the first widget, so it's not something
that's hogging CPU.  In fact, top output shows almost no activity during the
slowdown.

-- 
Tony Maro
http://www.maro.net/ossramblings.php
_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers

Reply via email to