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



On Thu, 2004-07-15 at 16:49, trigonometric softhome net wrote:
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: 

I presume you read the threading FAQs and docs on using GTK (and GDK)
with threads?  If you initialized the threading system properly and use
the enter and leave critical sections for all GTK and GDK calls, then
threading will work just fine and the GUI will update normally.  Sounds
like you haven't done this.

Michael



 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
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
-- 
Michael Torrie <torriem chem byu edu>



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