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.
This commit is contained in:
Emmanuele Bassi 2010-01-08 15:04:56 +00:00
parent 9599adbd82
commit 5157da9fc8
5 changed files with 83 additions and 7 deletions

View File

@ -363,7 +363,7 @@ _clutter_backend_glx_get_fbconfig (ClutterBackendGLX *backend_glx,
{ {
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend_glx); ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend_glx);
GLXFBConfig *configs = NULL; GLXFBConfig *configs = NULL;
gboolean use_argb = clutter_x11_has_argb_visuals (); gboolean use_argb = clutter_x11_get_use_argb_visual ();
int n_configs, i; int n_configs, i;
static const int attributes[] = { static const int attributes[] = {
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,

View File

@ -97,7 +97,7 @@ static ClutterBackendX11 *backend_singleton = NULL;
/* various flags corresponding to pre init setup calls */ /* various flags corresponding to pre init setup calls */
static gboolean _no_xevent_retrieval = FALSE; static gboolean _no_xevent_retrieval = FALSE;
static gboolean clutter_enable_xinput = FALSE; static gboolean clutter_enable_xinput = FALSE;
static gboolean clutter_enable_argb = TRUE; static gboolean clutter_enable_argb = FALSE;
static Display *_foreign_dpy = NULL; static Display *_foreign_dpy = NULL;
/* options */ /* options */
@ -988,8 +988,52 @@ clutter_x11_has_composite_extension (void)
return have_composite; 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.
*
* <note>If no ARGB visuals are found, the X11 backend will fall back to
* requesting a RGB visual instead.</note>
*
* ARGB visuals are required for the #ClutterStage:use-alpha property to work.
*
* <note>This function can only be called once, and before clutter_init() is
* called.</note>
*
* 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 gboolean
clutter_x11_has_argb_visuals (void) clutter_x11_get_use_argb_visual (void)
{ {
return clutter_enable_argb; return clutter_enable_argb;
} }
@ -1007,3 +1051,25 @@ clutter_backend_x11_get_visual_info (ClutterBackendX11 *backend_x11)
return NULL; return NULL;
} }
/**
* clutter_x11_get_visual_info:
*
* Retrieves the <structname>XVisualInfo</structname> used by the Clutter X11
* backend.
*
* Return value: a <structname>XVisualInfo</structname>, or
* <varname>None</varname>. 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);
}

View File

@ -770,8 +770,10 @@ clutter_x11_get_stage_from_window (Window win)
* along the lines of clutter_backend_x11_get_foreign_visual () or perhaps * along the lines of clutter_backend_x11_get_foreign_visual () or perhaps
* clutter_stage_x11_get_foreign_visual () * clutter_stage_x11_get_foreign_visual ()
* *
* Return value: An XVisualInfo suitable for creating a foreign stage. * Return value: An XVisualInfo suitable for creating a foreign stage. Use
* You should free this using XFree. * XFree() to free the returned value instead
*
* Deprecated: 1.2: Use clutter_x11_get_visual_info() instead
* *
* Since: 0.4 * Since: 0.4
*/ */

View File

@ -98,10 +98,14 @@ gint clutter_x11_untrap_x_errors (void);
Display *clutter_x11_get_default_display (void); Display *clutter_x11_get_default_display (void);
int clutter_x11_get_default_screen (void); int clutter_x11_get_default_screen (void);
Window clutter_x11_get_root_window (void); Window clutter_x11_get_root_window (void);
XVisualInfo *clutter_x11_get_visual_info (void);
void clutter_x11_set_display (Display * xdpy); 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); Window clutter_x11_get_stage_window (ClutterStage *stage);
XVisualInfo *clutter_x11_get_stage_visual (ClutterStage *stage);
gboolean clutter_x11_set_stage_foreign (ClutterStage *stage, gboolean clutter_x11_set_stage_foreign (ClutterStage *stage,
Window xwindow); Window xwindow);
@ -124,7 +128,8 @@ gboolean clutter_x11_has_xinput (void);
gboolean clutter_x11_has_composite_extension (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); Time clutter_x11_get_current_event_time (void);

View File

@ -1081,6 +1081,9 @@ clutter_x11_trap_x_errors
clutter_x11_untrap_x_errors clutter_x11_untrap_x_errors
clutter_x11_has_composite_extension clutter_x11_has_composite_extension
clutter_x11_get_current_event_time clutter_x11_get_current_event_time
clutter_x11_set_use_argb_visual
clutter_x11_get_use_argb_visual
clutter_x11_get_visual_info
<SUBSECTION> <SUBSECTION>
ClutterX11FilterFunc ClutterX11FilterFunc