Hello,
I am using gtk+-2.0.2 under cygwin and i would like
to run the gtk_main loop in a thread.
Here is a testcase of my program. If you compile it
and run it, you will see that the window is displayed but does not react to the
mouse.
It seems like the main loop does not process the
windows events or is stuck in a mutex ????
Thanks for any help.
Didier
here is the file test_th.c
/*---------------------------------------------------------------------------------------------------------
* Compile with: * * gcc test_th.c -o test_th `pkg-config gtk+-2.0 --cflags --libs` `pkg-config --cflags --libs gthread-2.0`` * * ---------------------------------------------------------------------------------------------------------*/ #include <stdio.h>
#include <stdlib.h> #include <unistd.h> #include <time.h> #include <gtk/gtk.h> #include <glib.h> #include <pthread.h> void *main_thread (void *args)
{ printf("starting main loop\n");
/* enter the GTK main loop */
gdk_threads_enter (); gtk_main (); gdk_threads_leave (); return NULL;
} int main (int argc, char *argv[])
{ pthread_t main_tid; GtkWidget *window; /* init threads */
g_thread_init (NULL); gdk_threads_init (); /* init gtk */
gtk_init(&argc, &argv); /* create a window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_show (window); pthread_create (&main_tid, NULL,
main_thread, NULL);
while (1)
{ sleep(1); } return 0; } /*---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------*/ |