x11: Switch back to RGB visuals by default
authorEmmanuele Bassi <ebassi@linux.intel.com>
Fri, 8 Jan 2010 15:04:56 +0000 (15:04 +0000)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Fri, 8 Jan 2010 15:09:21 +0000 (15:09 +0000)
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
clutter/x11/clutter-backend-x11.c
clutter/x11/clutter-stage-x11.c
clutter/x11/clutter-x11.h
doc/reference/clutter/clutter-sections.txt

index beca4df..dfcf9ee 100644 (file)
@@ -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,
index ec9afeb..4eaf081 100644 (file)
@@ -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.
+ *
+ * <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
-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 <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);
+}
index 6dbc290..12b1322 100644 (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
  * 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
  */
index 2b96057..368a117 100644 (file)
@@ -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);
 
index 89bfa40..0da1f24 100644 (file)
@@ -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
 
 <SUBSECTION>
 ClutterX11FilterFunc