[xserver-commit] xserver/damageext damageext.c,1.2,1.3

Keith Packard xserver-commit@pdx.freedesktop.org
Sat, 08 Nov 2003 23:06:01 -0800


Committed by: keithp

Update of /cvs/xserver/xserver/damageext
In directory pdx:/tmp/cvs-serv8142/damageext

Modified Files:
	damageext.c 
Log Message:
	* composite/compinit.c: (compCloseScreen), (compScreenInit):
	* composite/compint.h:
	* composite/compwindow.c: (compCheckWindow),
	(compPaintWindowBackground), (compDestroyWindow):
	* damageext/damageext.c: (DamageExtNotify), (DamageExtDestroy),
	(ProcDamageSubtract), (FreeDamageExt), (FreeDamageExtWin):
	* dix/window.c: (SetBorderSize):
	* miext/damage/damage.c: (damageDamageRegion), (damageDamageBox),
	(damageDestroyPixmap), (damagePaintWindow), (damageCopyWindow),
	(damageRestoreAreas), (damageSetWindowPixmap),
	(damageDestroyWindow), (DamageSetup), (DamageCreate),
	(DamageRegister), (DamageUnregister), (DamageSubtract),
	(DamageDamageRegion):
	* miext/damage/damagestr.h:
	* render/mirect.c: (miColorRects):

	Wrap PaintWindowBackground in composite extension to
	disable painting window background in manual Subwindows mode.

	compDestroyWindow needed to refetch cw and csw because
	CompFreeClientWindow/compFreeClientSubwindows zeroed them.

	Damage must store all damage in window relative
	coordinates so that damage tracks window movement.  I doubt
	this will work "right" with bitGravity, apps are likely to
	lose in that case anyway.

	Check for clientGone before trying to write events.

	Better checking for freeing datastructures in various orders

	dix/window.c: oops.  Was setting wrong region in COMPOSITE side
	of SetBorderSize.

	Damage must be associated with windows, not just underlying pixmap
	in case that changes.  Wrap SetWindowPixmap to track changes
	to window pixmaps (and DestroyWindow as well).

	Don't smash PaintWindow/CopyWindow regions in damageDamageRegion.
	Also, translate region back for those cases.

	render/mirect.c: track subWindowMode (oops)


Index: damageext.c
===================================================================
RCS file: /cvs/xserver/xserver/damageext/damageext.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- damageext.c	2 Nov 2003 19:56:10 -0000	1.2
+++ damageext.c	9 Nov 2003 07:05:59 -0000	1.3
@@ -39,8 +39,6 @@
 {
     ClientPtr		pClient = pDamageExt->pClient;
     DrawablePtr		pDrawable = pDamageExt->pDrawable;
-    int			dx = pDrawable->x;
-    int			dy = pDrawable->y;
     xDamageNotifyEvent	ev;
     int			i;
 
@@ -52,7 +50,7 @@
     ev.damage = pDamageExt->id;
     ev.timestamp = currentTime.milliseconds;
     ev.geometry.x = pDrawable->x;
-    ev.geometry.y = pDrawable->x;
+    ev.geometry.y = pDrawable->y;
     ev.geometry.width = pDrawable->width;
     ev.geometry.height = pDrawable->height;
     if (pBoxes)
@@ -62,11 +60,12 @@
 	    ev.level = pDamageExt->level;
 	    if (i < nBoxes - 1)
 		ev.level |= DamageNotifyMore;
-	    ev.area.x = pBoxes[i].x1 - dx;
-	    ev.area.y = pBoxes[i].y1 - dy;
+	    ev.area.x = pBoxes[i].x1;
+	    ev.area.y = pBoxes[i].y1;
 	    ev.area.width = pBoxes[i].x2 - pBoxes[i].x1;
 	    ev.area.height = pBoxes[i].y2 - pBoxes[i].y1;
-	    WriteEventsToClient (pClient, 1, (xEvent *) &ev);
+	    if (!pClient->clientGone)
+		WriteEventsToClient (pClient, 1, (xEvent *) &ev);
 	}
     }
     else
@@ -75,7 +74,8 @@
 	ev.area.y = 0;
 	ev.area.width = pDrawable->width;
 	ev.area.height = pDrawable->height;
-	WriteEventsToClient (pClient, 1, (xEvent *) &ev);
+	if (!pClient->clientGone)
+	    WriteEventsToClient (pClient, 1, (xEvent *) &ev);
     }
     /* pretend that all damage events are critical */
     SetCriticalOutputPending ();
@@ -107,7 +107,9 @@
 {
     DamageExtPtr    pDamageExt = closure;
     
-    FreeResource (pDamageExt->id, RT_NONE);
+    pDamageExt->pDamage = 0;
+    if (pDamageExt->id)
+	FreeResource (pDamageExt->id, RT_NONE);
 }
 
 static int
@@ -226,27 +228,17 @@
     if (pDamageExt->level != DamageReportRawRegion)
     {
 	DamagePtr   pDamage = pDamageExt->pDamage;
-	int	    dx = pDamageExt->pDrawable->x;
-	int	    dy = pDamageExt->pDrawable->y;
 	if (pRepair)
 	{
 	    if (pParts)
-	    {
 		REGION_INTERSECT (pScreen, pParts, DamageRegion (pDamage), pRepair);
-		REGION_TRANSLATE (pScreen, pParts, -dx, -dy);
-	    }
-	    REGION_TRANSLATE (pScreen, pRepair, dx, dy);
 	    if (DamageSubtract (pDamage, pRepair))
 		DamageExtReport (pDamage, DamageRegion (pDamage), (void *) pDamageExt);
-	    REGION_TRANSLATE (pScreen, pRepair, -dx, -dy);
 	}
 	else
 	{
 	    if (pParts)
-	    {
 		REGION_COPY (pScreen, pParts, DamageRegion (pDamage));
-		REGION_TRANSLATE (pScreen, pParts, -dx, -dy);
-	    }
 	    DamageEmpty (pDamage);
 	}
     }
@@ -379,9 +371,14 @@
     /*
      * Get rid of the resource table entry hanging from the window id
      */
+    pDamageExt->id = 0;
     if (WindowDrawable(pDamageExt->pDrawable->type))
 	FreeResourceByType (pDamageExt->pDrawable->id, DamageExtWinType, TRUE);
-    DamageUnregister (pDamageExt->pDrawable, pDamageExt->pDamage);
+    if (pDamageExt->pDamage)
+    {
+	DamageUnregister (pDamageExt->pDrawable, pDamageExt->pDamage);
+	DamageDestroy (pDamageExt->pDamage);
+    }
     xfree (pDamageExt);
     return Success;
 }
@@ -391,7 +388,8 @@
 {
     DamageExtPtr    pDamageExt = (DamageExtPtr) value;
 
-    FreeResource (pDamageExt->id, RT_NONE);
+    if (pDamageExt->id)
+	FreeResource (pDamageExt->id, RT_NONE);
     return Success;
 }