diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c index 0fd7e7767..0306232e0 100644 --- a/src/backends/x11/meta-backend-x11.c +++ b/src/backends/x11/meta-backend-x11.c @@ -605,6 +605,12 @@ meta_backend_x11_class_init (MetaBackendX11Class *klass) static void meta_backend_x11_init (MetaBackendX11 *x11) { + /* XInitThreads() is needed to use the "threaded swap wait" functionality + * in Cogl - see meta_renderer_x11_create_cogl_renderer(). We call it here + * to hopefully call it before any other use of XLib. + */ + XInitThreads(); + clutter_x11_request_reset_on_video_memory_purge (); /* We do X11 event retrieval ourselves */ diff --git a/src/backends/x11/meta-renderer-x11.c b/src/backends/x11/meta-renderer-x11.c index 7d2080d3a..8560baab2 100644 --- a/src/backends/x11/meta-renderer-x11.c +++ b/src/backends/x11/meta-renderer-x11.c @@ -66,6 +66,14 @@ meta_renderer_x11_create_cogl_renderer (MetaRenderer *renderer) cogl_renderer_set_custom_winsys (cogl_renderer, get_x11_cogl_winsys_vtable); cogl_xlib_renderer_set_foreign_display (cogl_renderer, xdisplay); + /* Set up things so that if the INTEL_swap_event extension is not present, + * but the driver is known to have good thread support, we use an extra + * thread and call glXWaitVideoSync() in the thread. This allows idles + * to work properly, even when Mutter is constantly redrawing new frames; + * otherwise, without INTEL_swap_event, we'll just block in glXSwapBuffers(). + */ + cogl_xlib_renderer_set_threaded_swap_wait_enabled (cogl_renderer, TRUE); + return cogl_renderer; }