GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Dec 18, 2014 4:24 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: draw events not caused by gdk_window_invalidate_rect
PostPosted: Thu Nov 08, 2012 7:00 pm 
Offline

Joined: Thu Nov 08, 2012 6:25 pm
Posts: 2
Hello, my dear GTK fellows! :)

Now I am engaged in AI championship and want to display current situation on battlefield using Cairo on GTK window. My application have to use provided framework which works in its own main loop. So, I can not call gtk_main in main thread. So, I am launching GTK main runloop in separate thread:

Code:
...
    g_thread_init(NULL);
    g_thread_create(gui_main_loop, data, FALSE, NULL);
...
   
...
gpointer gui_main_loop(gpointer data)
{
...
    gdk_threads_init();
    gdk_threads_enter();
...
    // Here I make my cute UI
...
    gtk_main();
    gdk_threads_leave();
...
}
...


I attached handler of "draw" event to my drawing area:
Code:
...
gboolean rendering(GtkWidget *widget, cairo_t *c, gpointer data)
{
    // Here I render my UI using cairo.
    // Just noticed I do not return anything from here.
}
...
    // I call this function before gtk_main
    g_signal_connect(G_OBJECT(drawing_area), "draw", G_CALLBACK(rendering), data);
...


So, my GTK window lives in another thread and redrawn each time I resize window. But I need to update it several times a second to monitor the current situation on battlefield. So, on every iteration several time a second I call invalidate function from my main thread:

Code:
...
        gdk_window_invalidate_rect(gtk_widget_get_window(drawing_area), NULL, true);
...


But in several seconds the UI freezes. It reacts on window resizes but ignores gdk_window_invalidate_rect calls. What am I doing wrong?

Sincerely,
Kyrylo V. Polezhaiev.


Top
 Profile  
 
 Post subject: Re: draw events not caused by gdk_window_invalidate_rect
PostPosted: Thu Nov 08, 2012 7:21 pm 
Offline

Joined: Thu Nov 08, 2012 6:25 pm
Posts: 2
return TRUE or FALSE in "draw" handler doesn't help me.
It renders several times and then handler isn't called anymore.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group