Re: What should be used?
- Date: Wed, 29 Jul 2015 15:12:46 +0100
- From: Emmanuele Bassi <ebassi@xxxxxxxxx>
- Subject: Re: What should be used?
On 29 July 2015 at 14:55, Stefan Salewski <mail@xxxxxxxxxxxx> wrote:
> On Wed, 2015-07-29 at 13:05 +0100, Emmanuele Bassi wrote:
>> If you have legacy code that requires disabling double buffering, you
>> should probably invest some time into porting it to a proper solution
>> integrated with the GTK drawing model;
> It would be great if someone could port this example to GTK3:
Those examples, especially the one that uses Unix signals to interrupt
the program flow, ought to be burned with fire. Not only they are
questionable in GTK 2.x, but they are also unportable jumbles of code
that work by sheer accident.
If you want to draw with Cairo on a separate thread Because Of
Reasons™, then you need to create a Cairo surface using the GdkWindow
API — see gdk_window_create_similar_image_surface() — then draw on it
from within your thread; at the end of the thread, queue a redraw on
the widget. At the same time, inside a GtkWidget::draw handler, use
the Cairo surface you drew on inside the thread, set it as you source,
and draw the surface on the Cairo context that GTK gives you. This
way, the drawing code will happen in a separate thread, and you'll
draw only when GTK tells you to draw.
All considerations on accessing GTK and GDK API from the thread that
called gtk_init/gtk_main (or g_application_run(), if you're writing
modern code) still apply.
[@] ebassi [@gmail.com]
gtk-list mailing list