From 61c69a1473cf6e44358caa1c2febf28969a31511 Mon Sep 17 00:00:00 2001
From: Boiko <boiko@ageless.conectiva>
Date: Mon, 19 Jun 2006 10:06:37 -0300
Subject: [PATCH] GL include inferiors
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch make the DRI driver draw over child
windows (patch from Kristian Høgsberg)
---
 hw/xfree86/dri/dri.c |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index b58b670..253a49f 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -71,6 +71,8 @@ #include "glxserver.h"
 #include "mipointer.h"
 #include "xf86_OSproc.h"
 
+#include "selection.h"
+
 #if !defined(PANORAMIX)
 extern Bool noPanoramiXExtension;
 #endif
@@ -1135,6 +1137,31 @@ DRIDrawablePrivDelete(pointer pResource,
     return TRUE;
 }
 
+extern Selection *CurrentSelections;
+extern int NumCurrentSelections;
+
+static Bool
+DRIIncludeInferiors(void)
+{
+
+  static Atom atom = BAD_RESOURCE;
+  static char atom_name[] = "_COMPIZ_GL_INCLUDE_INFERIORS";
+  int i;
+
+  if (atom == BAD_RESOURCE) {
+    atom = MakeAtom(atom_name, strlen(atom_name), True);
+    if (atom == BAD_RESOURCE)
+      return False;
+  }
+
+  for (i = 0; i < NumCurrentSelections; i++)
+    if (CurrentSelections[i].selection == atom &&
+	CurrentSelections[i].window != None)
+      return True;
+
+  return False;
+}
+
 Bool
 DRIGetDrawableInfo(ScreenPtr pScreen,
                    DrawablePtr pDrawable,
@@ -1153,6 +1180,7 @@ DRIGetDrawableInfo(ScreenPtr pScreen,
 {
     DRIScreenPrivPtr    pDRIPriv = DRI_SCREEN_PRIV(pScreen);
     DRIDrawablePrivPtr	pDRIDrawablePriv, pOldDrawPriv;
+    RegionPtr		pClipList;
     WindowPtr		pWin, pOldWin;
     int			i;
 
@@ -1246,8 +1274,13 @@ #if 0
 #endif
 	    *W = (int)(pWin->drawable.width);
 	    *H = (int)(pWin->drawable.height);
-	    *numClipRects = REGION_NUM_RECTS(&pWin->clipList);
-	    *pClipRects = (drm_clip_rect_t *)REGION_RECTS(&pWin->clipList);
+	    if (DRIIncludeInferiors())
+	      pClipList = &pWin->borderClip;
+	    else
+	      pClipList = &pWin->clipList;
+	      
+	    *numClipRects = REGION_NUM_RECTS(pClipList);
+	    *pClipRects = (drm_clip_rect_t *)REGION_RECTS(pClipList);
 
 	    if (!*numClipRects && pDRIPriv->fullscreen) {
 				/* use fake full-screen clip rect */
-- 
1.4.0

