I am using gtk_widget_queue_draw() already. The doc says,"Once the main loop
becomes idle (after the current batch of events has been processed,
roughly), the window will receive expose events for the union of all regions
that have been invalidated.", but this does not seem to be happening.
Placing a printf in my expose event revealed that expose is not being called
unless I move the mouse or something like that.  My program is
multithreaded, could that be causing problems?
Some code snippets:

GtkWidget *drawing_area;
....
//Inside main:
drawing_area = gtk_drawing_area_new ();
g_signal_connect (G_OBJECT (drawing_area), "expose_event", G_CALLBACK
(expose_event), NULL);
gtk_widget_set_events(drawing_area,GDK_ALL_EVENTS_MASK);
....

gboolean expose_event( GtkWidget      *widget,
                              GdkEventExpose *event )
{
printf("expose\n");
    //draw_player(players[0]);
  gdk_draw_drawable (widget->window,
             widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
             pixmap,
             event->area.x, event->area.y,
             event->area.x, event->area.y,
             event->area.width, event->area.height);

  return FALSE;
}

//Inside a asynchronous function
//marker is an ADT
gdk_draw_polygon (pixmap,marker.kontext,TRUE,marker->poly,4);
....
gdk_widget_queue_draw(drawing_area);
....

Thanks.
-RobB


On 2/2/07, Michael Ekstrand <[EMAIL PROTECTED]> wrote:
>
> On Fri, 2007-02-02 at 12:20 -0700, Rob Barnes wrote:
> > I'm trying to write a simple program that draws a moving polygon on the
> > screen. I started with the scribble-simple example and modified to draw
> the
> > moving shape by redrawing the shape in the background color in the
> previous
> > position first then drawing it in the foreground color in the current
> > position. It works fine, except it only refreshes when something happens
>
> > such as mouse movement, click, expose, window adjustment. So to keep
> things
> > moving I have to keep moving the mouse around, but it stops if the mouse
> > stops, even though the polygon is being redrawn contently.
>
> Make sure you request a redraw every time the underlying state changes -
> check out gtk_widget_queue_draw.
>
> --
> Michael Ekstrand
> Research Assistant, Scalable Computing Laboratory
> Goanna, compute cluster and InfiniBand network monitor tool:
>         http://www.scl.ameslab.gov/Projects/Monitor/
>
>
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to