calling gtk_widget_queue_draw from another thread
- From: Horst Löffel <bionicspoon web de>
- To: gtk-app-devel-list gnome org
- Subject: calling gtk_widget_queue_draw from another thread
- Date: Wed, 06 Nov 2013 18:58:38 +0100
Hi,
I'm currently working on a library that uses GTK to open multiple
windows for drawing operations. The library will be used in a console
application as a plugin for graphical output. It has to run on win64 and
linux.
Because the program acts as a plugin i have to run gtk_main in it's own
thread. But drawing operations will come from another thread which i
call "main" thread. So my solution was to share a cairo surface between
the main thread and the GTK thread. The redrawing than just happens in
the draw event callback of the GtkWidget, where i will just draw the
cairo surface.
I read in the api documentation that 'gdk_threads_enter/leave' is
deprecated and we should use 'g_idle_add' instead.
So everytime i want the widget to update it's contents i pack a
'gtk_widget_queue_draw' into an idle function. It works but I'm
basically flooding the GTK event loop with tons of 'g_idle_add +
queue_draw'.
It works surprisingly well on linux though. All the events seem to be
handled very quickly. But on windows the graphic updates are very slow
and jumpy. I think the windows version can't handle all the
'g_idle_adds' well enough.
I am wondering if there is a better solution to my problem.
Horst
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]