From 5157da9fc8340cebdd29989a4ea02ccf607d3c52 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 8 Jan 2010 15:04:56 +0000 Subject: [PATCH] x11: Switch back to RGB visuals by default Since asking for ARGB by default is still somewhat experimental on X11 and not every toolkit or complex widgets (like WebKit) still do not like dealing with ARGB visuals, we should switch back to RGB by default - now that at least we know it works. For applications (and toolkit integration libraries) that want to enable the ClutterStage:use-alpha property there is a new function: void clutter_x11_set_use_argb_visual (gboolean use_argb); which needs to be called before clutter_init(). The CLUTTER_DISABLE_ARGB_VISUAL environment variable can still be used to force this value off at run-time. --- clutter/glx/clutter-backend-glx.c | 2 +- clutter/x11/clutter-backend-x11.c | 70 +++++++++++++++++++++- clutter/x11/clutter-stage-x11.c | 6 +- clutter/x11/clutter-x11.h | 9 ++- doc/reference/clutter/clutter-sections.txt | 3 + 5 files changed, 83 insertions(+), 7 deletions(-) diff --git a/clutter/glx/clutter-backend-glx.c b/clutter/glx/clutter-backend-glx.c index beca4df41..dfcf9ee32 100644 --- a/clutter/glx/clutter-backend-glx.c +++ b/clutter/glx/clutter-backend-glx.c @@ -363,7 +363,7 @@ _clutter_backend_glx_get_fbconfig (ClutterBackendGLX *backend_glx, { ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend_glx); GLXFBConfig *configs = NULL; - gboolean use_argb = clutter_x11_has_argb_visuals (); + gboolean use_argb = clutter_x11_get_use_argb_visual (); int n_configs, i; static const int attributes[] = { GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, diff --git a/clutter/x11/clutter-backend-x11.c b/clutter/x11/clutter-backend-x11.c index ec9afebea..4eaf08106 100644 --- a/clutter/x11/clutter-backend-x11.c +++ b/clutter/x11/clutter-backend-x11.c @@ -97,7 +97,7 @@ static ClutterBackendX11 *backend_singleton = NULL; /* various flags corresponding to pre init setup calls */ static gboolean _no_xevent_retrieval = FALSE; static gboolean clutter_enable_xinput = FALSE; -static gboolean clutter_enable_argb = TRUE; +static gboolean clutter_enable_argb = FALSE; static Display *_foreign_dpy = NULL; /* options */ @@ -988,8 +988,52 @@ clutter_x11_has_composite_extension (void) return have_composite; } +/** + * clutter_x11_set_use_argb_visual: + * @use_argb: %TRUE if ARGB visuals should be requested by default + * + * Sets whether the Clutter X11 backend should request ARGB visuals by default + * or not. + * + * By default, Clutter requests RGB visuals. + * + * If no ARGB visuals are found, the X11 backend will fall back to + * requesting a RGB visual instead. + * + * ARGB visuals are required for the #ClutterStage:use-alpha property to work. + * + * This function can only be called once, and before clutter_init() is + * called. + * + * Since: 1.2 + */ +void +clutter_x11_set_use_argb_visual (gboolean use_argb) +{ + if (backend_singleton != NULL) + { + g_warning ("%s() can only be used before calling clutter_init()", + G_STRFUNC); + return; + } + + CLUTTER_NOTE (BACKEND, "ARGB visuals are %s", + use_argb ? "enabled" : "disabled"); + + clutter_enable_argb = use_argb; +} + +/** + * clutter_x11_get_use_argb_visual: + * + * Retrieves whether the Clutter X11 backend is using ARGB visuals by default + * + * Return value: %TRUE if ARGB visuals are queried by default + * + * Since: 1.2 + */ gboolean -clutter_x11_has_argb_visuals (void) +clutter_x11_get_use_argb_visual (void) { return clutter_enable_argb; } @@ -1007,3 +1051,25 @@ clutter_backend_x11_get_visual_info (ClutterBackendX11 *backend_x11) return NULL; } + +/** + * clutter_x11_get_visual_info: + * + * Retrieves the XVisualInfo used by the Clutter X11 + * backend. + * + * Return value: a XVisualInfo, or + * None. The returned value should be freed using XFree() + * when done + * + * Since: 1.2 + */ +XVisualInfo * +clutter_x11_get_visual_info (void) +{ + ClutterBackendX11 *backend_x11; + + backend_x11 = CLUTTER_BACKEND_X11 (clutter_get_default_backend ()); + + return clutter_backend_x11_get_visual_info (backend_x11); +} diff --git a/clutter/x11/clutter-stage-x11.c b/clutter/x11/clutter-stage-x11.c index 6dbc29050..12b13225c 100644 --- a/clutter/x11/clutter-stage-x11.c +++ b/clutter/x11/clutter-stage-x11.c @@ -770,8 +770,10 @@ clutter_x11_get_stage_from_window (Window win) * along the lines of clutter_backend_x11_get_foreign_visual () or perhaps * clutter_stage_x11_get_foreign_visual () * - * Return value: An XVisualInfo suitable for creating a foreign stage. - * You should free this using XFree. + * Return value: An XVisualInfo suitable for creating a foreign stage. Use + * XFree() to free the returned value instead + * + * Deprecated: 1.2: Use clutter_x11_get_visual_info() instead * * Since: 0.4 */ diff --git a/clutter/x11/clutter-x11.h b/clutter/x11/clutter-x11.h index 2b960578c..368a117b0 100644 --- a/clutter/x11/clutter-x11.h +++ b/clutter/x11/clutter-x11.h @@ -98,10 +98,14 @@ gint clutter_x11_untrap_x_errors (void); Display *clutter_x11_get_default_display (void); int clutter_x11_get_default_screen (void); Window clutter_x11_get_root_window (void); +XVisualInfo *clutter_x11_get_visual_info (void); void clutter_x11_set_display (Display * xdpy); +#ifndef CLUTTER_DISABLE_DEPRECATED +XVisualInfo *clutter_x11_get_stage_visual (ClutterStage *stage) G_GNUC_DEPRECATED; +#endif + Window clutter_x11_get_stage_window (ClutterStage *stage); -XVisualInfo *clutter_x11_get_stage_visual (ClutterStage *stage); gboolean clutter_x11_set_stage_foreign (ClutterStage *stage, Window xwindow); @@ -124,7 +128,8 @@ gboolean clutter_x11_has_xinput (void); gboolean clutter_x11_has_composite_extension (void); -gboolean clutter_x11_has_argb_visuals (void); +void clutter_X11_set_use_argb_visual (gboolean use_argb); +gboolean clutter_x11_get_use_argb_visual (void); Time clutter_x11_get_current_event_time (void); diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 89bfa4039..0da1f24bb 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1081,6 +1081,9 @@ clutter_x11_trap_x_errors clutter_x11_untrap_x_errors clutter_x11_has_composite_extension clutter_x11_get_current_event_time +clutter_x11_set_use_argb_visual +clutter_x11_get_use_argb_visual +clutter_x11_get_visual_info ClutterX11FilterFunc