Index: gdk/x11/gdkevents-x11.c
===================================================================
--- gdk/x11/gdkevents-x11.c	(revision 21350)
+++ gdk/x11/gdkevents-x11.c	(working copy)
@@ -2122,21 +2122,29 @@
 	  ((XDamageNotifyEvent *) xevent)->damage == window_impl->damage)
 	{
 	  XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) xevent;
-	  XserverRegion repair;
 	  GdkRectangle rect;
 
+	  GDK_NOTE (EVENTS,
+		    g_message ("damage:\t\twindow: %ld  x,y: %d %d  w,h: %d %d%s; serial: %lu",
+			       damage_event->drawable,
+			       damage_event->area.x, damage_event->area.y,
+			       damage_event->area.width, damage_event->area.height,
+			       damage_event->more ? " (more)" : "",
+			       damage_event->serial));
+
+	  /* Since we are getting raw damage rectangles, we don't really care
+	   * what the retained damage is on the server, but to avoid a bit of
+	   * memory usage and for cleanliness, we remove anything stored there.
+	   */
+	  XDamageSubtract (display_x11->xdisplay,
+			   window_impl->damage,
+			   None, None);
+
 	  rect.x = window_private->x + damage_event->area.x;
 	  rect.y = window_private->y + damage_event->area.y;
 	  rect.width = damage_event->area.width;
 	  rect.height = damage_event->area.height;
 
-	  repair = XFixesCreateRegion (display_x11->xdisplay,
-				       &damage_event->area, 1);
-	  XDamageSubtract (display_x11->xdisplay,
-			   window_impl->damage,
-			   repair, None);
-	  XFixesDestroyRegion (display_x11->xdisplay, repair);
-
 	  if (window_private->parent != NULL)
 	    _gdk_window_process_expose (GDK_WINDOW (window_private->parent),
 					damage_event->serial, &rect);
Index: gdk/x11/gdkwindow-x11.c
===================================================================
--- gdk/x11/gdkwindow-x11.c	(revision 21350)
+++ gdk/x11/gdkwindow-x11.c	(working copy)
@@ -6148,7 +6148,18 @@
   if (composited)
     {
       XCompositeRedirectWindow (dpy, xid, CompositeRedirectManual);
-      impl->damage = XDamageCreate (dpy, xid, XDamageReportBoundingBox);
+
+      /* RawRectangles tells the server to report each damaged rectangle
+       * as it happens in a separate event. We need this because of the
+       * way we integrate Damage with the anti-expose queue; at other
+       * reporting levels, the server may send an event when some area
+       * is damaged, and not send an event when it is damaged again. This
+       * means that we can't properly tell if damage occurred before
+       * some drawing (and thus should be cancelled by the antiexpose) or
+       * occurred after that point.
+       */
+
+      impl->damage = XDamageCreate (dpy, xid, XDamageReportRawRectangles);
     }
   else
     {
