--- src/compositor.c.orig	2005-06-28 23:40:21.000000000 +0100
+++ src/compositor.c	2005-07-13 03:35:14.000000000 +0100
@@ -773,7 +773,10 @@
 {
   XserverRegion region;
   MetaScreen *screen;
-  XRectangle r;
+  static XRectangle *expose_rects;
+  static int size_expose;
+  static int n_expose;
+  int more;
 
   screen = meta_display_screen_for_root (compositor->display,
                                          event->window);
@@ -781,13 +784,36 @@
   if (screen == NULL || screen->root_picture == None)
     return;
 
-  r.x = 0;
-  r.y = 0;
-  r.width = screen->width;
-  r.height = screen->height;
-  region = XFixesCreateRegion (compositor->display->xdisplay, &r, 1);
-  
-  merge_and_destroy_damage_region (compositor, screen, region);
+  more = event->count + 1;
+  if (n_expose == size_expose)
+    {
+      if (expose_rects)
+        {
+          expose_rects = g_realloc (expose_rects, 
+                                    (size_expose + more) * 
+                                    sizeof (XRectangle));
+          size_expose += more;
+        }
+      else
+        {
+          expose_rects = g_malloc (more * sizeof (XRectangle));
+          size_expose = more;
+        }
+    }
+
+  expose_rects[n_expose].x = event->x;
+  expose_rects[n_expose].y = event->y;
+  expose_rects[n_expose].width = event->width;
+  expose_rects[n_expose].height = event->height;
+  n_expose++;
+
+  if (event->count == 0)
+    {
+      region = XFixesCreateRegion (compositor->display->xdisplay,
+                                   expose_rects, n_expose);
+      merge_and_destroy_damage_region (compositor, screen, region);
+      n_expose = 0;
+    }
 }
 #endif /* HAVE_COMPOSITE_EXTENSIONS */
 
