Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/metacity/ChangeLog,v
retrieving revision 1.859
diff -u -p -u -r1.859 ChangeLog
--- ChangeLog	19 Aug 2004 02:05:24 -0000	1.859
+++ ChangeLog	20 Aug 2004 01:09:33 -0000
@@ -1,3 +1,17 @@
+2004-08-19  Havoc Pennington  <hp@redhat.com>
+
+	* src/display.h (struct _MetaDisplay): add render extension check
+	to the display
+
+	* src/display.c: check for render
+
+	* configure.in: don't build compositing manager by default, don't
+	want any nasty surprises; check for render separately from
+	compositing manager
+
+	* src/frame.c: use an ARGB visual when available for the window 
+	frame, so we can be all cool-ass
+	
 2004-08-18  Havoc Pennington  <hp@redhat.com>
 
 	* src/display.h (struct _MetaDisplay): track the last_xor_rect
Index: configure.in
===================================================================
RCS file: /cvs/gnome/metacity/configure.in,v
retrieving revision 1.162
diff -u -p -u -r1.162 configure.in
--- configure.in	17 Aug 2004 16:04:33 -0000	1.162
+++ configure.in	20 Aug 2004 01:09:33 -0000
@@ -131,6 +131,8 @@ AC_ARG_ENABLE(compositor,   [  --disable
 
 AC_ARG_ENABLE(xsync,       [  --disable-xsync             disable metacity's use of the XSync extension],,enable_xsync=auto)
 
+AC_ARG_ENABLE(render,       [  --disable-render             disable metacity's use of the RENDER extension],,enable_render=auto)
+
 AC_ARG_ENABLE(shape,       [  --disable-shape             disable metacity's use of the shaped window extension],,enable_shape=auto)
 
 ## try definining HAVE_BACKTRACE
@@ -192,7 +194,8 @@ if test x$enable_compositor = xyes; then
    have_xcomposite=yes
    echo "CompositeExt support forced on"
 elif test x$enable_compositor = xauto; then
-   true
+   echo "Not building compositing manager by default now, must enable explicitly to get it. And it doesn't work, so don't bother unless you want to hack on it..."
+   have_xcomposite=no
 else
    have_xcomposite=no
 fi
@@ -201,10 +204,44 @@ if test x$have_xcomposite = xyes; then
   echo "Building with CompositeExt"
   METACITY_PC_MODULES="$METACITY_PC_MODULES xcomposite >= $XCOMPOSITE_VERSION xfixes xrender xdamage"
   AC_DEFINE(HAVE_COMPOSITE_EXTENSIONS, , [Building with compositing manager support])
+
+  ## force on render also
+  have_xrender=yes
 else
   echo "Building without compositing manager"
 fi
 
+have_xrender=no
+## if no compositor, still possibly enable render
+if test x$have_xcomposite = xno; then
+  XRENDER_VERSION=0.0
+  AC_MSG_CHECKING([xrender >= $XRENDER_VERSION])
+  if $PKG_CONFIG --atleast-version $XRENDER_VERSION xrender; then
+     have_xrender=yes
+  else
+     have_xrender=no
+  fi
+  AC_MSG_RESULT($have_xrender)
+
+  if test x$enable_render = xyes; then
+     have_xrender=yes
+     echo "Render support forced on"
+  elif test x$enable_render = xauto; then
+     true
+  else
+     have_xrender=no
+  fi
+
+  if test x$have_xrender = xyes; then
+     echo "Building with Render"
+     METACITY_PC_MODULES="$METACITY_PC_MODULES xrender >= $XRENDER_VERSION"
+  fi
+fi ## have_composite
+
+if test x$have_xrender = xyes; then
+  AC_DEFINE(HAVE_RENDER, , [Building with Render extension support])
+fi
+
 PKG_CHECK_MODULES(METACITY, $METACITY_PC_MODULES)
 
 AC_PATH_XTRA
@@ -439,6 +476,7 @@ metacity-$VERSION:
 	Shape extension:          ${found_shape}
 	Resize-and-rotate:        ${found_randr}
 	Xsync:                    ${found_xsync}
+	Render:                   ${have_xrender}
         Deprecated config dialog: ${enable_config_dialog}
 "
 echo "This is the UNSTABLE branch of metacity, use 2.8.1.x for stable (gnome-2-6 branch in CVS)"
Index: src/compositor.c
===================================================================
RCS file: /cvs/gnome/metacity/src/compositor.c,v
retrieving revision 1.8
diff -u -p -u -r1.8 compositor.c
--- src/compositor.c	26 Dec 2003 02:42:38 -0000	1.8
+++ src/compositor.c	20 Aug 2004 01:09:33 -0000
@@ -1,7 +1,7 @@
 /* Metacity compositing manager */
 
 /* 
- * Copyright (C) 2003 Red Hat, Inc.
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
  * Copyright (C) 2003 Keith Packard
  * 
  * This program is free software; you can redistribute it and/or
@@ -82,8 +82,6 @@ struct MetaCompositor
   int damage_event_base;
   int fixes_error_base;
   int fixes_event_base;
-  int render_error_base;
-  int render_event_base;
   
   GHashTable *window_hash;
 
@@ -94,7 +92,6 @@ struct MetaCompositor
   guint have_composite : 1;
   guint have_damage : 1;
   guint have_fixes : 1;
-  guint have_render : 1;
 };
 
 #ifdef HAVE_COMPOSITE_EXTENSIONS
@@ -176,25 +173,11 @@ meta_compositor_new (MetaDisplay *displa
   meta_topic (META_DEBUG_COMPOSITOR, "Fixes extension event base %d error base %d\n",
               compositor->fixes_event_base,
               compositor->fixes_error_base);
-
-  if (!XRenderQueryExtension (display->xdisplay,
-                              &compositor->render_event_base,
-                              &compositor->render_error_base))
-    {
-      compositor->render_event_base = 0;
-      compositor->render_error_base = 0;
-    }
-  else
-    compositor->have_render = TRUE;
-
-  meta_topic (META_DEBUG_COMPOSITOR, "Render extension event base %d error base %d\n",
-              compositor->render_event_base,
-              compositor->render_error_base);
   
   if (!(compositor->have_composite &&
         compositor->have_fixes &&
-        compositor->have_render &&
-        compositor->have_damage))
+        compositor->have_damage &&
+        META_DISPLAY_HAS_RENDER (compositor->display)))
     {
       meta_topic (META_DEBUG_COMPOSITOR, "Failed to find all extensions needed for compositing manager, disabling compositing manager\n");
       g_assert (!compositor->enabled);
Index: src/display.c
===================================================================
RCS file: /cvs/gnome/metacity/src/display.c,v
retrieving revision 1.222
diff -u -p -u -r1.222 display.c
--- src/display.c	19 Aug 2004 02:05:24 -0000	1.222
+++ src/display.c	20 Aug 2004 01:09:33 -0000
@@ -53,6 +53,9 @@
 #ifdef HAVE_SHAPE
 #include <X11/extensions/shape.h>
 #endif
+#ifdef HAVE_RENDER
+#include <X11/extensions/Xrender.h>
+#endif
 #ifdef HAVE_XKB
 #include <X11/XKBlib.h>
 #endif
@@ -507,6 +510,8 @@ meta_display_open (const char *name)
 #ifdef HAVE_XSYNC
   {
     int major, minor;
+
+    display->have_xsync = FALSE;
     
     display->xsync_error_base = 0;
     display->xsync_event_base = 0;
@@ -524,6 +529,9 @@ meta_display_open (const char *name)
         display->xsync_error_base = 0;
         display->xsync_event_base = 0;
       }
+    else
+      display->have_xsync = TRUE;
+    
     meta_verbose ("Attempted to init Xsync, found version %d.%d error base %d event base %d\n",
                   major, minor,
                   display->xsync_error_base,
@@ -536,6 +544,8 @@ meta_display_open (const char *name)
 
 #ifdef HAVE_SHAPE
   {
+    display->have_shape = FALSE;
+    
     display->shape_error_base = 0;
     display->shape_event_base = 0;
     
@@ -546,6 +556,9 @@ meta_display_open (const char *name)
         display->shape_error_base = 0;
         display->shape_event_base = 0;
       }
+    else
+      display->have_shape = TRUE;
+    
     meta_verbose ("Attempted to init Shape, found error base %d event base %d\n",
                   display->shape_error_base,
                   display->shape_event_base);
@@ -554,6 +567,31 @@ meta_display_open (const char *name)
   meta_verbose ("Not compiled with Shape support\n");
 #endif /* !HAVE_SHAPE */
 
+#ifdef HAVE_RENDER
+  {
+    display->have_render = FALSE;
+    
+    display->render_error_base = 0;
+    display->render_event_base = 0;
+    
+    if (!XRenderQueryExtension (display->xdisplay,
+                                &display->render_event_base,
+                                &display->render_error_base))
+      {
+        display->render_error_base = 0;
+        display->render_event_base = 0;
+      }
+    else
+      display->have_render = TRUE;
+    
+    meta_verbose ("Attempted to init Render, found error base %d event base %d\n",
+                  display->render_error_base,
+                  display->render_event_base);
+  }
+#else  /* HAVE_RENDER */
+  meta_verbose ("Not compiled with Render support\n");
+#endif /* !HAVE_RENDER */
+  
   /* Create the leader window here. Set its properties and
    * use the timestamp from one of the PropertyNotify events
    * that will follow.
Index: src/display.h
===================================================================
RCS file: /cvs/gnome/metacity/src/display.h,v
retrieving revision 1.120
diff -u -p -u -r1.120 display.h
--- src/display.h	19 Aug 2004 02:05:24 -0000	1.120
+++ src/display.h	20 Aug 2004 01:09:33 -0000
@@ -315,16 +315,32 @@ struct _MetaDisplay
 #ifdef HAVE_XSYNC
   int xsync_event_base;
   int xsync_error_base;
-#define META_DISPLAY_HAS_XSYNC(display) ((display)->xsync_event_base != 0)
-#else
-#define META_DISPLAY_HAS_XSYNC(display) FALSE
 #endif
 #ifdef HAVE_SHAPE
   int shape_event_base;
   int shape_error_base;
-#define META_DISPLAY_HAS_SHAPE(display) ((display)->shape_event_base != 0)
+#endif
+#ifdef HAVE_RENDER
+  int render_event_base;
+  int render_error_base;
+#endif
+#ifdef HAVE_XSYNC
+  unsigned int have_xsync : 1;
+#define META_DISPLAY_HAS_XSYNC(display) ((display)->have_xsync)
+#else
+#define META_DISPLAY_HAS_XSYNC(display) FALSE
+#endif
+#ifdef HAVE_SHAPE
+  unsigned int have_shape : 1;
+#define META_DISPLAY_HAS_SHAPE(display) ((display)->have_shape)
 #else
 #define META_DISPLAY_HAS_SHAPE(display) FALSE
+#endif
+#ifdef HAVE_RENDER
+  unsigned int have_render : 1;
+#define META_DISPLAY_HAS_RENDER(display) ((display)->have_render)
+#else
+#define META_DISPLAY_HAS_RENDER(display) FALSE
 #endif
 };
 
Index: src/frame.c
===================================================================
RCS file: /cvs/gnome/metacity/src/frame.c,v
retrieving revision 1.58
diff -u -p -u -r1.58 frame.c
--- src/frame.c	8 Aug 2004 12:23:34 -0000	1.58
+++ src/frame.c	20 Aug 2004 01:09:33 -0000
@@ -2,7 +2,7 @@
 
 /* 
  * Copyright (C) 2001 Havoc Pennington
- * Copyright (C) 2003 Red Hat, Inc.
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -26,6 +26,10 @@
 #include "errors.h"
 #include "keybindings.h"
 
+#ifdef HAVE_RENDER
+#include <X11/extensions/Xrender.h>
+#endif
+
 #define EVENT_MASK (SubstructureRedirectMask |                     \
                     StructureNotifyMask | SubstructureNotifyMask | \
                     ExposureMask |                                 \
@@ -35,6 +39,61 @@
                     FocusChangeMask |                              \
                     ColormapChangeMask)
 
+static Visual*
+find_argb_visual (MetaDisplay *display,
+                  int          scr)
+{
+#ifdef HAVE_RENDER
+  XVisualInfo		*xvi;
+  XVisualInfo		template;
+  int			nvi;
+  int			i;
+  XRenderPictFormat	*format;
+  Visual		*visual;
+
+  if (!META_DISPLAY_HAS_RENDER (display))
+    return NULL;
+  
+  template.screen = scr;
+  template.depth = 32;
+  template.class = TrueColor;
+  xvi = XGetVisualInfo (display->xdisplay, 
+                        VisualScreenMask |
+                        VisualDepthMask |
+                        VisualClassMask,
+                        &template,
+                        &nvi);
+  if (!xvi)
+    return 0;
+  
+  visual = NULL;
+
+  for (i = 0; i < nvi; i++)
+    {
+      format = XRenderFindVisualFormat (display->xdisplay, xvi[i].visual);
+      if (format->type == PictTypeDirect && format->direct.alphaMask)
+	{
+          visual = xvi[i].visual;
+          break;
+	}
+    }
+
+  XFree (xvi);
+
+  if (visual)
+    meta_topic (META_DEBUG_COMPOSITOR,
+                "Found ARGB visual 0x%lx\n",
+                (long) visual->visualid);
+  else
+    meta_topic (META_DEBUG_COMPOSITOR,
+                "No ARGB visual found\n");
+  
+  return visual;
+#else  /* RENDER */
+  return NULL;
+#endif /* !RENDER */
+}
+
 void
 meta_window_ensure_frame (MetaWindow *window)
 {
@@ -77,13 +136,20 @@ meta_window_ensure_frame (MetaWindow *wi
   /* Default depth/visual handles clients with weird visuals; they can
    * always be children of the root depth/visual obviously, but
    * e.g. DRI games can't be children of a parent that has the same
-   * visual as the client.
+   * visual as the client. NULL means default visual.
+   *
+   * We look for an ARGB visual if we can find one, otherwise use
+   * the default of NULL.
+   */
+  
+  /* Special case for depth 32 windows (assumed to be ARGB),
+   * we use the window's visual
    */
-
-  visual = 0;
-  /* XXX special case for depth 32 windows (assumed to be ARGB) */
   if (window->depth == 32)
-    visual = window->xvisual;  
+    visual = window->xvisual;
+  else
+    visual = find_argb_visual(window->display, 
+                              window->screen->number);
 
   frame->xwindow = meta_ui_create_frame_window (window->screen->ui,
                                                 window->display->xdisplay,
Index: src/frames.c
===================================================================
RCS file: /cvs/gnome/metacity/src/frames.c,v
retrieving revision 1.75
diff -u -p -u -r1.75 frames.c
--- src/frames.c	24 Nov 2003 18:09:47 -0000	1.75
+++ src/frames.c	20 Aug 2004 01:09:33 -0000
@@ -268,10 +268,13 @@ queue_recalc_func (gpointer key, gpointe
 
   /* If a resize occurs it will cause a redraw, but the
    * resize may not actually be needed so we always redraw
-   * in case of color change.
+   * in case of color change. Don't change color if this is
+   * an ARGB visual
    */
-  gtk_style_set_background (GTK_WIDGET (frames)->style,
-                            frame->window, GTK_STATE_NORMAL);
+  if (gdk_window_get_visual (frame->window)->depth != 32)
+    gtk_style_set_background (GTK_WIDGET (frames)->style,
+                              frame->window, GTK_STATE_NORMAL);
+  
   gdk_window_invalidate_rect (frame->window, NULL, FALSE);
   meta_core_queue_frame_resize (gdk_display,
                                 frame->xwindow);
@@ -313,10 +316,14 @@ queue_draw_func (gpointer key, gpointer 
 
   /* If a resize occurs it will cause a redraw, but the
    * resize may not actually be needed so we always redraw
-   * in case of color change.
+   * in case of color change. Only redraw if it is not
+   * an ARGB visual however since we always want background
+   * in this case to be transparent.
    */
-  gtk_style_set_background (GTK_WIDGET (frames)->style,
-                            frame->window, GTK_STATE_NORMAL);
+  if (gdk_window_get_visual (frame->window)->depth != 32)
+    gtk_style_set_background (GTK_WIDGET (frames)->style,
+                              frame->window, GTK_STATE_NORMAL);
+
   gdk_window_invalidate_rect (frame->window, NULL, FALSE);
 }
 
@@ -469,6 +476,7 @@ meta_frames_manage_window (MetaFrames *f
 			   GdkWindow  *window)
 {
   MetaUIFrame *frame;
+  GdkColor col;
 
   g_assert (window);
 
@@ -477,8 +485,20 @@ meta_frames_manage_window (MetaFrames *f
   frame->window = window;
 
   gdk_window_set_user_data (frame->window, frames);
-  gtk_style_set_background (GTK_WIDGET (frames)->style,
-			    frame->window, GTK_STATE_NORMAL);
+
+  /* Set the window background to the current style if not ARGB and 
+   * transparent otherwise
+   */
+  if (gdk_window_get_visual (frame->window)->depth != 32)
+    {
+      gtk_style_set_background (GTK_WIDGET (frames)->style,
+                                frame->window, GTK_STATE_NORMAL);
+    }
+  else
+    {
+      col.pixel = 0;
+      gdk_window_set_background (window, &col);
+    }
 
   /* Don't set event mask here, it's in frame.c */
   
@@ -613,7 +633,9 @@ meta_frames_reset_bg (MetaFrames *frames
 
   frame = meta_frames_lookup_window (frames, xwindow);
   
-  gtk_style_set_background (widget->style, frame->window, GTK_STATE_NORMAL);
+  if (gdk_window_get_visual (frame->window)->depth != 32) 
+    gtk_style_set_background (GTK_WIDGET (frames)->style,
+                              frame->window, GTK_STATE_NORMAL);
 }
 
 static void
Index: src/theme.c
===================================================================
RCS file: /cvs/gnome/metacity/src/theme.c,v
retrieving revision 1.70
diff -u -p -u -r1.70 theme.c
--- src/theme.c	10 Jan 2004 17:16:06 -0000	1.70
+++ src/theme.c	20 Aug 2004 01:09:34 -0000
@@ -2663,7 +2663,8 @@ get_gc_for_primitive (GtkWidget         
   meta_color_spec_render (color_spec, widget, &color);
 
   values.foreground = color;
-  gdk_rgb_find_color (widget->style->colormap, &values.foreground);
+  gdk_rgb_find_color (gdk_drawable_get_colormap (drawable),
+                      &values.foreground);
   values.line_width = line_width;
 
   gc = gdk_gc_new_with_values (drawable, &values,
