[Gtk-sharp-list] Drawing area misses expose events (lengthy)

Oliver D. Battenfeld odb at mathematik.uni-marburg.de
Tue Jul 4 12:26:27 EDT 2006


I'm having a bit of trouble with a (simple?) GTK#-based GUI application 
which is supposed to continously display a graphical animation of sorts.

The application consists of a Gtk.Window to which I'm adding a MenuBar, some 
Buttons and a custom class which is derived from DrawingArea.

Let me state the problem first: The animation works but it sporadically 
freezes. When this happens, the Gtk.Window as a whole seems to freeze, e.g. 
button hover animations don't work anymore. If I click on any of the 
buttons (most of them don't have any functionality yet anyway) the 
animation (and the Window as a whole) are revived.

I'm not a computer graphics expert so please bear with me: The basic idea 
was to continously redraw a Pixmap which gets drawn to the DrawingArea's 

There are basically 2 methods which do the graphics stuff:

OnTimerTick is called when another class (which provides data about the 
objects to be drawn onscreen) emits a timer event:

public OnTimerTick(double timestamp) {
   // draw stuff to Pixmap

The other one is my expose event handler which is registered by the 
constructor of my custom class:

private void OnExpose(System.Object o, ExposeEventArgs args) {
   EventExpose exposeEvent = args.Event;
   Rectangle exposeArea = exposeEvent.Area;
    exposeEvent.Window.DrawDrawable(graphicsContext, pixmap, exposeArea.X, \  
           exposeArea.Y, exposeArea.X, exposeArea.Y, exposeArea.Width, \         
   args.RetVal = true;

This approach was inspired by the Pixbuf demo application which is part of 
the gtk-sharp source distribution.

Now, my patented Debug.WriteLine debugging method :-) has revealed that IF 
the animation works there is an expose event after a timer tick (which is 
exactly what QueueDraw is supposed to do, AFAIK). If however the whole 
thing hangs, I still get my timer ticks but the expose event handler 
doesn't get called.

I'm afraid I can't tell you more without any other debugging methods. Any 
ideas what could be going wrong here? My first idea (sorry, I'm new to both 
GTK and GTK# - and C#, oh boy) was that the application gets swamped by too 
many expose events but using larger timer intervals (like 10 times per 
second or even once per second) doesn't make the problem go away (it still 
happens at some point). Also, if that were the case shouldn't GTK just skip 
some events and thus some frames then? (and not freeze the GUI elements?)

I can provide you with more details if necessary (or even the whole source 
code, it's supposed to be GPLed anyway).

Thanks very much for any kind of help!


More information about the Gtk-sharp-list mailing list