drawing area won't refresh on X11 unless touched, app is multithreaded, gtk 2.0



I made a simple modification of the scribble program because I wanted to see how to make the drawing area update on its own so the user can watch something be drawn on it in realtime as the CPU works. So this is the goal, if you can tell me how to do this that would be great. I created a new thread for gtk_main using pthreads so that I could do the active drawing on the drawing area in the remainder of the normal c main function. All I then do is this:
while(1) {
   sleep(1);
   x = (gdouble)((double)random()/
       RAND_MAX)*drawing_area->allocation.width;
   y = (gdouble)((double)random()/
       RAND_MAX)*drawing_area->allocation.height;
   draw_brush(drawing_area,x,y);

   //gtk_widget_queue_draw(drawing_area);
   //gdk_window_process_updates(drawing_area->window,1);
   //gdk_window_clear(drawing_area->window);
   //gdk_window_invalidate_rect(drawing_area->window,&rect,1);
   //gtk_widget_event(window,);
   //gtk_widget_draw(drawing_area,&rect);
} Note that the draw_brush function is the same as in the scribble.c program in the gtk tutorial. The commented stuff above is all the things I tried to get it to refresh, but whatever I try the same thing happens; nothing. Nothing happens until I press a key, or move the mouse over the window area, then all the blocks that were drawn appear. Does this have something to do with X, is it X that is lagging behind in the updating. Or is this something to do with the fact I pthread gtk_main? How can I force this to work? This is really annoying since it is such a seemingly trivial thing, it's like a massive timewaste. Regards
trigonometric



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