gdk: Add function to retrieve the GdkVisual

Straight from Cogl.

This allows us to propagate the GdkVisual Cogl and Clutter use to
embedding toolkits, like GTK+.

The function is annotated as being added to the 1.22 development
cycle because it will be backported to the stable branch, so that
downstream developers can package up a version of Clutter that does
not crash on nVidia.

https://bugzilla.gnome.org/show_bug.cgi?id=747489
This commit is contained in:
Emmanuele Bassi 2015-06-10 12:02:13 +01:00
parent c91621e8c2
commit 2d5b5aa82a
3 changed files with 52 additions and 0 deletions

View File

@ -498,3 +498,51 @@ clutter_gdk_disable_event_retrieval (void)
disable_event_retrieval = TRUE;
}
/**
* clutter_gdk_get_visual:
*
* Retrieves the #GdkVisual used by Clutter.
*
* This function should be used when embedding Clutter inside GDK-based
* foreign toolkits, to ensure that the visual applied to the #GdkWindow
* used to render the #ClutterStage is the correct one.
*
* Returns: (transfer none): a #GdkVisual instance
*
* Since: 1.22
*/
GdkVisual *
clutter_gdk_get_visual (void)
{
ClutterBackend *backend = clutter_get_default_backend ();
GdkScreen *screen;
if (backend == NULL)
{
g_critical ("The Clutter backend has not been initialised");
return NULL;
}
if (!CLUTTER_IS_BACKEND_GDK (backend))
{
g_critical ("The Clutter backend is not a GDK backend");
return NULL;
}
screen = CLUTTER_BACKEND_GDK (backend)->screen;
g_assert (screen != NULL);
#if defined(GDK_WINDOWING_X11) && defined(COGL_HAS_XLIB_SUPPORT)
{
XVisualInfo *xvisinfo = cogl_clutter_winsys_xlib_get_visual_info ();
if (xvisinfo != NULL)
return gdk_x11_screen_lookup_visual (screen, xvisinfo->visualid);
}
#endif
if (gdk_screen_get_rgba_visual (screen) != NULL)
return gdk_screen_get_rgba_visual (screen);
return gdk_screen_get_system_visual (screen);
}

View File

@ -61,6 +61,9 @@ ClutterStage * clutter_gdk_get_stage_from_window (GdkWindow *window);
CLUTTER_AVAILABLE_IN_1_10
void clutter_gdk_disable_event_retrieval (void);
CLUTTER_AVAILABLE_IN_1_22
GdkVisual * clutter_gdk_get_visual (void);
G_END_DECLS
#endif /* __CLUTTER_GDK_H__ */

View File

@ -1519,6 +1519,7 @@ clutter_gdk_handle_event
clutter_gdk_set_display
clutter_gdk_get_default_display
clutter_gdk_set_stage_foreign
clutter_gdk_get_visual
</SECTION>
<SECTION>