summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2015-06-10 11:55:50 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2015-06-10 19:12:50 +0100
commit44fc1c87489bb7bbe1d28eb0f551794db333e1fb (patch)
tree1e1174bfd6dee37ed0cac7c0d7d51c152d45c5ed
parent69dee9c5eb5711e20d63d5aa5cfe249321d02228 (diff)
downloadclutter-44fc1c87489bb7bbe1d28eb0f551794db333e1fb.tar.gz
gdk: Use the Cogl visual on Xlib winsys
GDK 3.16 started selecting different visuals, to best comply with the requirements for OpenGL, and this has broken Clutter on GLX drivers that are fairly picky in how they select visuals and GLXFBConfig. GDK selects GLXFBConfig that do not include depth or stencil buffers; Cogl, on the other hand, needs both depth and stencil buffers, and keeps selecting the first available visual, assuming that the GLX driver will give us the best compliant one, as per specification. Sadly, some drivers will return incompatible configurations, and then bomb out when you try to embed Clutter inside GTK+, because of mismatched visuals. Cogl has an old, deprecated, Clutter-only API that allows us to retrieve the XVisualInfo mapping to the GLXFBConfig it uses; this means we should look up the GdkVisual for it when creating our own GdkWindows, instead of relying on the RGBA and system GdkVisuals exposed by GDK — at least on X11. https://bugzilla.gnome.org/show_bug.cgi?id=747489 (cherry picked from commit c91621e8c28bb190eaa9d59e08b180589a255cf3) Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
-rw-r--r--clutter/gdk/clutter-stage-gdk.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/clutter/gdk/clutter-stage-gdk.c b/clutter/gdk/clutter-stage-gdk.c
index e855a985c..82f7679a0 100644
--- a/clutter/gdk/clutter-stage-gdk.c
+++ b/clutter/gdk/clutter-stage-gdk.c
@@ -29,6 +29,10 @@
#include <cogl/cogl.h>
+#ifdef COGL_HAS_XLIB_SUPPORT
+#include <cogl/cogl-xlib.h>
+#endif
+
#define GDK_DISABLE_DEPRECATION_WARNINGS
#include <gdk/gdk.h>
@@ -183,7 +187,7 @@ clutter_stage_gdk_realize (ClutterStageWindow *stage_window)
GdkWindowAttr attributes;
gboolean cursor_visible;
gboolean use_alpha;
- gfloat width, height;
+ gfloat width, height;
if (backend->cogl_context == NULL)
{
@@ -191,12 +195,7 @@ clutter_stage_gdk_realize (ClutterStageWindow *stage_window)
return FALSE;
}
- if (stage_gdk->foreign_window)
- {
- width = gdk_window_get_width (stage_gdk->window);
- height = gdk_window_get_height (stage_gdk->window);
- }
- else
+ if (!stage_gdk->foreign_window)
{
if (stage_gdk->window != NULL)
{
@@ -239,13 +238,34 @@ clutter_stage_gdk_realize (ClutterStageWindow *stage_window)
attributes.cursor = stage_gdk->blank_cursor;
}
- attributes.visual = NULL;
+ /* If the ClutterStage:use-alpha is set, but GDK does not have an
+ * RGBA visual, then we unset the property on the Stage
+ */
if (use_alpha)
{
- attributes.visual = gdk_screen_get_rgba_visual (backend_gdk->screen);
+ if (gdk_screen_get_rgba_visual (backend_gdk->screen) == NULL)
+ {
+ clutter_stage_set_use_alpha (stage_cogl->wrapper, FALSE);
+ use_alpha = FALSE;
+ }
+ }
- if (attributes.visual == NULL)
- clutter_stage_set_use_alpha (stage_cogl->wrapper, FALSE);
+#if defined(GDK_WINDOWING_X11) && defined(COGL_HAS_XLIB_SUPPORT)
+ if (GDK_IS_X11_DISPLAY (backend_gdk->display))
+ {
+ XVisualInfo *xvisinfo = cogl_clutter_winsys_xlib_get_visual_info ();
+ if (xvisinfo != NULL)
+ {
+ attributes.visual = gdk_x11_screen_lookup_visual (backend_gdk->screen,
+ xvisinfo->visualid);
+ }
+ }
+ else
+#endif
+ {
+ attributes.visual = use_alpha
+ ? gdk_screen_get_rgba_visual (backend_gdk->screen)
+ : gdk_screen_get_system_visual (backend_gdk->screen);
}
if (attributes.visual == NULL)
@@ -263,11 +283,15 @@ clutter_stage_gdk_realize (ClutterStageWindow *stage_window)
clutter_stage_gdk_set_gdk_geometry (stage_gdk);
}
+ else
+ {
+ width = gdk_window_get_width (stage_gdk->window);
+ height = gdk_window_get_height (stage_gdk->window);
+ }
gdk_window_ensure_native (stage_gdk->window);
- g_object_set_data (G_OBJECT (stage_gdk->window),
- "clutter-stage-window", stage_gdk);
+ g_object_set_data (G_OBJECT (stage_gdk->window), "clutter-stage-window", stage_gdk);
stage_cogl->onscreen = cogl_onscreen_new (backend->cogl_context,
width, height);