[gtk+] Deprecate the GdkRegion API



commit 3e96cfe8fcfeedabc09b2a8b3aa87007a3b5a2a0
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jun 28 14:44:12 2010 +0200

    Deprecate the GdkRegion API
    
    Includes fixing all callers to use the cairo region API instead. This is
    usually just replacing the function names, the only difference is
    gdk_region_get_rectangles() being replaced by
    cairo_region_num_rectangles() and cairo_region_get_rectangle() which
    required a bit more work.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=613284

 docs/reference/gdk/tmpl/regions.sgml |    9 +-
 gdk/directfb/gdkdrawable-directfb.c  |   26 +-
 gdk/directfb/gdkgeometry-directfb.c  |   52 ++--
 gdk/directfb/gdkwindow-directfb.c    |    6 +-
 gdk/gdk.symbols                      |    4 +
 gdk/gdkdraw.c                        |   16 +-
 gdk/gdkevents.c                      |    4 +-
 gdk/gdkgc.c                          |   40 ++--
 gdk/gdkoffscreenwindow.c             |    4 +-
 gdk/gdkpango.c                       |   10 +-
 gdk/gdkpolyreg-generic.c             |    2 +-
 gdk/gdkregion-generic.c              |   37 ++
 gdk/gdkregion.h                      |    9 +
 gdk/gdkwindow.c                      |  625 +++++++++++++++++-----------------
 gdk/quartz/GdkQuartzView.c           |   12 +-
 gdk/quartz/gdkgc-quartz.c            |   17 +-
 gdk/quartz/gdkgeometry-quartz.c      |   17 +-
 gdk/quartz/gdkprivate-quartz.h       |    4 +-
 gdk/quartz/gdkwindow-quartz.c        |  113 +++----
 gdk/win32/gdkdrawable-win32.c        |   12 +-
 gdk/win32/gdkevents-win32.c          |   10 +-
 gdk/win32/gdkgeometry-win32.c        |   16 +-
 gdk/x11/gdkdnd-x11.c                 |   10 +-
 gdk/x11/gdkgeometry-x11.c            |   28 +-
 gdk/x11/gdkwindow-x11.c              |   25 +-
 gtk/gtkcontainer.c                   |    4 +-
 gtk/gtkiconview.c                    |   27 +-
 gtk/gtklabel.c                       |   10 +-
 gtk/gtktextdisplay.c                 |   12 +-
 gtk/gtktreeview.c                    |   41 ++--
 gtk/gtkwidget.c                      |   30 +-
 tests/testgtk.c                      |    8 +-
 32 files changed, 644 insertions(+), 596 deletions(-)
---
diff --git a/docs/reference/gdk/tmpl/regions.sgml b/docs/reference/gdk/tmpl/regions.sgml
index dfb43a6..4de1b2b 100644
--- a/docs/reference/gdk/tmpl/regions.sgml
+++ b/docs/reference/gdk/tmpl/regions.sgml
@@ -47,15 +47,12 @@ Defines the x and y coordinates of a point.
 @x: the x coordinate of the point.
 @y: the y coordinate of the point.
 
-<!-- ##### STRUCT GdkRectangle ##### -->
+<!-- ##### TYPEDEF GdkRectangle ##### -->
 <para>
-Defines the position and size of a rectangle.
+Defines the position and size of a rectangle. It is identical to 
+#cairo_rectangle_int_t.
 </para>
 
- x: the x coordinate of the left edge of the rectangle.
- y: the y coordinate of the top of the rectangle.
- width: the width of the rectangle.
- height: the height of the rectangle.
 
 <!-- ##### FUNCTION gdk_rectangle_intersect ##### -->
 <para>
diff --git a/gdk/directfb/gdkdrawable-directfb.c b/gdk/directfb/gdkdrawable-directfb.c
index c142ba5..da314e5 100644
--- a/gdk/directfb/gdkdrawable-directfb.c
+++ b/gdk/directfb/gdkdrawable-directfb.c
@@ -258,7 +258,7 @@ gdk_directfb_clip_region (GdkDrawable  *drawable,
                    GDKDFB_RECTANGLE_VALS_FROM_BOX( &private->paint_region.extents ),
                    private->paint_region.numRects );
 
-    gdk_region_intersect (ret_clip, &private->paint_region);
+    cairo_region_intersect (ret_clip, &private->paint_region);
   }
 
   if (gc)
@@ -273,13 +273,13 @@ gdk_directfb_clip_region (GdkDrawable  *drawable,
 
           if (gc->clip_x_origin || gc->clip_y_origin)
             {
-              gdk_region_offset (ret_clip, -gc->clip_x_origin, -gc->clip_y_origin);
-              gdk_region_intersect (ret_clip, region);
-              gdk_region_offset (ret_clip, gc->clip_x_origin, gc->clip_y_origin);
+              cairo_region_translate (ret_clip, -gc->clip_x_origin, -gc->clip_y_origin);
+              cairo_region_intersect (ret_clip, region);
+              cairo_region_translate (ret_clip, gc->clip_x_origin, gc->clip_y_origin);
             }
           else
             {
-              gdk_region_intersect (ret_clip, region);
+              cairo_region_intersect (ret_clip, region);
             }
         }
 
@@ -327,7 +327,7 @@ gdk_directfb_clip_region (GdkDrawable  *drawable,
           D_DEBUG_AT( GDKDFB_DrawClip, "  -> clipping child    [ %4d,%4d - %4dx%4d ]  (%ld boxes)\n",
                       GDKDFB_RECTANGLE_VALS_FROM_BOX( &temp.extents ), temp.numRects );
 
-          gdk_region_subtract (ret_clip, &temp);
+          cairo_region_subtract (ret_clip, &temp);
         }
     }
 
@@ -739,7 +739,7 @@ gdk_directfb_draw_points (GdkDrawable *drawable,
 
   while (npoints > 0)
     {
-      if (gdk_region_point_in (&clip, points->x, points->y))
+      if (cairo_region_contains_point (&clip, points->x, points->y))
         {
           impl->surface->FillRectangle (impl->surface,
                                         points->x, points->y, 1, 1);
@@ -940,7 +940,7 @@ gdk_directfb_draw_image (GdkDrawable *drawable,
 
   gdk_directfb_clip_region (drawable, gc, &dest_rect, &clip);
 
-  if (!gdk_region_empty (&clip))
+  if (!cairo_region_is_empty (&clip))
     {
       DFBRectangle  src_rect = { xsrc, ysrc, width, height };
 
@@ -1218,15 +1218,15 @@ gdk_directfb_draw_pixbuf (GdkDrawable  *drawable,
   tmp_rect.width = width;
   tmp_rect.height = height;
 
-  drect = gdk_region_rectangle (&tmp_rect);
+  drect = cairo_region_create_rectangle (&tmp_rect);
   clip = gdk_drawable_get_clip_region (drawable);
 
-  gdk_region_intersect (drect, clip);
+  cairo_region_intersect (drect, clip);
 
-  gdk_region_get_clipbox (drect, &tmp_rect);
+  cairo_region_get_extents (drect, &tmp_rect);
   
-  gdk_region_destroy (drect);
-  gdk_region_destroy (clip);
+  cairo_region_destroy (drect);
+  cairo_region_destroy (clip);
 
   if (tmp_rect.width == 0 ||
       tmp_rect.height == 0)
diff --git a/gdk/directfb/gdkgeometry-directfb.c b/gdk/directfb/gdkgeometry-directfb.c
index f848956..bddc2dd 100644
--- a/gdk/directfb/gdkgeometry-directfb.c
+++ b/gdk/directfb/gdkgeometry-directfb.c
@@ -91,24 +91,24 @@ _gdk_directfb_window_scroll (GdkWindow *window,
 
   /* Move the current invalid region */
   if (private->update_area)
-    gdk_region_offset (private->update_area, dx, dy);
+    cairo_region_translate (private->update_area, dx, dy);
 
   if (GDK_WINDOW_IS_MAPPED (window))
     {
       GdkRectangle  clip_rect = {  0,  0, impl->width, impl->height };
       GdkRectangle  rect      = { dx, dy, impl->width, impl->height };
 
-      invalidate_region = gdk_region_rectangle (&clip_rect);
+      invalidate_region = cairo_region_create_rectangle (&clip_rect);
 
       if (gdk_rectangle_intersect (&rect, &clip_rect, &rect) &&
           (!private->update_area ||
-           !gdk_region_rect_in (private->update_area, &rect)))
+           !cairo_region_contains_rectangle (private->update_area, &rect)))
         {
           GdkRegion *region;
 
-          region = gdk_region_rectangle (&rect);
-          gdk_region_subtract (invalidate_region, region);
-          gdk_region_destroy (region);
+          region = cairo_region_create_rectangle (&rect);
+          cairo_region_subtract (invalidate_region, region);
+          cairo_region_destroy (region);
 
           if (impl->surface)
             {
@@ -141,7 +141,7 @@ _gdk_directfb_window_scroll (GdkWindow *window,
   if (invalidate_region)
     {
       gdk_window_invalidate_region (window, invalidate_region, TRUE);
-      gdk_region_destroy (invalidate_region);
+      cairo_region_destroy (invalidate_region);
     }
 }
 
@@ -188,31 +188,31 @@ _gdk_directfb_window_move_region (GdkWindow       *window,
     return;
 
   GdkRectangle  clip_rect = {  0,  0, impl->width, impl->height };
-  window_clip = gdk_region_rectangle (&clip_rect);
+  window_clip = cairo_region_create_rectangle (&clip_rect);
 
   /* compute source regions */
-  src_region = gdk_region_copy (region);
-  brought_in = gdk_region_copy (region);
-  gdk_region_intersect (src_region, window_clip);
+  src_region = cairo_region_copy (region);
+  brought_in = cairo_region_copy (region);
+  cairo_region_intersect (src_region, window_clip);
 
-  gdk_region_subtract (brought_in, src_region);
-  gdk_region_offset (brought_in, dx, dy);
+  cairo_region_subtract (brought_in, src_region);
+  cairo_region_translate (brought_in, dx, dy);
 
   /* compute destination regions */
-  dest_region = gdk_region_copy (src_region);
-  gdk_region_offset (dest_region, dx, dy);
-  gdk_region_intersect (dest_region, window_clip);
-  gdk_region_get_clipbox (dest_region, &dest_extents);
+  dest_region = cairo_region_copy (src_region);
+  cairo_region_translate (dest_region, dx, dy);
+  cairo_region_intersect (dest_region, window_clip);
+  cairo_region_get_extents (dest_region, &dest_extents);
 
-  gdk_region_destroy (window_clip);
+  cairo_region_destroy (window_clip);
 
   /* calculating moving part of current invalid area */
   moving_invalid_region = NULL;
   if (private->update_area)
     {
-      moving_invalid_region = gdk_region_copy (private->update_area);
-      gdk_region_intersect (moving_invalid_region, src_region);
-      gdk_region_offset (moving_invalid_region, dx, dy);
+      moving_invalid_region = cairo_region_copy (private->update_area);
+      cairo_region_intersect (moving_invalid_region, src_region);
+      cairo_region_translate (moving_invalid_region, dx, dy);
     }
   
   /* invalidate all of the src region */
@@ -220,18 +220,18 @@ _gdk_directfb_window_move_region (GdkWindow       *window,
 
   /* un-invalidate destination region */
   if (private->update_area)
-    gdk_region_subtract (private->update_area, dest_region);
+    cairo_region_subtract (private->update_area, dest_region);
   
   /* invalidate moving parts of existing update area */
   if (moving_invalid_region)
     {
       gdk_window_invalidate_region (window, moving_invalid_region, FALSE);
-      gdk_region_destroy (moving_invalid_region);
+      cairo_region_destroy (moving_invalid_region);
     }
 
   /* invalidate area brought in from off-screen */
   gdk_window_invalidate_region (window, brought_in, FALSE);
-  gdk_region_destroy (brought_in);
+  cairo_region_destroy (brought_in);
 
   /* Actually do the moving */
 	if (impl->surface)
@@ -250,8 +250,8 @@ _gdk_directfb_window_move_region (GdkWindow       *window,
               impl->surface->SetClip (impl->surface, NULL);
               impl->surface->Flip(impl->surface,&destination,0);
 	}
-  gdk_region_destroy (src_region);
-  gdk_region_destroy (dest_region);
+  cairo_region_destroy (src_region);
+  cairo_region_destroy (dest_region);
 }
 
 #define __GDK_GEOMETRY_X11_C__
diff --git a/gdk/directfb/gdkwindow-directfb.c b/gdk/directfb/gdkwindow-directfb.c
index 83da5b8..ed086c6 100644
--- a/gdk/directfb/gdkwindow-directfb.c
+++ b/gdk/directfb/gdkwindow-directfb.c
@@ -227,7 +227,7 @@ gdk_window_impl_directfb_get_visible_region (GdkDrawable *drawable)
 
   D_DEBUG_AT( GDKDFB_Window, "  -> returning %4d,%4d-%4dx%4d\n", drect.x, drect.y, drect.w, drect.h );
 
-  return gdk_region_rectangle (&rect);
+  return cairo_region_create_rectangle (&rect);
 }
 
 static void
@@ -2648,7 +2648,7 @@ gdk_window_impl_directfb_begin_paint_region (GdkPaintable    *paintable,
                   DFB_RECTANGLE_VALS_FROM_REGION( &impl->paint_region.extents ), impl->paint_region.numRects );
 
       /* Add the new region to the paint region... */
-      gdk_region_union (&impl->paint_region, region);
+      cairo_region_union (&impl->paint_region, region);
     }
   else
     {
@@ -2668,7 +2668,7 @@ gdk_window_impl_directfb_begin_paint_region (GdkPaintable    *paintable,
               DFB_RECTANGLE_VALS_FROM_REGION( &impl->paint_region.extents ), impl->paint_region.numRects );
 
   /* ...but clip the initial/compound result against the clip region. */
-  gdk_region_intersect (&impl->paint_region, &impl->clip_region);
+  cairo_region_intersect (&impl->paint_region, &impl->clip_region);
 
   D_DEBUG_AT( GDKDFB_Window, "  -> clipped  %4d,%4d-%4dx%4d (%ld boxes)\n",
               DFB_RECTANGLE_VALS_FROM_REGION( &impl->paint_region.extents ), impl->paint_region.numRects );
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index 81626e8..fcf06c0 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -977,6 +977,7 @@ gdk_pixmap_lookup_for_display
 
 #if IN_HEADER(__GDK_REGION_H__)
 #if IN_FILE(__GDK_REGION_GENERIC_C__)
+#ifndef GDK_DISABLE_DEPRECATED
 gdk_region_copy
 gdk_region_destroy
 gdk_region_empty
@@ -998,12 +999,15 @@ gdk_region_union_with_rect
 gdk_region_xor
 #endif
 #endif
+#endif
 
 #if IN_HEADER(__GDK_REGION_H__)
 #if IN_FILE(__GDK_POLYREG_GENERIC_C__)
+#ifndef GDK_DISABLE_DEPRECATED
 gdk_region_polygon
 #endif
 #endif
+#endif
 
 #if IN_HEADER(__GDK_RGB_H__)
 #if IN_FILE(__GDK_RGB_C__)
diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c
index 47a2a7d..6ea712d 100644
--- a/gdk/gdkdraw.c
+++ b/gdk/gdkdraw.c
@@ -1059,7 +1059,7 @@ gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable,
  * but no area outside of this region will be affected by drawing
  * primitives.
  * 
- * Returns: a #GdkRegion. This must be freed with gdk_region_destroy()
+ * Returns: a #GdkRegion. This must be freed with cairo_region_destroy()
  *          when you are done.
  **/
 GdkRegion *
@@ -1079,7 +1079,7 @@ gdk_drawable_get_clip_region (GdkDrawable *drawable)
  * obscured by other windows, but no area outside of this region
  * is visible.
  * 
- * Returns: a #GdkRegion. This must be freed with gdk_region_destroy()
+ * Returns: a #GdkRegion. This must be freed with cairo_region_destroy()
  *          when you are done.
  **/
 GdkRegion *
@@ -1100,7 +1100,7 @@ gdk_drawable_real_get_visible_region (GdkDrawable *drawable)
 
   gdk_drawable_get_size (drawable, &rect.width, &rect.height);
 
-  return gdk_region_rectangle (&rect);
+  return cairo_region_create_rectangle (&rect);
 }
 
 /**
@@ -1431,15 +1431,15 @@ gdk_drawable_real_draw_pixbuf (GdkDrawable  *drawable,
   tmp_rect.width = width;
   tmp_rect.height = height;
 
-  drect = gdk_region_rectangle (&tmp_rect);
+  drect = cairo_region_create_rectangle (&tmp_rect);
   clip = gdk_drawable_get_clip_region (drawable);
 
-  gdk_region_intersect (drect, clip);
+  cairo_region_intersect (drect, clip);
 
-  gdk_region_get_clipbox (drect, &tmp_rect);
+  cairo_region_get_extents (drect, &tmp_rect);
   
-  gdk_region_destroy (drect);
-  gdk_region_destroy (clip);
+  cairo_region_destroy (drect);
+  cairo_region_destroy (clip);
 
   if (tmp_rect.width == 0 ||
       tmp_rect.height == 0)
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index b87e319..fb2d2be 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -473,7 +473,7 @@ gdk_event_copy (const GdkEvent *event)
     case GDK_EXPOSE:
     case GDK_DAMAGE:
       if (event->expose.region)
-	new_event->expose.region = gdk_region_copy (event->expose.region);
+	new_event->expose.region = cairo_region_copy (event->expose.region);
       break;
       
     case GDK_SETTING:
@@ -551,7 +551,7 @@ gdk_event_free (GdkEvent *event)
     case GDK_EXPOSE:
     case GDK_DAMAGE:
       if (event->expose.region)
-	gdk_region_destroy (event->expose.region);
+	cairo_region_destroy (event->expose.region);
       break;
       
     case GDK_MOTION_NOTIFY:
diff --git a/gdk/gdkgc.c b/gdk/gdkgc.c
index fbdfb6d..f76ead8 100644
--- a/gdk/gdkgc.c
+++ b/gdk/gdkgc.c
@@ -205,9 +205,9 @@ gdk_gc_finalize (GObject *object)
   GdkGCPrivate *priv = GDK_GC_GET_PRIVATE (gc);
 
   if (priv->clip_region)
-    gdk_region_destroy (priv->clip_region);
+    cairo_region_destroy (priv->clip_region);
   if (priv->old_clip_region)
-    gdk_region_destroy (priv->old_clip_region);
+    cairo_region_destroy (priv->old_clip_region);
   if (priv->clip_mask)
     g_object_unref (priv->clip_mask);
   if (priv->old_clip_mask)
@@ -293,7 +293,7 @@ gdk_gc_set_values (GdkGC           *gc,
       
       if (priv->clip_region)
 	{
-	  gdk_region_destroy (priv->clip_region);
+	  cairo_region_destroy (priv->clip_region);
 	  priv->clip_region = NULL;
 	}
     }
@@ -550,7 +550,7 @@ _gdk_gc_set_clip_region_real (GdkGC     *gc,
     }
   
   if (priv->clip_region)
-    gdk_region_destroy (priv->clip_region);
+    cairo_region_destroy (priv->clip_region);
 
   priv->clip_region = region;
 
@@ -585,9 +585,9 @@ _gdk_gc_add_drawable_clip (GdkGC     *gc,
   if (priv->region_tag_applied)
     _gdk_gc_remove_drawable_clip (gc);
 
-  region = gdk_region_copy (region);
+  region = cairo_region_copy (region);
   if (offset_x != 0 || offset_y != 0)
-    gdk_region_offset (region, offset_x, offset_y);
+    cairo_region_translate (region, offset_x, offset_y);
 
   if (priv->clip_mask)
     {
@@ -596,7 +596,7 @@ _gdk_gc_add_drawable_clip (GdkGC     *gc,
       GdkGC *tmp_gc;
       GdkColor black = {0, 0, 0, 0};
       GdkRectangle r;
-      GdkOverlapType overlap;
+      cairo_region_overlap_t overlap;
 
       gdk_drawable_get_size (priv->clip_mask, &w, &h);
 
@@ -609,8 +609,8 @@ _gdk_gc_add_drawable_clip (GdkGC     *gc,
        * the region, so we try to avoid allocating bitmaps that are just fully
        * set or completely unset.
        */
-      overlap = gdk_region_rect_in (region, &r);
-      if (overlap == GDK_OVERLAP_RECTANGLE_PART)
+      overlap = cairo_region_contains_rectangle (region, &r);
+      if (overlap == CAIRO_REGION_OVERLAP_PART)
 	{
 	   /* The region and the mask intersect, create a new clip mask that
 	      includes both areas */
@@ -631,12 +631,12 @@ _gdk_gc_add_drawable_clip (GdkGC     *gc,
 	  gdk_gc_set_clip_mask (gc, new_mask);
 	  g_object_unref (new_mask);
 	}
-      else if (overlap == GDK_OVERLAP_RECTANGLE_OUT)
+      else if (overlap == CAIRO_REGION_OVERLAP_OUT)
 	{
 	  /* No intersection, set empty clip region */
-	  GdkRegion *empty = gdk_region_new ();
+	  GdkRegion *empty = cairo_region_create ();
 
-	  gdk_region_destroy (region);
+	  cairo_region_destroy (region);
 	  priv->old_clip_mask = g_object_ref (priv->clip_mask);
 	  priv->clip_region = empty;
 	  _gdk_windowing_gc_set_clip_region (gc, empty, FALSE);
@@ -644,7 +644,7 @@ _gdk_gc_add_drawable_clip (GdkGC     *gc,
       else
 	{
 	  /* Completely inside region, don't set unnecessary clip */
-	  gdk_region_destroy (region);
+	  cairo_region_destroy (region);
 	  return;
 	}
     }
@@ -653,7 +653,7 @@ _gdk_gc_add_drawable_clip (GdkGC     *gc,
       priv->old_clip_region = priv->clip_region;
       priv->clip_region = region;
       if (priv->old_clip_region)
-	gdk_region_intersect (region, priv->old_clip_region);
+	cairo_region_intersect (region, priv->old_clip_region);
 
       _gdk_windowing_gc_set_clip_region (gc, priv->clip_region, FALSE);
     }
@@ -711,7 +711,7 @@ gdk_gc_set_clip_rectangle (GdkGC              *gc,
   _gdk_gc_remove_drawable_clip (gc);
   
   if (rectangle)
-    region = gdk_region_rectangle (rectangle);
+    region = cairo_region_create_rectangle (rectangle);
   else
     region = NULL;
 
@@ -738,7 +738,7 @@ gdk_gc_set_clip_region (GdkGC           *gc,
   _gdk_gc_remove_drawable_clip (gc);
   
   if (region)
-    copy = gdk_region_copy (region);
+    copy = cairo_region_copy (region);
   else
     copy = NULL;
 
@@ -1063,20 +1063,20 @@ gdk_gc_copy (GdkGC *dst_gc,
   dst_gc->colormap = src_gc->colormap;
 
   if (dst_priv->clip_region)
-    gdk_region_destroy (dst_priv->clip_region);
+    cairo_region_destroy (dst_priv->clip_region);
 
   if (src_priv->clip_region)
-    dst_priv->clip_region = gdk_region_copy (src_priv->clip_region);
+    dst_priv->clip_region = cairo_region_copy (src_priv->clip_region);
   else
     dst_priv->clip_region = NULL;
 
   dst_priv->region_tag_applied = src_priv->region_tag_applied;
   
   if (dst_priv->old_clip_region)
-    gdk_region_destroy (dst_priv->old_clip_region);
+    cairo_region_destroy (dst_priv->old_clip_region);
 
   if (src_priv->old_clip_region)
-    dst_priv->old_clip_region = gdk_region_copy (src_priv->old_clip_region);
+    dst_priv->old_clip_region = cairo_region_copy (src_priv->old_clip_region);
   else
     dst_priv->old_clip_region = NULL;
 
diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c
index 88b33fa..f6a87e9 100644
--- a/gdk/gdkoffscreenwindow.c
+++ b/gdk/gdkoffscreenwindow.c
@@ -288,9 +288,9 @@ add_damage (GdkOffscreenWindow *offscreen,
       rect.height += 7;
     }
 
-  damage = gdk_region_rectangle (&rect);
+  damage = cairo_region_create_rectangle (&rect);
   _gdk_window_add_damage (offscreen->wrapper, damage);
-  gdk_region_destroy (damage);
+  cairo_region_destroy (damage);
 }
 
 static GdkDrawable *
diff --git a/gdk/gdkpango.c b/gdk/gdkpango.c
index a4ca424..2707817 100644
--- a/gdk/gdkpango.c
+++ b/gdk/gdkpango.c
@@ -1255,7 +1255,7 @@ layout_iter_get_line_clip_region (PangoLayoutIter *iter,
 
   line = pango_layout_iter_get_line_readonly (iter);
 
-  clip_region = gdk_region_new ();
+  clip_region = cairo_region_create ();
 
   pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
   baseline = pango_layout_iter_get_baseline (iter);
@@ -1289,7 +1289,7 @@ layout_iter_get_line_clip_region (PangoLayoutIter *iter,
           rect.width = PANGO_PIXELS (pixel_ranges[2*j + 1] - logical_rect.x) - x_off;
           rect.height = PANGO_PIXELS (baseline - logical_rect.y + logical_rect.height) - y_off;
 
-          gdk_region_union_with_rect (clip_region, &rect);
+          cairo_region_union_rectangle (clip_region, &rect);
         }
 
       g_free (pixel_ranges);
@@ -1380,7 +1380,7 @@ gdk_pango_layout_get_clip_region (PangoLayout *layout,
   g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL);
   g_return_val_if_fail (index_ranges != NULL, NULL);
   
-  clip_region = gdk_region_new ();
+  clip_region = cairo_region_create ();
   
   iter = pango_layout_get_iter (layout);
   
@@ -1399,8 +1399,8 @@ gdk_pango_layout_get_clip_region (PangoLayout *layout,
 						     index_ranges,
 						     n_ranges);
 
-      gdk_region_union (clip_region, line_region);
-      gdk_region_destroy (line_region);
+      cairo_region_union (clip_region, line_region);
+      cairo_region_destroy (line_region);
     }
   while (pango_layout_iter_next_line (iter));
 
diff --git a/gdk/gdkpolyreg-generic.c b/gdk/gdkpolyreg-generic.c
index f344b54..afcc278 100644
--- a/gdk/gdkpolyreg-generic.c
+++ b/gdk/gdkpolyreg-generic.c
@@ -481,7 +481,7 @@ gdk_region_polygon (const GdkPoint *points,
 	extents.y = MIN(points[0].y, points[2].y);
 	extents.width = MAX(points[0].x, points[2].x) - extents.x;
 	extents.height = MAX(points[0].y, points[2].y) - extents.y;
-	return gdk_region_rectangle (&extents);
+	return cairo_region_create_rectangle (&extents);
     }
 
     pETEs = g_new (EdgeTableEntry, n_points);
diff --git a/gdk/gdkregion-generic.c b/gdk/gdkregion-generic.c
index ff66adc..5fe743c 100644
--- a/gdk/gdkregion-generic.c
+++ b/gdk/gdkregion-generic.c
@@ -10,6 +10,8 @@
  * Creates a new empty #GdkRegion.
  *
  * Returns: a new empty #GdkRegion
+ *
+ * Deprecated: 2.22: Use cairo_region_create() instead.
  */
 GdkRegion *
 gdk_region_new (void)
@@ -24,6 +26,8 @@ gdk_region_new (void)
  * Creates a new region containing the area @rectangle.
  * 
  * Return value: a new region
+ *
+ * Deprecated: 2.22: Use cairo_region_create_rectangle()
  **/
 GdkRegion *
 gdk_region_rectangle (const GdkRectangle *rectangle)
@@ -43,6 +47,8 @@ gdk_region_rectangle (const GdkRectangle *rectangle)
  * Copies @region, creating an identical new region.
  * 
  * Return value: a new region identical to @region
+ *
+ * Deprecated: 2.22: Use cairo_region_copy()
  **/
 GdkRegion *
 gdk_region_copy (const GdkRegion *region)
@@ -57,6 +63,7 @@ gdk_region_copy (const GdkRegion *region)
  *
  * Obtains the smallest rectangle which includes the entire #GdkRegion.
  *
+ * Deprecated: 2.22: Use cairo_region_get_extents()
  */
 void
 gdk_region_get_clipbox (const GdkRegion *region,
@@ -77,6 +84,8 @@ gdk_region_get_clipbox (const GdkRegion *region,
  *
  * Obtains the area covered by the region as a list of rectangles.
  * The array returned in @rectangles must be freed with g_free().
+ *
+ * Deprecated: 2.22: Use cairo_region_num_rectangles() and cairo_region_get_rectangle() instead.
  **/
 void
 gdk_region_get_rectangles (const GdkRegion  *region,
@@ -110,6 +119,8 @@ gdk_region_get_rectangles (const GdkRegion  *region,
  * Sets the area of @region to the union of the areas of @region and
  * @rect. The resulting area is the set of pixels contained in
  * either @region or @rect.
+ *
+ * Deprecated: 2.22: Use cairo_region_union_rectangle() instead.
  **/
 void
 gdk_region_union_with_rect (GdkRegion          *region,
@@ -129,6 +140,8 @@ gdk_region_union_with_rect (GdkRegion          *region,
  * @region: a #GdkRegion
  *
  * Destroys a #GdkRegion.
+ *
+ * Deprecated: 2.22: Use cairo_region_destroy() instead.
  */
 void
 gdk_region_destroy (GdkRegion *region)
@@ -146,6 +159,8 @@ gdk_region_destroy (GdkRegion *region)
  * @dy: the distance to move the region vertically
  *
  * Moves a region the specified distance.
+ *
+ * Deprecated: 2.22: Use cairo_region_translate() instead.
  */
 void
 gdk_region_offset (GdkRegion *region,
@@ -163,6 +178,8 @@ gdk_region_offset (GdkRegion *region,
  *
  * Resizes a region by the specified amount.
  * Positive values shrink the region. Negative values expand it.
+ *
+ * Deprecated: 2.22: There is no replacement for this function.
  */
 void
 gdk_region_shrink (GdkRegion *region,
@@ -198,6 +215,8 @@ gdk_region_shrink (GdkRegion *region,
  * Sets the area of @source1 to the intersection of the areas of @source1
  * and @source2. The resulting area is the set of pixels contained in
  * both @source1 and @source2.
+ *
+ * Deprecated: 2.22: Use cairo_region_intersect() instead.
  **/
 void
 gdk_region_intersect (GdkRegion       *source1,
@@ -217,6 +236,8 @@ gdk_region_intersect (GdkRegion       *source1,
  * Sets the area of @source1 to the union of the areas of @source1 and
  * @source2. The resulting area is the set of pixels contained in
  * either @source1 or @source2.
+ *
+ * Deprecated: 2.22: Use cairo_region_union() instead.
  **/
 void
 gdk_region_union (GdkRegion       *source1,
@@ -235,6 +256,8 @@ gdk_region_union (GdkRegion       *source1,
  *
  * Subtracts the area of @source2 from the area @source1. The resulting
  * area is the set of pixels contained in @source1 but not in @source2.
+ *
+ * Deprecated: 2.22: Use cairo_region_subtract() instead.
  **/
 void
 gdk_region_subtract (GdkRegion       *source1,
@@ -254,6 +277,10 @@ gdk_region_subtract (GdkRegion       *source1,
  * Sets the area of @source1 to the exclusive-OR of the areas of @source1
  * and @source2. The resulting area is the set of pixels contained in one
  * or the other of the two sources but not in both.
+ *
+ * Deprecated: 2.22: There is no replacement, but the function can be
+ *                   reimplemented using cairo_region_intersect() and
+ *                   cairo_region_subract() easily.
  **/
 void
 gdk_region_xor (GdkRegion       *source1,
@@ -281,6 +308,8 @@ gdk_region_xor (GdkRegion       *source1,
  * Finds out if the #GdkRegion is empty.
  *
  * Returns: %TRUE if @region is empty.
+ *
+ * Deprecated: 2.22: Use cairo_region_is_empty() instead.
  */
 gboolean
 gdk_region_empty (const GdkRegion *region)
@@ -298,6 +327,8 @@ gdk_region_empty (const GdkRegion *region)
  * Finds out if the two regions are the same.
  *
  * Returns: %TRUE if @region1 and @region2 are equal.
+ *
+ * Deprecated: 2.22: Use cairo_region_equal() instead.
  */
 gboolean
 gdk_region_equal (const GdkRegion *region1,
@@ -347,6 +378,8 @@ gdk_region_rect_equal (const GdkRegion    *region,
  * Finds out if a point is in a region.
  *
  * Returns: %TRUE if the point is in @region.
+ *
+ * Deprecated: 2.22: Use cairo_region_contains_point() instead.
  */
 gboolean
 gdk_region_point_in (const GdkRegion *region,
@@ -368,6 +401,8 @@ gdk_region_point_in (const GdkRegion *region,
  * Returns: %GDK_OVERLAP_RECTANGLE_IN, %GDK_OVERLAP_RECTANGLE_OUT, or
  *   %GDK_OVERLAP_RECTANGLE_PART, depending on whether the rectangle is inside,
  *   outside, or partly inside the #GdkRegion, respectively.
+ *
+ * Deprecated: 2.22: Use cairo_region_contains_rectangle() instead.
  */
 GdkOverlapType
 gdk_region_rect_in (const GdkRegion    *region,
@@ -445,6 +480,8 @@ gdk_region_unsorted_spans_intersect_foreach (GdkRegion     *region,
  * @data: data to pass to @function
  *
  * Calls a function on each span in the intersection of @region and @spans.
+ *
+ * Deprecated: 2.22: There is no replacement.
  */
 void
 gdk_region_spans_intersect_foreach (GdkRegion     *region,
diff --git a/gdk/gdkregion.h b/gdk/gdkregion.h
index f8a00eb..c00fb42 100644
--- a/gdk/gdkregion.h
+++ b/gdk/gdkregion.h
@@ -45,10 +45,14 @@ typedef enum
   GDK_WINDING_RULE
 } GdkFillRule;
 
+#ifndef GDK_DISABLE_DEPRECATED
 /* Types of overlapping between a rectangle and a region
  * GDK_OVERLAP_RECTANGLE_IN: rectangle is in region
  * GDK_OVERLAP_RECTANGLE_OUT: rectangle in not in region
  * GDK_OVERLAP_RECTANGLE_PART: rectangle in partially in region
+ *
+ * Deprecated: 2.22: Superceded by #cairo_region_overlap_t and
+ *                   cairo_region_contains_rectangle().
  */
 typedef enum
 {
@@ -61,9 +65,11 @@ typedef void (* GdkSpanFunc) (GdkSpan *span,
                               gpointer data);
 
 GdkRegion    * gdk_region_new             (void);
+#endif
 GdkRegion    * gdk_region_polygon         (const GdkPoint     *points,
                                            gint                n_points,
                                            GdkFillRule         fill_rule);
+#ifndef GDK_DISABLE_DEPRECATED
 GdkRegion    * gdk_region_copy            (const GdkRegion    *region);
 GdkRegion    * gdk_region_rectangle       (const GdkRectangle *rectangle);
 void           gdk_region_destroy         (GdkRegion          *region);
@@ -77,8 +83,10 @@ void           gdk_region_get_rectangles  (const GdkRegion    *region,
 gboolean       gdk_region_empty           (const GdkRegion    *region);
 gboolean       gdk_region_equal           (const GdkRegion    *region1,
                                            const GdkRegion    *region2);
+#endif
 gboolean       gdk_region_rect_equal      (const GdkRegion    *region,
                                            const GdkRectangle *rectangle);
+#ifndef GDK_DISABLE_DEPRECATED
 gboolean       gdk_region_point_in        (const GdkRegion    *region,
                                            int                 x,
                                            int                 y);
@@ -108,6 +116,7 @@ void   gdk_region_spans_intersect_foreach (GdkRegion          *region,
                                            gboolean            sorted,
                                            GdkSpanFunc         function,
                                            gpointer            data);
+#endif
 
 G_END_DECLS
 
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index a6f1392..b4c84aa 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -688,10 +688,10 @@ gdk_window_finalize (GObject *object)
     }
 
   if (obj->shape)
-    gdk_region_destroy (obj->shape);
+    cairo_region_destroy (obj->shape);
 
   if (obj->input_shape)
-    gdk_region_destroy (obj->input_shape);
+    cairo_region_destroy (obj->input_shape);
 
   if (obj->cursor)
     gdk_cursor_unref (obj->cursor);
@@ -813,7 +813,7 @@ remove_child_area (GdkWindowObject *private,
 
       /* If region is empty already, no need to do
 	 anything potentially costly */
-      if (gdk_region_empty (region))
+      if (cairo_region_is_empty (region))
 	break;
 
       if (!GDK_WINDOW_IS_MAPPED (child) || child->input_only || child->composited)
@@ -830,45 +830,45 @@ remove_child_area (GdkWindowObject *private,
       r.height = child->height;
 
       /* Bail early if child totally outside region */
-      if (gdk_region_rect_in (region, &r) == GDK_OVERLAP_RECTANGLE_OUT)
+      if (cairo_region_contains_rectangle (region, &r) == CAIRO_REGION_OVERLAP_OUT)
 	continue;
 
-      child_region = gdk_region_rectangle (&r);
+      child_region = cairo_region_create_rectangle (&r);
 
       if (child->shape)
 	{
 	  /* Adjust shape region to parent window coords */
-	  gdk_region_offset (child->shape, child->x, child->y);
-	  gdk_region_intersect (child_region, child->shape);
-	  gdk_region_offset (child->shape, -child->x, -child->y);
+	  cairo_region_translate (child->shape, child->x, child->y);
+	  cairo_region_intersect (child_region, child->shape);
+	  cairo_region_translate (child->shape, -child->x, -child->y);
 	}
       else if (private->window_type == GDK_WINDOW_FOREIGN)
 	{
 	  shape = _gdk_windowing_window_get_shape ((GdkWindow *)child);
 	  if (shape)
 	    {
-	      gdk_region_intersect (child_region, shape);
-	      gdk_region_destroy (shape);
+	      cairo_region_intersect (child_region, shape);
+	      cairo_region_destroy (shape);
 	    }
 	}
 
       if (for_input)
 	{
 	  if (child->input_shape)
-	    gdk_region_intersect (child_region, child->input_shape);
+	    cairo_region_intersect (child_region, child->input_shape);
 	  else if (private->window_type == GDK_WINDOW_FOREIGN)
 	    {
 	      shape = _gdk_windowing_window_get_input_shape ((GdkWindow *)child);
 	      if (shape)
 		{
-		  gdk_region_intersect (child_region, shape);
-		  gdk_region_destroy (shape);
+		  cairo_region_intersect (child_region, shape);
+		  cairo_region_destroy (shape);
 		}
 	    }
 	}
 
-      gdk_region_subtract (region, child_region);
-      gdk_region_destroy (child_region);
+      cairo_region_subtract (region, child_region);
+      cairo_region_destroy (child_region);
 
     }
 }
@@ -967,6 +967,23 @@ apply_shape (GdkWindowObject *private,
   private->applied_shape = region != NULL;
 }
 
+static gboolean
+region_rect_equal (const cairo_region_t *region,
+                   const GdkRectangle *rect)
+{
+    GdkRectangle extents;
+
+    if (cairo_region_num_rectangles (region) != 1)
+        return FALSE;
+
+    cairo_region_get_extents (region, &extents);
+
+    return extents.x == rect->x &&
+        extents.y == rect->y &&
+        extents.width == rect->width &&
+        extents.height == rect->height;
+}
+
 static void
 apply_clip_as_shape (GdkWindowObject *private)
 {
@@ -980,7 +997,7 @@ apply_clip_as_shape (GdkWindowObject *private)
      from the actual clip region implied by the size
      of the window. This is to avoid unneccessarily
      adding meaningless shapes to all native subwindows */
-  if (!gdk_region_rect_equal (private->clip_region, &r))
+  if (!region_rect_equal (private->clip_region, &r))
     apply_shape (private, private->clip_region);
   else
     apply_shape (private, NULL);
@@ -1035,11 +1052,11 @@ recompute_visible_regions_internal (GdkWindowObject *private,
 	  r.y = private->y;
 	  r.width = private->width;
 	  r.height = private->height;
-	  new_clip = gdk_region_rectangle (&r);
+	  new_clip = cairo_region_create_rectangle (&r);
 
 	  if (!gdk_window_is_toplevel (private))
 	    {
-	      gdk_region_intersect (new_clip, private->parent->clip_region);
+	      cairo_region_intersect (new_clip, private->parent->clip_region);
 
 	      /* Remove all overlapping children from parent.
 	       * Unless we're all native, because then we don't need to take
@@ -1052,33 +1069,33 @@ recompute_visible_regions_internal (GdkWindowObject *private,
 	    }
 
 	  /* Convert from parent coords to window coords */
-	  gdk_region_offset (new_clip, -private->x, -private->y);
+	  cairo_region_translate (new_clip, -private->x, -private->y);
 
 	  if (private->shape)
-	    gdk_region_intersect (new_clip, private->shape);
+	    cairo_region_intersect (new_clip, private->shape);
 	}
       else
-	new_clip = gdk_region_new ();
+	new_clip = cairo_region_create ();
 
       if (private->clip_region == NULL ||
-	  !gdk_region_equal (private->clip_region, new_clip))
+	  !cairo_region_equal (private->clip_region, new_clip))
 	clip_region_changed = TRUE;
 
       if (private->clip_region)
-	gdk_region_destroy (private->clip_region);
+	cairo_region_destroy (private->clip_region);
       private->clip_region = new_clip;
 
       old_clip_region_with_children = private->clip_region_with_children;
-      private->clip_region_with_children = gdk_region_copy (private->clip_region);
+      private->clip_region_with_children = cairo_region_copy (private->clip_region);
       if (private->window_type != GDK_WINDOW_ROOT)
 	remove_child_area (private, NULL, FALSE, private->clip_region_with_children);
 
       if (clip_region_changed ||
-	  !gdk_region_equal (private->clip_region_with_children, old_clip_region_with_children))
+	  !cairo_region_equal (private->clip_region_with_children, old_clip_region_with_children))
 	  private->clip_tag = new_region_tag ();
 
       if (old_clip_region_with_children)
-	gdk_region_destroy (old_clip_region_with_children);
+	cairo_region_destroy (old_clip_region_with_children);
     }
 
   if (clip_region_changed)
@@ -1086,13 +1103,13 @@ recompute_visible_regions_internal (GdkWindowObject *private,
       GdkVisibilityState visibility;
       gboolean fully_visible;
 
-      if (gdk_region_empty (private->clip_region))
+      if (cairo_region_is_empty (private->clip_region))
 	visibility = GDK_VISIBILITY_FULLY_OBSCURED;
       else
         {
           if (private->shape)
             {
-	      fully_visible = gdk_region_equal (private->clip_region,
+	      fully_visible = cairo_region_equal (private->clip_region,
 	                                        private->shape);
             }
           else
@@ -1101,7 +1118,7 @@ recompute_visible_regions_internal (GdkWindowObject *private,
 	      r.y = 0;
 	      r.width = private->width;
 	      r.height = private->height;
-	      fully_visible = gdk_region_rect_equal (private->clip_region, &r);
+	      fully_visible = region_rect_equal (private->clip_region, &r);
 	    }
 
 	  if (fully_visible)
@@ -2227,13 +2244,13 @@ _gdk_window_destroy_hierarchy (GdkWindow *window,
 
 	  if (private->clip_region)
 	    {
-	      gdk_region_destroy (private->clip_region);
+	      cairo_region_destroy (private->clip_region);
 	      private->clip_region = NULL;
 	    }
 
 	  if (private->clip_region_with_children)
 	    {
-	      gdk_region_destroy (private->clip_region_with_children);
+	      cairo_region_destroy (private->clip_region_with_children);
 	      private->clip_region_with_children = NULL;
 	    }
 
@@ -2825,7 +2842,7 @@ gdk_window_begin_implicit_paint (GdkWindow *window, GdkRectangle *rect)
     return FALSE;
 
   paint = g_new (GdkWindowPaint, 1);
-  paint->region = gdk_region_new (); /* Empty */
+  paint->region = cairo_region_create (); /* Empty */
   paint->x_offset = rect->x;
   paint->y_offset = rect->y;
   paint->uses_implicit = FALSE;
@@ -2859,7 +2876,7 @@ gdk_window_flush_implicit_paint (GdkWindow *window)
 
   paint = impl_window->implicit_paint;
   paint->flushed = TRUE;
-  region = gdk_region_copy (private->clip_region_with_children);
+  region = cairo_region_copy (private->clip_region_with_children);
 
   /* Don't flush active double buffers, as that may show partially done
    * rendering */
@@ -2867,16 +2884,16 @@ gdk_window_flush_implicit_paint (GdkWindow *window)
     {
       GdkWindowPaint *tmp_paint = list->data;
 
-      gdk_region_subtract (region, tmp_paint->region);
+      cairo_region_subtract (region, tmp_paint->region);
     }
 
-  gdk_region_offset (region, private->abs_x, private->abs_y);
-  gdk_region_intersect (region, paint->region);
+  cairo_region_translate (region, private->abs_x, private->abs_y);
+  cairo_region_intersect (region, paint->region);
 
-  if (!GDK_WINDOW_DESTROYED (window) && !gdk_region_empty (region))
+  if (!GDK_WINDOW_DESTROYED (window) && !cairo_region_is_empty (region))
     {
       /* Remove flushed region from the implicit paint */
-      gdk_region_subtract (paint->region, region);
+      cairo_region_subtract (paint->region, region);
 
       /* Some regions are valid, push these to window now */
       tmp_gc = _gdk_drawable_get_scratch_gc ((GdkDrawable *)window, FALSE);
@@ -2887,7 +2904,7 @@ gdk_window_flush_implicit_paint (GdkWindow *window)
       gdk_gc_set_clip_region (tmp_gc, NULL);
     }
   else
-    gdk_region_destroy (region);
+    cairo_region_destroy (region);
 }
 
 /* Ends an implicit paint, paired with gdk_window_begin_implicit_paint returning TRUE */
@@ -2906,7 +2923,7 @@ gdk_window_end_implicit_paint (GdkWindow *window)
 
   private->implicit_paint = NULL;
 
-  if (!GDK_WINDOW_DESTROYED (window) && !gdk_region_empty (paint->region))
+  if (!GDK_WINDOW_DESTROYED (window) && !cairo_region_is_empty (paint->region))
     {
       /* Some regions are valid, push these to window now */
       tmp_gc = _gdk_drawable_get_scratch_gc ((GdkDrawable *)window, FALSE);
@@ -2917,7 +2934,7 @@ gdk_window_end_implicit_paint (GdkWindow *window)
       gdk_gc_set_clip_region (tmp_gc, NULL);
     }
   else
-    gdk_region_destroy (paint->region);
+    cairo_region_destroy (paint->region);
 
   g_object_unref (paint->pixmap);
   g_free (paint);
@@ -2941,9 +2958,9 @@ gdk_window_begin_paint_rect (GdkWindow          *window,
 
   g_return_if_fail (GDK_IS_WINDOW (window));
 
-  region = gdk_region_rectangle (rectangle);
+  region = cairo_region_create_rectangle (rectangle);
   gdk_window_begin_paint_region (window, region);
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
 }
 
 /**
@@ -3021,22 +3038,22 @@ gdk_window_begin_paint_region (GdkWindow       *window,
   implicit_paint = impl_window->implicit_paint;
 
   paint = g_new (GdkWindowPaint, 1);
-  paint->region = gdk_region_copy (region);
+  paint->region = cairo_region_copy (region);
   paint->region_tag = new_region_tag ();
 
-  gdk_region_intersect (paint->region, private->clip_region_with_children);
-  gdk_region_get_clipbox (paint->region, &clip_box);
+  cairo_region_intersect (paint->region, private->clip_region_with_children);
+  cairo_region_get_extents (paint->region, &clip_box);
 
   /* Convert to impl coords */
-  gdk_region_offset (paint->region, private->abs_x, private->abs_y);
+  cairo_region_translate (paint->region, private->abs_x, private->abs_y);
 
   /* Mark the region as valid on the implicit paint */
 
   if (implicit_paint)
-    gdk_region_union (implicit_paint->region, paint->region);
+    cairo_region_union (implicit_paint->region, paint->region);
 
   /* Convert back to normal coords */
-  gdk_region_offset (paint->region, -private->abs_x, -private->abs_y);
+  cairo_region_translate (paint->region, -private->abs_x, -private->abs_y);
 
   if (implicit_paint)
     {
@@ -3069,12 +3086,12 @@ gdk_window_begin_paint_region (GdkWindow       *window,
     {
       GdkWindowPaint *tmp_paint = list->data;
 
-      gdk_region_subtract (tmp_paint->region, paint->region);
+      cairo_region_subtract (tmp_paint->region, paint->region);
     }
 
   private->paint_stack = g_slist_prepend (private->paint_stack, paint);
 
-  if (!gdk_region_empty (paint->region))
+  if (!cairo_region_is_empty (paint->region))
     {
       gdk_window_clear_backing_region (window,
 				       paint->region);
@@ -3113,9 +3130,9 @@ setup_redirect_clip (GdkWindow      *window,
   dest_rect.y = -y_offset;
   dest_rect.width = private->redirect->width;
   dest_rect.height = private->redirect->height;
-  tmpreg = gdk_region_rectangle (&dest_rect);
-  gdk_region_intersect (visible_region, tmpreg);
-  gdk_region_destroy (tmpreg);
+  tmpreg = cairo_region_create_rectangle (&dest_rect);
+  cairo_region_intersect (visible_region, tmpreg);
+  cairo_region_destroy (tmpreg);
 
   /* Compensate for the dest pos */
   x_offset += private->redirect->dest_x;
@@ -3126,7 +3143,7 @@ setup_redirect_clip (GdkWindow      *window,
   /* offset clip and tiles from window coords to pixmaps coords */
   gdk_gc_offset (gc, -x_offset, -y_offset);
 
-  gdk_region_destroy (visible_region);
+  cairo_region_destroy (visible_region);
 
   *x_offset_out = x_offset;
   *y_offset_out = y_offset;
@@ -3182,7 +3199,7 @@ gdk_window_end_paint (GdkWindow *window)
   private->paint_stack = g_slist_delete_link (private->paint_stack,
 					      private->paint_stack);
 
-  gdk_region_get_clipbox (paint->region, &clip_box);
+  cairo_region_get_extents (paint->region, &clip_box);
 
   tmp_gc = _gdk_drawable_get_scratch_gc (window, FALSE);
 
@@ -3193,8 +3210,8 @@ gdk_window_end_paint (GdkWindow *window)
     {
       gdk_window_flush_outstanding_moves (window);
 
-      full_clip = gdk_region_copy (private->clip_region_with_children);
-      gdk_region_intersect (full_clip, paint->region);
+      full_clip = cairo_region_copy (private->clip_region_with_children);
+      cairo_region_intersect (full_clip, paint->region);
       _gdk_gc_set_clip_region_internal (tmp_gc, full_clip, TRUE); /* Takes ownership of full_clip */
       gdk_gc_set_clip_origin (tmp_gc, - x_offset, - y_offset);
       gdk_draw_drawable (private->impl, tmp_gc, paint->pixmap,
@@ -3223,7 +3240,7 @@ gdk_window_end_paint (GdkWindow *window)
 
   cairo_surface_destroy (paint->surface);
   g_object_unref (paint->pixmap);
-  gdk_region_destroy (paint->region);
+  cairo_region_destroy (paint->region);
   g_free (paint);
 
   /* find a composited window in our hierarchy to signal its
@@ -3272,7 +3289,7 @@ gdk_window_free_paint_stack (GdkWindow *window)
 	  if (tmp_list == private->paint_stack)
 	    g_object_unref (paint->pixmap);
 
-	  gdk_region_destroy (paint->region);
+	  cairo_region_destroy (paint->region);
 	  g_free (paint);
 
 	  tmp_list = tmp_list->next;
@@ -3308,12 +3325,12 @@ do_move_region_bits_on_impl (GdkWindowObject *impl_window,
     }
   tmp_gc = _gdk_drawable_get_subwindow_scratch_gc ((GdkWindow *)private);
 
-  gdk_region_get_clipbox (dest_region, &copy_rect);
+  cairo_region_get_extents (dest_region, &copy_rect);
   gdk_gc_set_clip_region (tmp_gc, dest_region);
 
   /* The region area is moved and we queue translations for all expose events
      to the source area that were sent prior to the copy */
-  gdk_region_offset (dest_region, -dx, -dy); /* Move to source region */
+  cairo_region_translate (dest_region, -dx, -dy); /* Move to source region */
   impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl);
 
   impl_iface->queue_translation ((GdkWindow *)impl_window,
@@ -3336,7 +3353,7 @@ gdk_window_region_move_new (GdkRegion *region,
   GdkWindowRegionMove *move;
 
   move = g_slice_new (GdkWindowRegionMove);
-  move->dest_region  = gdk_region_copy (region);
+  move->dest_region  = cairo_region_copy (region);
   move->dx = dx;
   move->dy = dy;
 
@@ -3346,7 +3363,7 @@ gdk_window_region_move_new (GdkRegion *region,
 static void
 gdk_window_region_move_free (GdkWindowRegionMove *move)
 {
-  gdk_region_destroy (move->dest_region);
+  cairo_region_destroy (move->dest_region);
   g_slice_free (GdkWindowRegionMove, move);
 }
 
@@ -3362,7 +3379,7 @@ append_move_region (GdkWindowObject *impl_window,
   gboolean added_move;
   GList *l, *prev;
 
-  if (gdk_region_empty (new_dest_region))
+  if (cairo_region_is_empty (new_dest_region))
     return;
 
   /* In principle this could just append the move to the list of outstanding
@@ -3378,9 +3395,9 @@ append_move_region (GdkWindowObject *impl_window,
      move is in the source of the new move, or if the destination of the new
      move overlaps the destination of the old move. We simplify this by
      just comparing the total regions (src + dest) */
-  new_total_region = gdk_region_copy (new_dest_region);
-  gdk_region_offset (new_total_region, -dx, -dy);
-  gdk_region_union (new_total_region, new_dest_region);
+  new_total_region = cairo_region_copy (new_dest_region);
+  cairo_region_translate (new_total_region, -dx, -dy);
+  cairo_region_union (new_total_region, new_dest_region);
 
   added_move = FALSE;
   for (l = g_list_last (impl_window->outstanding_moves); l != NULL; l = prev)
@@ -3388,28 +3405,28 @@ append_move_region (GdkWindowObject *impl_window,
       prev = l->prev;
       old_move = l->data;
 
-      old_total_region = gdk_region_copy (old_move->dest_region);
-      gdk_region_offset (old_total_region, -old_move->dx, -old_move->dy);
-      gdk_region_union (old_total_region, old_move->dest_region);
+      old_total_region = cairo_region_copy (old_move->dest_region);
+      cairo_region_translate (old_total_region, -old_move->dx, -old_move->dy);
+      cairo_region_union (old_total_region, old_move->dest_region);
 
-      gdk_region_intersect (old_total_region, new_total_region);
+      cairo_region_intersect (old_total_region, new_total_region);
       /* If these regions intersect then its not safe to push the
 	 new region before the old one */
-      if (!gdk_region_empty (old_total_region))
+      if (!cairo_region_is_empty (old_total_region))
 	{
 	  /* The area where the new moves source overlaps the old ones
 	     destination */
-	  source_overlaps_destination = gdk_region_copy (new_dest_region);
-	  gdk_region_offset (source_overlaps_destination, -dx, -dy);
-	  gdk_region_intersect (source_overlaps_destination, old_move->dest_region);
-	  gdk_region_offset (source_overlaps_destination, dx, dy);
+	  source_overlaps_destination = cairo_region_copy (new_dest_region);
+	  cairo_region_translate (source_overlaps_destination, -dx, -dy);
+	  cairo_region_intersect (source_overlaps_destination, old_move->dest_region);
+	  cairo_region_translate (source_overlaps_destination, dx, dy);
 
 	  /* We can do all sort of optimizations here, but to do things safely it becomes
 	     quite complicated. However, a very common case is that you copy something first,
 	     then copy all that or a subset of it to a new location (i.e. if you scroll twice
 	     in the same direction). We'd like to detect this case and optimize it to one
 	     copy. */
-	  if (gdk_region_equal (source_overlaps_destination, new_dest_region))
+	  if (cairo_region_equal (source_overlaps_destination, new_dest_region))
 	    {
 	      /* This means we might be able to replace the old move and the new one
 		 with the new one read from the old ones source, and a second copy of
@@ -3418,13 +3435,13 @@ append_move_region (GdkWindowObject *impl_window,
 		 by the destination of the new one */
 
 	      /* the new destination of old move if split is ok: */
-	      non_overwritten = gdk_region_copy (old_move->dest_region);
-	      gdk_region_subtract (non_overwritten, new_dest_region);
+	      non_overwritten = cairo_region_copy (old_move->dest_region);
+	      cairo_region_subtract (non_overwritten, new_dest_region);
 	      /* move to source region */
-	      gdk_region_offset (non_overwritten, -old_move->dx, -old_move->dy);
+	      cairo_region_translate (non_overwritten, -old_move->dx, -old_move->dy);
 
-	      gdk_region_intersect (non_overwritten, new_dest_region);
-	      if (gdk_region_empty (non_overwritten))
+	      cairo_region_intersect (non_overwritten, new_dest_region);
+	      if (cairo_region_is_empty (non_overwritten))
 		{
 		  added_move = TRUE;
 		  move = gdk_window_region_move_new (new_dest_region,
@@ -3434,19 +3451,19 @@ append_move_region (GdkWindowObject *impl_window,
 		  impl_window->outstanding_moves =
 		    g_list_insert_before (impl_window->outstanding_moves,
 					  l, move);
-		  gdk_region_subtract (old_move->dest_region, new_dest_region);
+		  cairo_region_subtract (old_move->dest_region, new_dest_region);
 		}
-	      gdk_region_destroy (non_overwritten);
+	      cairo_region_destroy (non_overwritten);
 	    }
 
-	  gdk_region_destroy (source_overlaps_destination);
-	  gdk_region_destroy (old_total_region);
+	  cairo_region_destroy (source_overlaps_destination);
+	  cairo_region_destroy (old_total_region);
 	  break;
 	}
-      gdk_region_destroy (old_total_region);
+      cairo_region_destroy (old_total_region);
     }
 
-  gdk_region_destroy (new_total_region);
+  cairo_region_destroy (new_total_region);
 
   if (!added_move)
     {
@@ -3471,9 +3488,9 @@ move_region_on_impl (GdkWindowObject *impl_window,
 		     int dx, int dy)
 {
   if ((dx == 0 && dy == 0) ||
-      gdk_region_empty (region))
+      cairo_region_is_empty (region))
     {
-      gdk_region_destroy (region);
+      cairo_region_destroy (region);
       return;
     }
 
@@ -3484,25 +3501,25 @@ move_region_on_impl (GdkWindowObject *impl_window,
     {
       GdkRegion *update_area;
 
-      update_area = gdk_region_copy (region);
+      update_area = cairo_region_copy (region);
 
       /* Convert from target to source */
-      gdk_region_offset (update_area, -dx, -dy);
-      gdk_region_intersect (update_area, impl_window->update_area);
+      cairo_region_translate (update_area, -dx, -dy);
+      cairo_region_intersect (update_area, impl_window->update_area);
       /* We only copy the area, so keep the old update area invalid.
 	 It would be safe to remove it too, as code that uses
 	 move_region_on_impl generally also invalidate the source
 	 area. However, it would just use waste cycles. */
 
       /* Convert back */
-      gdk_region_offset (update_area, dx, dy);
-      gdk_region_union (impl_window->update_area, update_area);
+      cairo_region_translate (update_area, dx, dy);
+      cairo_region_union (impl_window->update_area, update_area);
 
       /* This area of the destination is now invalid,
 	 so no need to copy to it.  */
-      gdk_region_subtract (region, update_area);
+      cairo_region_subtract (region, update_area);
 
-      gdk_region_destroy (update_area);
+      cairo_region_destroy (update_area);
     }
 
   /* If we're currently exposing this window, don't copy to this
@@ -3513,12 +3530,12 @@ move_region_on_impl (GdkWindowObject *impl_window,
       GdkWindowPaint *implicit_paint = impl_window->implicit_paint;
       GdkRegion *exposing;
 
-      exposing = gdk_region_copy (implicit_paint->region);
-      gdk_region_intersect (exposing, region);
-      gdk_region_subtract (region, exposing);
+      exposing = cairo_region_copy (implicit_paint->region);
+      cairo_region_intersect (exposing, region);
+      cairo_region_subtract (region, exposing);
 
       impl_window_add_update_area (impl_window, exposing);
-      gdk_region_destroy (exposing);
+      cairo_region_destroy (exposing);
     }
 
   if (impl_window->outstanding_surfaces == 0) /* Enable flicker free handling of moves. */
@@ -3527,7 +3544,7 @@ move_region_on_impl (GdkWindowObject *impl_window,
     do_move_region_bits_on_impl (impl_window,
 				 region, dx, dy);
 
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
 }
 
 /* Flushes all outstanding changes to the window, call this
@@ -4073,18 +4090,18 @@ gdk_window_get_composite_drawable (GdkDrawable *drawable,
   for (list = private->paint_stack; list != NULL; list = list->next)
     {
       GdkWindowPaint *paint = list->data;
-      GdkOverlapType overlap;
+      cairo_region_overlap_t overlap;
 
-      overlap = gdk_region_rect_in (paint->region, &rect);
+      overlap = cairo_region_contains_rectangle (paint->region, &rect);
 
-      if (overlap == GDK_OVERLAP_RECTANGLE_IN)
+      if (overlap == CAIRO_REGION_OVERLAP_IN)
 	{
 	  *composite_x_offset = paint->x_offset;
 	  *composite_y_offset = paint->y_offset;
 
 	  return g_object_ref (paint->pixmap);
 	}
-      else if (overlap == GDK_OVERLAP_RECTANGLE_PART)
+      else if (overlap == CAIRO_REGION_OVERLAP_PART)
 	{
 	  overlap_buffer = TRUE;
 	  break;
@@ -4095,20 +4112,20 @@ gdk_window_get_composite_drawable (GdkDrawable *drawable,
   implicit_paint = impl_window->implicit_paint;
   if (implicit_paint)
     {
-      GdkOverlapType overlap;
+      cairo_region_overlap_t overlap;
 
       rect.x += private->abs_x;
       rect.y += private->abs_y;
 
-      overlap = gdk_region_rect_in (implicit_paint->region, &rect);
-      if (overlap == GDK_OVERLAP_RECTANGLE_IN)
+      overlap = cairo_region_contains_rectangle (implicit_paint->region, &rect);
+      if (overlap == CAIRO_REGION_OVERLAP_IN)
 	{
 	  *composite_x_offset = -private->abs_x + implicit_paint->x_offset;
 	  *composite_y_offset = -private->abs_y + implicit_paint->y_offset;
 
 	  return g_object_ref (implicit_paint->pixmap);
 	}
-      else if (overlap == GDK_OVERLAP_RECTANGLE_PART)
+      else if (overlap == CAIRO_REGION_OVERLAP_PART)
 	overlap_buffer = TRUE;
     }
 
@@ -4175,24 +4192,24 @@ gdk_window_get_clip_region (GdkDrawable *drawable)
   GdkWindowObject *private = (GdkWindowObject *)drawable;
   GdkRegion *result;
 
-  result = gdk_region_copy (private->clip_region);
+  result = cairo_region_copy (private->clip_region);
 
   if (private->paint_stack)
     {
-      GdkRegion *paint_region = gdk_region_new ();
+      GdkRegion *paint_region = cairo_region_create ();
       GSList *tmp_list = private->paint_stack;
 
       while (tmp_list)
 	{
 	  GdkWindowPaint *paint = tmp_list->data;
 
-	  gdk_region_union (paint_region, paint->region);
+	  cairo_region_union (paint_region, paint->region);
 
 	  tmp_list = tmp_list->next;
 	}
 
-      gdk_region_intersect (result, paint_region);
-      gdk_region_destroy (paint_region);
+      cairo_region_intersect (result, paint_region);
+      cairo_region_destroy (paint_region);
     }
 
   return result;
@@ -4203,7 +4220,7 @@ gdk_window_get_visible_region (GdkDrawable *drawable)
 {
   GdkWindowObject *private = (GdkWindowObject*) drawable;
 
-  return gdk_region_copy (private->clip_region);
+  return cairo_region_copy (private->clip_region);
 }
 
 static void
@@ -4249,23 +4266,23 @@ gdk_window_draw_drawable (GdkDrawable *drawable,
 	  r.y = ydest;
 	  r.width = width;
 	  r.height = height;
-	  exposure_region = gdk_region_rectangle (&r);
+	  exposure_region = cairo_region_create_rectangle (&r);
 
 	  if (_gdk_gc_get_subwindow (gc) == GDK_CLIP_BY_CHILDREN)
 	    clip = private->clip_region_with_children;
 	  else
 	    clip = private->clip_region;
-	  gdk_region_intersect (exposure_region, clip);
+	  cairo_region_intersect (exposure_region, clip);
 
 	  _gdk_gc_remove_drawable_clip (gc);
 	  clip = _gdk_gc_get_clip_region (gc);
 	  if (clip)
 	    {
-	      gdk_region_offset (exposure_region,
+	      cairo_region_translate (exposure_region,
 				 old_clip_x,
 				 old_clip_y);
-	      gdk_region_intersect (exposure_region, clip);
-	      gdk_region_offset (exposure_region,
+	      cairo_region_intersect (exposure_region, clip);
+	      cairo_region_translate (exposure_region,
 				 -old_clip_x,
 				 -old_clip_y);
 	    }
@@ -4277,18 +4294,18 @@ gdk_window_draw_drawable (GdkDrawable *drawable,
 	   * Note that xsrc/ysrc has been corrected for abs_x/y offsets already,
 	   * which need to be undone */
 	  clip = gdk_drawable_get_visible_region (original_src);
-	  gdk_region_offset (clip,
+	  cairo_region_translate (clip,
 			     xdest - (xsrc - GDK_WINDOW_OBJECT (original_src)->abs_x),
 			     ydest - (ysrc - GDK_WINDOW_OBJECT (original_src)->abs_y));
-	  gdk_region_subtract (exposure_region, clip);
-	  gdk_region_destroy (clip);
+	  cairo_region_subtract (exposure_region, clip);
+	  cairo_region_destroy (clip);
 
 	  gdk_window_invalidate_region_full (GDK_WINDOW (private),
 					      exposure_region,
 					      _gdk_gc_get_subwindow (gc) == GDK_INCLUDE_INFERIORS,
 					      CLEAR_BG_ALL);
 
-	  gdk_region_destroy (exposure_region);
+	  cairo_region_destroy (exposure_region);
 	}
     }
 
@@ -4573,9 +4590,9 @@ gdk_window_clear_backing_region (GdkWindow *window,
   method.gc = NULL;
   setup_backing_rect_method (&method, window, paint, 0, 0);
 
-  clip = gdk_region_copy (paint->region);
-  gdk_region_intersect (clip, region);
-  gdk_region_get_clipbox (clip, &clipbox);
+  clip = cairo_region_copy (paint->region);
+  cairo_region_intersect (clip, region);
+  cairo_region_get_extents (clip, &clipbox);
 
 
   if (method.cr)
@@ -4607,7 +4624,7 @@ gdk_window_clear_backing_region (GdkWindow *window,
 #endif
     }
 
-  gdk_region_destroy (clip);
+  cairo_region_destroy (clip);
 
 #if 0
   g_timer_destroy (timer);
@@ -4633,7 +4650,7 @@ gdk_window_clear_backing_region_redirect (GdkWindow *window,
 							GDK_WINDOW (redirect->redirected),
 							TRUE,
 							&x_offset, &y_offset);
-  gdk_region_intersect (clip_region, region);
+  cairo_region_intersect (clip_region, region);
 
   /* offset is from redirected window origin to window origin, convert to
      the offset from the redirected pixmap origin to the window origin */
@@ -4641,7 +4658,7 @@ gdk_window_clear_backing_region_redirect (GdkWindow *window,
   y_offset += redirect->dest_y - redirect->src_y;
 
   /* Convert region to pixmap coords */
-  gdk_region_offset (clip_region, x_offset, y_offset);
+  cairo_region_translate (clip_region, x_offset, y_offset);
 
   paint.x_offset = 0;
   paint.y_offset = 0;
@@ -4665,7 +4682,7 @@ gdk_window_clear_backing_region_redirect (GdkWindow *window,
     {
       g_assert (method.gc != NULL);
 
-      gdk_region_get_clipbox (clip_region, &clipbox);
+      cairo_region_get_extents (clip_region, &clipbox);
       gdk_gc_set_clip_region (method.gc, clip_region);
       gdk_draw_rectangle (redirect->pixmap, method.gc, TRUE,
 			  clipbox.x, clipbox.y,
@@ -4674,7 +4691,7 @@ gdk_window_clear_backing_region_redirect (GdkWindow *window,
 
     }
 
-  gdk_region_destroy (clip_region);
+  cairo_region_destroy (clip_region);
   cairo_surface_destroy (paint.surface);
 }
 
@@ -4700,9 +4717,9 @@ gdk_window_clear_backing_region_direct (GdkWindow *window,
   method.gc = NULL;
   setup_backing_rect_method (&method, window, &paint, 0, 0);
 
-  clip = gdk_region_copy (private->clip_region_with_children);
-  gdk_region_intersect (clip, region);
-  gdk_region_get_clipbox (clip, &clipbox);
+  clip = cairo_region_copy (private->clip_region_with_children);
+  cairo_region_intersect (clip, region);
+  cairo_region_get_extents (clip, &clipbox);
 
   if (method.cr)
     {
@@ -4725,7 +4742,7 @@ gdk_window_clear_backing_region_direct (GdkWindow *window,
 
     }
 
-  gdk_region_destroy (clip);
+  cairo_region_destroy (clip);
   cairo_surface_destroy (paint.surface);
 }
 
@@ -4791,8 +4808,8 @@ gdk_window_clear_region_internal (GdkWindow *window,
       if (impl_iface->clear_region && clears_as_native (private))
 	{
 	  GdkRegion *copy;
-	  copy = gdk_region_copy (region);
-	  gdk_region_intersect (copy,
+	  copy = cairo_region_copy (region);
+	  cairo_region_intersect (copy,
 				private->clip_region_with_children);
 
 
@@ -4801,7 +4818,7 @@ gdk_window_clear_region_internal (GdkWindow *window,
 	  gdk_window_flush (window);
 	  impl_iface->clear_region (window, copy, send_expose);
 
-	  gdk_region_destroy (copy);
+	  cairo_region_destroy (copy);
 	}
       else
 	{
@@ -4838,11 +4855,11 @@ gdk_window_clear_area_internal (GdkWindow *window,
   rect.width = width;
   rect.height = height;
 
-  region = gdk_region_rectangle (&rect);
+  region = cairo_region_create_rectangle (&rect);
   gdk_window_clear_region_internal (window,
 				    region,
 				    send_expose);
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
 
 }
 
@@ -5372,7 +5389,7 @@ _gdk_window_process_updates_recurse (GdkWindow *window,
   GdkRectangle r;
   GList *l, *children;
 
-  if (gdk_region_empty (expose_region))
+  if (cairo_region_is_empty (expose_region))
     return;
 
   /* Make this reentrancy safe for expose handlers freeing windows */
@@ -5397,35 +5414,35 @@ _gdk_window_process_updates_recurse (GdkWindow *window,
       r.width = child->width;
       r.height = child->height;
 
-      child_region = gdk_region_rectangle (&r);
+      child_region = cairo_region_create_rectangle (&r);
       if (child->shape)
 	{
 	  /* Adjust shape region to parent window coords */
-	  gdk_region_offset (child->shape, child->x, child->y);
-	  gdk_region_intersect (child_region, child->shape);
-	  gdk_region_offset (child->shape, -child->x, -child->y);
+	  cairo_region_translate (child->shape, child->x, child->y);
+	  cairo_region_intersect (child_region, child->shape);
+	  cairo_region_translate (child->shape, -child->x, -child->y);
 	}
 
       if (child->impl == private->impl)
 	{
 	  /* Client side child, expose */
-	  gdk_region_intersect (child_region, expose_region);
-	  gdk_region_subtract (expose_region, child_region);
-	  gdk_region_offset (child_region, -child->x, -child->y);
+	  cairo_region_intersect (child_region, expose_region);
+	  cairo_region_subtract (expose_region, child_region);
+	  cairo_region_translate (child_region, -child->x, -child->y);
 	  _gdk_window_process_updates_recurse ((GdkWindow *)child, child_region);
 	}
       else
 	{
 	  /* Native child, just remove area from expose region */
-	  gdk_region_subtract (expose_region, child_region);
+	  cairo_region_subtract (expose_region, child_region);
 	}
-      gdk_region_destroy (child_region);
+      cairo_region_destroy (child_region);
     }
 
   g_list_foreach (children, (GFunc)g_object_unref, NULL);
   g_list_free (children);
 
-  if (!gdk_region_empty (expose_region) &&
+  if (!cairo_region_is_empty (expose_region) &&
       !private->destroyed)
     {
       if (private->event_mask & GDK_EXPOSURE_MASK)
@@ -5437,7 +5454,7 @@ _gdk_window_process_updates_recurse (GdkWindow *window,
 	  event.expose.send_event = FALSE;
 	  event.expose.count = 0;
 	  event.expose.region = expose_region;
-	  gdk_region_get_clipbox (expose_region, &event.expose.area);
+	  cairo_region_get_extents (expose_region, &event.expose.area);
 
 	  (*_gdk_event_func) (&event, _gdk_event_data);
 
@@ -5497,7 +5514,7 @@ gdk_window_process_updates_internal (GdkWindow *window)
 	  gboolean end_implicit;
 
 	  /* Clip to part visible in toplevel */
-	  gdk_region_intersect (update_area, private->clip_region);
+	  cairo_region_intersect (update_area, private->clip_region);
 
 	  if (debug_updates)
 	    {
@@ -5518,7 +5535,7 @@ gdk_window_process_updates_internal (GdkWindow *window)
 	      GdkRegion *remove;
 	      GList *l, *prev;
 
-	      remove = gdk_region_copy (update_area);
+	      remove = cairo_region_copy (update_area);
 	      /* We iterate backwards, starting from the state that would be
 		 if we had applied all the moves. */
 	      for (l = g_list_last (private->outstanding_moves); l != NULL; l = prev)
@@ -5527,24 +5544,24 @@ gdk_window_process_updates_internal (GdkWindow *window)
 		  move = l->data;
 
 		  /* Don't need this area */
-		  gdk_region_subtract (move->dest_region, remove);
+		  cairo_region_subtract (move->dest_region, remove);
 
 		  /* However if any of the destination we do need has a source
 		     in the updated region we do need that as a destination for
 		     the earlier moves */
-		  gdk_region_offset (move->dest_region, -move->dx, -move->dy);
-		  gdk_region_subtract (remove, move->dest_region);
+		  cairo_region_translate (move->dest_region, -move->dx, -move->dy);
+		  cairo_region_subtract (remove, move->dest_region);
 
-		  if (gdk_region_empty (move->dest_region))
+		  if (cairo_region_is_empty (move->dest_region))
 		    {
 		      gdk_window_region_move_free (move);
 		      private->outstanding_moves =
 			g_list_delete_link (private->outstanding_moves, l);
 		    }
 		  else /* move back */
-		    gdk_region_offset (move->dest_region, move->dx, move->dy);
+		    cairo_region_translate (move->dest_region, move->dx, move->dy);
 		}
-	      gdk_region_destroy (remove);
+	      cairo_region_destroy (remove);
 	    }
 
 	  /* By now we a set of window moves that should be applied, and then
@@ -5583,9 +5600,9 @@ gdk_window_process_updates_internal (GdkWindow *window)
 	   * avoid doing the unnecessary repaint any outstanding expose events.
 	   */
 
-	  gdk_region_get_clipbox (update_area, &clip_box);
+	  cairo_region_get_extents (update_area, &clip_box);
 	  end_implicit = gdk_window_begin_implicit_paint (window, &clip_box);
-	  expose_region = gdk_region_copy (update_area);
+	  expose_region = cairo_region_copy (update_area);
 	  if (!end_implicit)
 	    {
 	      /* Rendering is not double buffered by gdk, do outstanding
@@ -5621,10 +5638,10 @@ gdk_window_process_updates_internal (GdkWindow *window)
 
 	      gdk_window_end_implicit_paint (window);
 	    }
-	  gdk_region_destroy (expose_region);
+	  cairo_region_destroy (expose_region);
 	}
       if (!save_region)
-	gdk_region_destroy (update_area);
+	cairo_region_destroy (update_area);
     }
 
   if (private->outstanding_moves)
@@ -5826,9 +5843,9 @@ gdk_window_invalidate_rect_full (GdkWindow          *window,
       rect = &window_rect;
     }
 
-  region = gdk_region_rectangle (rect);
+  region = cairo_region_create_rectangle (rect);
   gdk_window_invalidate_region_full (window, region, invalidate_children, clear_bg);
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
 }
 
 /**
@@ -5863,7 +5880,7 @@ draw_ugly_color (GdkWindow       *window,
   gdk_gc_set_rgb_fg_color (ugly_gc, &ugly_color);
   gdk_gc_set_clip_region (ugly_gc, region);
 
-  gdk_region_get_clipbox (region, &clipbox);
+  cairo_region_get_extents (region, &clipbox);
 
   gdk_draw_rectangle (window,
 		      ugly_gc,
@@ -5879,11 +5896,11 @@ impl_window_add_update_area (GdkWindowObject *impl_window,
 			     GdkRegion *region)
 {
   if (impl_window->update_area)
-    gdk_region_union (impl_window->update_area, region);
+    cairo_region_union (impl_window->update_area, region);
   else
     {
       gdk_window_add_update_window ((GdkWindow *)impl_window);
-      impl_window->update_area = gdk_region_copy (region);
+      impl_window->update_area = cairo_region_copy (region);
       gdk_window_schedule_update ((GdkWindow *)impl_window);
     }
 }
@@ -5918,12 +5935,12 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow       *window,
 
   if (private->input_only ||
       !private->viewable ||
-      gdk_region_empty (region) ||
+      cairo_region_is_empty (region) ||
       private->window_type == GDK_WINDOW_ROOT)
     return;
 
   visible_region = gdk_drawable_get_visible_region (window);
-  gdk_region_intersect (visible_region, region);
+  cairo_region_intersect (visible_region, region);
 
   tmp_list = private->children;
   while (tmp_list)
@@ -5939,29 +5956,29 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow       *window,
 	  child_rect.y = child->y;
 	  child_rect.width = child->width;
 	  child_rect.height = child->height;
-	  child_region = gdk_region_rectangle (&child_rect);
+	  child_region = cairo_region_create_rectangle (&child_rect);
 
 	  /* remove child area from the invalid area of the parent */
 	  if (GDK_WINDOW_IS_MAPPED (child) && !child->shaped &&
 	      !child->composited &&
 	      !gdk_window_is_offscreen (child))
-	    gdk_region_subtract (visible_region, child_region);
+	    cairo_region_subtract (visible_region, child_region);
 
 	  if (child_func && (*child_func) ((GdkWindow *)child, user_data))
 	    {
-	      GdkRegion *tmp = gdk_region_copy (region);
+	      GdkRegion *tmp = cairo_region_copy (region);
 
-	      gdk_region_offset (tmp, - child_rect.x, - child_rect.y);
-	      gdk_region_offset (child_region, - child_rect.x, - child_rect.y);
-	      gdk_region_intersect (child_region, tmp);
+	      cairo_region_translate (tmp, - child_rect.x, - child_rect.y);
+	      cairo_region_translate (child_region, - child_rect.x, - child_rect.y);
+	      cairo_region_intersect (child_region, tmp);
 
 	      gdk_window_invalidate_maybe_recurse_full ((GdkWindow *)child,
 							child_region, clear_bg, child_func, user_data);
 
-	      gdk_region_destroy (tmp);
+	      cairo_region_destroy (tmp);
 	    }
 
-	  gdk_region_destroy (child_region);
+	  cairo_region_destroy (child_region);
 	}
 
       tmp_list = tmp_list->next;
@@ -5969,7 +5986,7 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow       *window,
 
   impl_window = gdk_window_get_impl_window (private);
 
-  if (!gdk_region_empty (visible_region)  ||
+  if (!cairo_region_is_empty (visible_region)  ||
       /* Even if we're not exposing anything, make sure we process
 	 idles for windows with outstanding moves */
       (impl_window->outstanding_moves != NULL &&
@@ -5979,7 +5996,7 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow       *window,
 	draw_ugly_color (window, region);
 
       /* Convert to impl coords */
-      gdk_region_offset (visible_region, private->abs_x, private->abs_y);
+      cairo_region_translate (visible_region, private->abs_x, private->abs_y);
 
       /* Only invalidate area if app requested expose events or if
 	 we need to clear the area (by request or to emulate background
@@ -5993,7 +6010,7 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow       *window,
 	impl_window_add_update_area (impl_window, visible_region);
     }
 
-  gdk_region_destroy (visible_region);
+  cairo_region_destroy (visible_region);
 }
 
 /**
@@ -6128,17 +6145,17 @@ _gdk_window_invalidate_for_expose (GdkWindow       *window,
       move = l->data;
 
       /* covert to move source region */
-      move_region = gdk_region_copy (move->dest_region);
-      gdk_region_offset (move_region, -move->dx, -move->dy);
+      move_region = cairo_region_copy (move->dest_region);
+      cairo_region_translate (move_region, -move->dx, -move->dy);
 
       /* Move area of region that intersects with move source
 	 by dx, dy of the move*/
-      gdk_region_intersect (move_region, region);
-      gdk_region_subtract (region, move_region);
-      gdk_region_offset (move_region, move->dx, move->dy);
-      gdk_region_union (region, move_region);
+      cairo_region_intersect (move_region, region);
+      cairo_region_subtract (region, move_region);
+      cairo_region_translate (move_region, move->dx, move->dy);
+      cairo_region_union (region, move_region);
 
-      gdk_region_destroy (move_region);
+      cairo_region_destroy (move_region);
     }
 
   gdk_window_invalidate_maybe_recurse_full (window, region, CLEAR_BG_WINCLEARED,
@@ -6156,7 +6173,7 @@ _gdk_window_invalidate_for_expose (GdkWindow       *window,
  * no longer have an invalid/dirty region; the update area is removed
  * from @window and handed to you. If a window has no update area,
  * gdk_window_get_update_area() returns %NULL. You are responsible for
- * calling gdk_region_destroy() on the returned region if it's non-%NULL.
+ * calling cairo_region_destroy() on the returned region if it's non-%NULL.
  *
  * Return value: the update area for @window
  **/
@@ -6173,31 +6190,31 @@ gdk_window_get_update_area (GdkWindow *window)
 
   if (impl_window->update_area)
     {
-      tmp_region = gdk_region_copy (private->clip_region_with_children);
+      tmp_region = cairo_region_copy (private->clip_region_with_children);
       /* Convert to impl coords */
-      gdk_region_offset (tmp_region, private->abs_x, private->abs_y);
-      gdk_region_intersect (tmp_region, impl_window->update_area);
+      cairo_region_translate (tmp_region, private->abs_x, private->abs_y);
+      cairo_region_intersect (tmp_region, impl_window->update_area);
 
-      if (gdk_region_empty (tmp_region))
+      if (cairo_region_is_empty (tmp_region))
 	{
-	  gdk_region_destroy (tmp_region);
+	  cairo_region_destroy (tmp_region);
 	  return NULL;
 	}
       else
 	{
-	  gdk_region_subtract (impl_window->update_area, tmp_region);
+	  cairo_region_subtract (impl_window->update_area, tmp_region);
 
-	  if (gdk_region_empty (impl_window->update_area) &&
+	  if (cairo_region_is_empty (impl_window->update_area) &&
 	      impl_window->outstanding_moves == NULL)
 	    {
-	      gdk_region_destroy (impl_window->update_area);
+	      cairo_region_destroy (impl_window->update_area);
 	      impl_window->update_area = NULL;
 
 	      gdk_window_remove_update_window ((GdkWindow *)impl_window);
 	    }
 
 	  /* Convert from impl coords */
-	  gdk_region_offset (tmp_region, -private->abs_x, -private->abs_y);
+	  cairo_region_translate (tmp_region, -private->abs_x, -private->abs_y);
 	  return tmp_region;
 
 	}
@@ -6224,7 +6241,7 @@ _gdk_window_clear_update_area (GdkWindow *window)
     {
       gdk_window_remove_update_window (window);
 
-      gdk_region_destroy (private->update_area);
+      cairo_region_destroy (private->update_area);
       private->update_area = NULL;
     }
 }
@@ -6916,7 +6933,7 @@ gdk_window_raise (GdkWindow *window)
   old_region = NULL;
   if (gdk_window_is_viewable (window) &&
       !private->input_only)
-    old_region = gdk_region_copy (private->clip_region);
+    old_region = cairo_region_copy (private->clip_region);
 
   /* Keep children in (reverse) stacking order */
   gdk_window_raise_internal (window);
@@ -6925,13 +6942,13 @@ gdk_window_raise (GdkWindow *window)
 
   if (old_region)
     {
-      new_region = gdk_region_copy (private->clip_region);
+      new_region = cairo_region_copy (private->clip_region);
 
-      gdk_region_subtract (new_region, old_region);
+      cairo_region_subtract (new_region, old_region);
       gdk_window_invalidate_region_full (window, new_region, TRUE, CLEAR_BG_ALL);
 
-      gdk_region_destroy (old_region);
-      gdk_region_destroy (new_region);
+      cairo_region_destroy (old_region);
+      cairo_region_destroy (new_region);
     }
 }
 
@@ -7546,7 +7563,7 @@ gdk_window_move_resize_toplevel (GdkWindow *window,
       !private->input_only)
     {
       expose = TRUE;
-      old_region = gdk_region_copy (private->clip_region);
+      old_region = cairo_region_copy (private->clip_region);
     }
 
   impl_iface = GDK_WINDOW_IMPL_GET_IFACE (private->impl);
@@ -7564,17 +7581,17 @@ gdk_window_move_resize_toplevel (GdkWindow *window,
 
   if (expose)
     {
-      new_region = gdk_region_copy (private->clip_region);
+      new_region = cairo_region_copy (private->clip_region);
 
       /* This is the newly exposed area (due to any resize),
        * X will expose it, but lets do that without the
        * roundtrip
        */
-      gdk_region_subtract (new_region, old_region);
+      cairo_region_subtract (new_region, old_region);
       gdk_window_invalidate_region_full (window, new_region, TRUE, CLEAR_BG_WINCLEARED);
 
-      gdk_region_destroy (old_region);
-      gdk_region_destroy (new_region);
+      cairo_region_destroy (old_region);
+      cairo_region_destroy (new_region);
     }
 
   _gdk_synthesize_crossing_events_for_geometry_change (window);
@@ -7624,16 +7641,16 @@ collect_native_child_region_helper (GdkWindowObject *window,
 
       if (child->impl != impl)
 	{
-	  tmp = gdk_region_copy (child->clip_region);
-	  gdk_region_offset (tmp,
+	  tmp = cairo_region_copy (child->clip_region);
+	  cairo_region_translate (tmp,
 			     x_offset + child->x,
 			     y_offset + child->y);
 	  if (*region == NULL)
 	    *region = tmp;
 	  else
 	    {
-	      gdk_region_union (*region, tmp);
-	      gdk_region_destroy (tmp);
+	      cairo_region_union (*region, tmp);
+	      cairo_region_destroy (tmp);
 	    }
 	}
       else
@@ -7652,7 +7669,7 @@ collect_native_child_region (GdkWindowObject *window,
   GdkRegion *region;
 
   if (include_this && gdk_window_has_impl (window) && window->viewable)
-    return gdk_region_copy (window->clip_region);
+    return cairo_region_copy (window->clip_region);
 
   region = NULL;
 
@@ -7717,15 +7734,15 @@ gdk_window_move_resize_internal (GdkWindow *window,
     {
       expose = TRUE;
 
-      old_region = gdk_region_copy (private->clip_region);
+      old_region = cairo_region_copy (private->clip_region);
       /* Adjust region to parent window coords */
-      gdk_region_offset (old_region, private->x, private->y);
+      cairo_region_translate (old_region, private->x, private->y);
 
       old_native_child_region = collect_native_child_region (private, TRUE);
       if (old_native_child_region)
 	{
 	  /* Adjust region to parent window coords */
-	  gdk_region_offset (old_native_child_region, private->x, private->y);
+	  cairo_region_translate (old_native_child_region, private->x, private->y);
 
 	  /* Any native window move will immediately copy stuff to the destination, which may overwrite a
 	   * source or destination for a delayed GdkWindowRegionMove. So, we need
@@ -7766,7 +7783,7 @@ gdk_window_move_resize_internal (GdkWindow *window,
     {
       new_native_child_region = collect_native_child_region (private, TRUE);
       /* Adjust region to parent window coords */
-      gdk_region_offset (new_native_child_region, private->x, private->y);
+      cairo_region_translate (new_native_child_region, private->x, private->y);
     }
 
   if (gdk_window_has_impl (private))
@@ -7785,9 +7802,9 @@ gdk_window_move_resize_internal (GdkWindow *window,
 
   if (expose)
     {
-      new_region = gdk_region_copy (private->clip_region);
+      new_region = cairo_region_copy (private->clip_region);
       /* Adjust region to parent window coords */
-      gdk_region_offset (new_region, private->x, private->y);
+      cairo_region_translate (new_region, private->x, private->y);
 
       /* copy_area:
        * Part of the data at the new location can be copied from the
@@ -7799,37 +7816,37 @@ gdk_window_move_resize_internal (GdkWindow *window,
        * Everything in the old and new regions that is not copied must be
        * invalidated (including children) as this is newly exposed
        */
-      copy_area = gdk_region_copy (new_region);
+      copy_area = cairo_region_copy (new_region);
 
-      gdk_region_union (new_region, old_region);
+      cairo_region_union (new_region, old_region);
 
       if (old_native_child_region)
 	{
 	  /* Don't copy from inside native children, as this is copied by
 	   * the native window move.
 	   */
-	  gdk_region_subtract (old_region, old_native_child_region);
+	  cairo_region_subtract (old_region, old_native_child_region);
 	}
-      gdk_region_offset (old_region, dx, dy);
+      cairo_region_translate (old_region, dx, dy);
 
-      gdk_region_intersect (copy_area, old_region);
+      cairo_region_intersect (copy_area, old_region);
 
       if (new_native_child_region)
 	{
 	  /* Don't copy any bits that would cause a read from the moved
 	     native windows, as we can't read that data */
-	  gdk_region_offset (new_native_child_region, dx, dy);
-	  gdk_region_subtract (copy_area, new_native_child_region);
-	  gdk_region_offset (new_native_child_region, -dx, -dy);
+	  cairo_region_translate (new_native_child_region, dx, dy);
+	  cairo_region_subtract (copy_area, new_native_child_region);
+	  cairo_region_translate (new_native_child_region, -dx, -dy);
 	}
 
-      gdk_region_subtract (new_region, copy_area);
+      cairo_region_subtract (new_region, copy_area);
 
       /* Convert old region to impl coords */
-      gdk_region_offset (old_region, -dx + private->abs_x - private->x, -dy + private->abs_y - private->y);
+      cairo_region_translate (old_region, -dx + private->abs_x - private->x, -dy + private->abs_y - private->y);
 
       /* convert from parent coords to impl */
-      gdk_region_offset (copy_area, private->abs_x - private->x, private->abs_y - private->y);
+      cairo_region_translate (copy_area, private->abs_x - private->x, private->abs_y - private->y);
 
       move_region_on_impl (impl_window, copy_area, dx, dy); /* takes ownership of copy_area */
 
@@ -7841,20 +7858,20 @@ gdk_window_move_resize_internal (GdkWindow *window,
       if (old_native_child_region)
 	{
 	  /* No need to expose the region that the native window move copies */
-	  gdk_region_offset (old_native_child_region, dx, dy);
-	  gdk_region_intersect (old_native_child_region, new_native_child_region);
-	  gdk_region_subtract (new_region, old_native_child_region);
+	  cairo_region_translate (old_native_child_region, dx, dy);
+	  cairo_region_intersect (old_native_child_region, new_native_child_region);
+	  cairo_region_subtract (new_region, old_native_child_region);
 	}
       gdk_window_invalidate_region_full (GDK_WINDOW (private->parent), new_region, TRUE, CLEAR_BG_ALL);
 
-      gdk_region_destroy (old_region);
-      gdk_region_destroy (new_region);
+      cairo_region_destroy (old_region);
+      cairo_region_destroy (new_region);
     }
 
   if (old_native_child_region)
     {
-      gdk_region_destroy (old_native_child_region);
-      gdk_region_destroy (new_native_child_region);
+      cairo_region_destroy (old_native_child_region);
+      cairo_region_destroy (new_native_child_region);
     }
 
   _gdk_synthesize_crossing_events_for_geometry_change (window);
@@ -8013,27 +8030,27 @@ gdk_window_scroll (GdkWindow *window,
   impl_window = gdk_window_get_impl_window (private);
 
   /* Calculate the area that can be gotten by copying the old area */
-  copy_area = gdk_region_copy (private->clip_region);
+  copy_area = cairo_region_copy (private->clip_region);
   if (old_native_child_region)
     {
       /* Don't copy from inside native children, as this is copied by
        * the native window move.
        */
-      gdk_region_subtract (copy_area, old_native_child_region);
+      cairo_region_subtract (copy_area, old_native_child_region);
 
       /* Don't copy any bits that would cause a read from the moved
 	 native windows, as we can't read that data */
-      gdk_region_subtract (copy_area, new_native_child_region);
+      cairo_region_subtract (copy_area, new_native_child_region);
     }
-  gdk_region_offset (copy_area, dx, dy);
-  gdk_region_intersect (copy_area, private->clip_region);
+  cairo_region_translate (copy_area, dx, dy);
+  cairo_region_intersect (copy_area, private->clip_region);
 
   /* And the rest need to be invalidated */
-  noncopy_area = gdk_region_copy (private->clip_region);
-  gdk_region_subtract (noncopy_area, copy_area);
+  noncopy_area = cairo_region_copy (private->clip_region);
+  cairo_region_subtract (noncopy_area, copy_area);
 
   /* convert from window coords to impl */
-  gdk_region_offset (copy_area, private->abs_x, private->abs_y);
+  cairo_region_translate (copy_area, private->abs_x, private->abs_y);
 
   move_region_on_impl (impl_window, copy_area, dx, dy); /* takes ownership of copy_area */
 
@@ -8041,18 +8058,18 @@ gdk_window_scroll (GdkWindow *window,
   if (old_native_child_region)
     {
       /* No need to expose the region that the native window move copies */
-      gdk_region_offset (old_native_child_region, dx, dy);
-      gdk_region_intersect (old_native_child_region, new_native_child_region);
-      gdk_region_subtract (noncopy_area, old_native_child_region);
+      cairo_region_translate (old_native_child_region, dx, dy);
+      cairo_region_intersect (old_native_child_region, new_native_child_region);
+      cairo_region_subtract (noncopy_area, old_native_child_region);
     }
   gdk_window_invalidate_region_full (window, noncopy_area, TRUE, CLEAR_BG_ALL);
 
-  gdk_region_destroy (noncopy_area);
+  cairo_region_destroy (noncopy_area);
 
   if (old_native_child_region)
     {
-      gdk_region_destroy (old_native_child_region);
-      gdk_region_destroy (new_native_child_region);
+      cairo_region_destroy (old_native_child_region);
+      cairo_region_destroy (new_native_child_region);
     }
 
   _gdk_synthesize_crossing_events_for_geometry_change (window);
@@ -8096,26 +8113,26 @@ gdk_window_move_region (GdkWindow       *window,
   impl_window = gdk_window_get_impl_window (private);
 
   /* compute source regions */
-  copy_area = gdk_region_copy (region);
-  gdk_region_intersect (copy_area, private->clip_region_with_children);
+  copy_area = cairo_region_copy (region);
+  cairo_region_intersect (copy_area, private->clip_region_with_children);
 
   /* compute destination regions */
-  gdk_region_offset (copy_area, dx, dy);
-  gdk_region_intersect (copy_area, private->clip_region_with_children);
+  cairo_region_translate (copy_area, dx, dy);
+  cairo_region_intersect (copy_area, private->clip_region_with_children);
 
   /* Invalidate parts of the region (source and dest) not covered
      by the copy */
-  nocopy_area = gdk_region_copy (region);
-  gdk_region_offset (nocopy_area, dx, dy);
-  gdk_region_union (nocopy_area, region);
-  gdk_region_subtract (nocopy_area, copy_area);
+  nocopy_area = cairo_region_copy (region);
+  cairo_region_translate (nocopy_area, dx, dy);
+  cairo_region_union (nocopy_area, region);
+  cairo_region_subtract (nocopy_area, copy_area);
 
   /* convert from window coords to impl */
-  gdk_region_offset (copy_area, private->abs_x, private->abs_y);
+  cairo_region_translate (copy_area, private->abs_x, private->abs_y);
   move_region_on_impl (impl_window, copy_area, dx, dy); /* Takes ownership of copy_area */
 
   gdk_window_invalidate_region_full (window, nocopy_area, FALSE, CLEAR_BG_ALL);
-  gdk_region_destroy (nocopy_area);
+  cairo_region_destroy (nocopy_area);
 }
 
 /**
@@ -8846,7 +8863,7 @@ gdk_window_shape_combine_mask (GdkWindow *window,
 				   x, y);
 
   if (region)
-    gdk_region_destroy (region);
+    cairo_region_destroy (region);
 }
 
 /**
@@ -8891,16 +8908,16 @@ gdk_window_shape_combine_region (GdkWindow       *window,
   private->shaped = (shape_region != NULL);
 
   if (private->shape)
-    gdk_region_destroy (private->shape);
+    cairo_region_destroy (private->shape);
 
   old_region = NULL;
   if (GDK_WINDOW_IS_MAPPED (window))
-    old_region = gdk_region_copy (private->clip_region);
+    old_region = cairo_region_copy (private->clip_region);
 
   if (shape_region)
     {
-      private->shape = gdk_region_copy (shape_region);
-      gdk_region_offset (private->shape, offset_x, offset_y);
+      private->shape = cairo_region_copy (shape_region);
+      cairo_region_translate (private->shape, offset_x, offset_y);
     }
   else
     private->shape = NULL;
@@ -8913,32 +8930,32 @@ gdk_window_shape_combine_region (GdkWindow       *window,
 
   if (old_region)
     {
-      new_region = gdk_region_copy (private->clip_region);
+      new_region = cairo_region_copy (private->clip_region);
 
       /* New area in the window, needs invalidation */
-      diff = gdk_region_copy (new_region);
-      gdk_region_subtract (diff, old_region);
+      diff = cairo_region_copy (new_region);
+      cairo_region_subtract (diff, old_region);
 
       gdk_window_invalidate_region_full (window, diff, TRUE, CLEAR_BG_ALL);
 
-      gdk_region_destroy (diff);
+      cairo_region_destroy (diff);
 
       if (!gdk_window_is_toplevel (private))
 	{
 	  /* New area in the non-root parent window, needs invalidation */
-	  diff = gdk_region_copy (old_region);
-	  gdk_region_subtract (diff, new_region);
+	  diff = cairo_region_copy (old_region);
+	  cairo_region_subtract (diff, new_region);
 
 	  /* Adjust region to parent window coords */
-	  gdk_region_offset (diff, private->x, private->y);
+	  cairo_region_translate (diff, private->x, private->y);
 
 	  gdk_window_invalidate_region_full (GDK_WINDOW (private->parent), diff, TRUE, CLEAR_BG_ALL);
 
-	  gdk_region_destroy (diff);
+	  cairo_region_destroy (diff);
 	}
 
-      gdk_region_destroy (new_region);
-      gdk_region_destroy (old_region);
+      cairo_region_destroy (new_region);
+      cairo_region_destroy (old_region);
     }
 }
 
@@ -8957,11 +8974,11 @@ do_child_shapes (GdkWindow *window,
   r.width = private->width;
   r.height = private->height;
 
-  region = gdk_region_rectangle (&r);
+  region = cairo_region_create_rectangle (&r);
   remove_child_area (private, NULL, FALSE, region);
 
   if (merge && private->shape)
-    gdk_region_subtract (region, private->shape);
+    cairo_region_subtract (region, private->shape);
 
   gdk_window_shape_combine_region (window, region, 0, 0);
 }
@@ -9053,7 +9070,7 @@ gdk_window_input_shape_combine_mask (GdkWindow *window,
 					 x, y);
 
   if (region != NULL)
-    gdk_region_destroy (region);
+    cairo_region_destroy (region);
 }
 
 /**
@@ -9099,12 +9116,12 @@ gdk_window_input_shape_combine_region (GdkWindow       *window,
     return;
 
   if (private->input_shape)
-    gdk_region_destroy (private->input_shape);
+    cairo_region_destroy (private->input_shape);
 
   if (shape_region)
     {
-      private->input_shape = gdk_region_copy (shape_region);
-      gdk_region_offset (private->input_shape, offset_x, offset_y);
+      private->input_shape = cairo_region_copy (shape_region);
+      cairo_region_translate (private->input_shape, offset_x, offset_y);
     }
   else
     private->input_shape = NULL;
@@ -9134,13 +9151,13 @@ do_child_input_shapes (GdkWindow *window,
   r.width = private->width;
   r.height = private->height;
 
-  region = gdk_region_rectangle (&r);
+  region = cairo_region_create_rectangle (&r);
   remove_child_area (private, NULL, TRUE, region);
 
   if (merge && private->shape)
-    gdk_region_subtract (region, private->shape);
+    cairo_region_subtract (region, private->shape);
   if (merge && private->input_shape)
-    gdk_region_subtract (region, private->input_shape);
+    cairo_region_subtract (region, private->input_shape);
 
   gdk_window_input_shape_combine_region (window, region, 0, 0);
 }
@@ -9596,12 +9613,12 @@ _gdk_window_calculate_full_clip_region (GdkWindow *window,
     *base_y_offset = 0;
 
   if (!private->viewable || private->input_only)
-    return gdk_region_new ();
+    return cairo_region_create ();
 
   window_get_size_rectangle (window, &visible_rect);
 
   /* real_clip_region is in window coordinates */
-  real_clip_region = gdk_region_rectangle (&visible_rect);
+  real_clip_region = cairo_region_create_rectangle (&visible_rect);
 
   x_offset = y_offset = 0;
 
@@ -9648,16 +9665,16 @@ _gdk_window_calculate_full_clip_region (GdkWindow *window,
 	  visible_rect.y += child_private->y - y_offset;
 
 	  /* This shortcut is really necessary for performance when there are a lot of windows */
-	  gdk_region_get_clipbox (real_clip_region, &real_clip_rect);
+	  cairo_region_get_extents (real_clip_region, &real_clip_rect);
 	  if (visible_rect.x >= real_clip_rect.x + real_clip_rect.width ||
 	      visible_rect.x + visible_rect.width <= real_clip_rect.x ||
 	      visible_rect.y >= real_clip_rect.y + real_clip_rect.height ||
 	      visible_rect.y + visible_rect.height <= real_clip_rect.y)
 	    continue;
 
-	  tmpreg = gdk_region_rectangle (&visible_rect);
-	  gdk_region_subtract (real_clip_region, tmpreg);
-	  gdk_region_destroy (tmpreg);
+	  tmpreg = cairo_region_create_rectangle (&visible_rect);
+	  cairo_region_subtract (real_clip_region, tmpreg);
+	  cairo_region_destroy (tmpreg);
 	}
 
       /* Clip to the parent */
@@ -9666,9 +9683,9 @@ _gdk_window_calculate_full_clip_region (GdkWindow *window,
       visible_rect.x += - x_offset;
       visible_rect.y += - y_offset;
 
-      tmpreg = gdk_region_rectangle (&visible_rect);
-      gdk_region_intersect (real_clip_region, tmpreg);
-      gdk_region_destroy (tmpreg);
+      tmpreg = cairo_region_create_rectangle (&visible_rect);
+      cairo_region_intersect (real_clip_region, tmpreg);
+      cairo_region_destroy (tmpreg);
     }
 
   if (base_x_offset)
@@ -9689,7 +9706,7 @@ _gdk_window_add_damage (GdkWindow *toplevel,
   event.expose.window = toplevel;
   event.expose.send_event = FALSE;
   event.expose.region = damaged_region;
-  gdk_region_get_clipbox (event.expose.region, &event.expose.area);
+  cairo_region_get_extents (event.expose.region, &event.expose.area);
   display = gdk_drawable_get_display (event.expose.window);
   _gdk_event_queue_append (display, gdk_event_copy (&event));
 }
@@ -9800,10 +9817,10 @@ point_in_window (GdkWindowObject *window,
     x >= 0 && x < window->width &&
     y >= 0 && y < window->height &&
     (window->shape == NULL ||
-     gdk_region_point_in (window->shape,
+     cairo_region_contains_point (window->shape,
 			  x, y)) &&
     (window->input_shape == NULL ||
-     gdk_region_point_in (window->input_shape,
+     cairo_region_contains_point (window->input_shape,
 			  x, y));
 }
 
@@ -11389,8 +11406,8 @@ gdk_window_print (GdkWindowObject *window,
   g_print (" abs[%d,%d]",
 	   window->abs_x, window->abs_y);
 
-  gdk_region_get_clipbox (window->clip_region, &r);
-  if (gdk_region_empty (window->clip_region))
+  cairo_region_get_extents (window->clip_region, &r);
+  if (cairo_region_is_empty (window->clip_region))
     g_print (" clipbox[empty]");
   else
     g_print (" clipbox[%d,%d %dx%d]", r.x, r.y, r.width, r.height);
diff --git a/gdk/quartz/GdkQuartzView.c b/gdk/quartz/GdkQuartzView.c
index 2c897fb..7249db7 100644
--- a/gdk/quartz/GdkQuartzView.c
+++ b/gdk/quartz/GdkQuartzView.c
@@ -75,7 +75,7 @@
   const NSRect *drawn_rects;
   NSInteger count;
   int i;
-  GdkRegion *region;
+  cairo_region_t *region;
 
   if (GDK_WINDOW_DESTROYED (gdk_window))
     return;
@@ -89,12 +89,12 @@
   /* Clear our own bookkeeping of regions that need display */
   if (impl->needs_display_region)
     {
-      gdk_region_destroy (impl->needs_display_region);
+      cairo_region_destroy (impl->needs_display_region);
       impl->needs_display_region = NULL;
     }
 
   [self getRectsBeingDrawn:&drawn_rects count:&count];
-  region = gdk_region_new ();
+  region = cairo_region_create ();
   
   for (i = 0; i < count; i++)
     {
@@ -102,15 +102,15 @@
       gdk_rect.y = drawn_rects[i].origin.y;
       gdk_rect.width = drawn_rects[i].size.width;
       gdk_rect.height = drawn_rects[i].size.height;
-      
-      gdk_region_union_with_rect (region, &gdk_rect);
+
+      cairo_region_union_rectangle (region, &gdk_rect);
     }
 
   impl->in_paint_rect_count++;
   _gdk_window_process_updates_recurse (gdk_window, region);
   impl->in_paint_rect_count--;
 
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
 
   if (needsInvalidateShadow)
     {
diff --git a/gdk/quartz/gdkgc-quartz.c b/gdk/quartz/gdkgc-quartz.c
index 552bf5f..8f1a6de 100644
--- a/gdk/quartz/gdkgc-quartz.c
+++ b/gdk/quartz/gdkgc-quartz.c
@@ -437,11 +437,11 @@ _gdk_quartz_gc_update_cg_context (GdkGC                      *gc,
     {
       CGRect rect;
       CGRect *cg_rects;
-      GdkRectangle *rects;
+      cairo_region_t *region;
       gint n_rects, i;
 
-      gdk_region_get_rectangles (_gdk_gc_get_clip_region (gc),
-				 &rects, &n_rects);
+      region = _gdk_gc_get_clip_region (gc);
+      n_rects = cairo_region_num_rectangles (region);
 
       if (n_rects == 1)
 	cg_rects = &rect;
@@ -450,15 +450,16 @@ _gdk_quartz_gc_update_cg_context (GdkGC                      *gc,
 
       for (i = 0; i < n_rects; i++)
 	{
-	  cg_rects[i].origin.x = rects[i].x + gc->clip_x_origin;
-	  cg_rects[i].origin.y = rects[i].y + gc->clip_y_origin;
-	  cg_rects[i].size.width = rects[i].width;
-	  cg_rects[i].size.height = rects[i].height;
+          cairo_rectangle_int_t cairo_rect;
+          cairo_region_get_rectangle (region, i, &cairo_rect);
+	  cg_rects[i].origin.x = cairo_rect.x + gc->clip_x_origin;
+	  cg_rects[i].origin.y = cairo_rect.y + gc->clip_y_origin;
+	  cg_rects[i].size.width = cairo_rect.width;
+	  cg_rects[i].size.height = cairo_rect.height;
 	}
 
       CGContextClipToRects (context, cg_rects, n_rects);
 
-      g_free (rects);
       if (cg_rects != &rect)
 	g_free (cg_rects);
     }
diff --git a/gdk/quartz/gdkgeometry-quartz.c b/gdk/quartz/gdkgeometry-quartz.c
index 06a31f1..12e8a0f 100644
--- a/gdk/quartz/gdkgeometry-quartz.c
+++ b/gdk/quartz/gdkgeometry-quartz.c
@@ -34,7 +34,7 @@ _gdk_quartz_window_queue_translation (GdkWindow *window,
 
   int i, n_rects;
   GdkRegion *intersection;
-  GdkRectangle *rects;
+  GdkRectangle rect;
 
   /* We will intersect the known region that needs display with the given
    * area.  This intersection will be translated by dx, dy.  For the end
@@ -44,17 +44,12 @@ _gdk_quartz_window_queue_translation (GdkWindow *window,
   if (!impl->needs_display_region)
     return;
 
-  intersection = gdk_region_copy (impl->needs_display_region);
-  gdk_region_intersect (intersection, area);
-  gdk_region_offset (intersection, dx, dy);
+  intersection = cairo_region_copy (impl->needs_display_region);
+  cairo_region_intersect (intersection, area);
+  cairo_region_translate (intersection, dx, dy);
 
-  gdk_region_get_rectangles (intersection, &rects, &n_rects);
-
-  for (i = 0; i < n_rects; i++)
-    _gdk_quartz_window_set_needs_display_in_rect (window, &rects[i]);
-
-  g_free (rects);
-  gdk_region_destroy (intersection);
+  _gdk_quartz_window_set_needs_display_in_region (window, intersection);
+  cairo_region_destroy (intersection);
 }
 
 gboolean
diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h
index 4bc924f..6b641a5 100644
--- a/gdk/quartz/gdkprivate-quartz.h
+++ b/gdk/quartz/gdkprivate-quartz.h
@@ -157,8 +157,8 @@ void       _gdk_quartz_window_did_resign_main       (GdkWindow *window);
 void       _gdk_quartz_window_debug_highlight       (GdkWindow *window,
                                                      gint       number);
 
-void       _gdk_quartz_window_set_needs_display_in_rect (GdkWindow    *window,
-                                                         GdkRectangle *rect);
+void       _gdk_quartz_window_set_needs_display_in_region (GdkWindow    *window,
+                                                           GdkRegion    *region);
 
 void       _gdk_quartz_window_update_position           (GdkWindow    *window);
 
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index da4e8c9..dd2f0d3 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -112,28 +112,28 @@ gdk_window_impl_quartz_get_context (GdkDrawable *drawable,
     {
       CGRect rect;
       CGRect *cg_rects;
-      GdkRectangle *rects;
       gint n_rects, i;
 
-      gdk_region_get_rectangles (window_impl->paint_clip_region,
-                                 &rects, &n_rects);
+      n_rects = cairo_region_num_rectangles (window_impl->paint_clip_region);
 
       if (n_rects == 1)
-        cg_rects = &rect;
+	cg_rects = &rect;
       else
-        cg_rects = g_new (CGRect, n_rects);
+	cg_rects = g_new (CGRect, n_rects);
 
       for (i = 0; i < n_rects; i++)
-        {
-          cg_rects[i].origin.x = rects[i].x;
-          cg_rects[i].origin.y = rects[i].y;
-          cg_rects[i].size.width = rects[i].width;
-          cg_rects[i].size.height = rects[i].height;
-        }
+	{
+          cairo_rectangle_int_t cairo_rect;
+          cairo_region_get_rectangle (window_impl->paint_clip_region,
+                                      i, &cairo_rect);
+	  cg_rects[i].origin.x = cairo_rect.x;
+	  cg_rects[i].origin.y = cairo_rect.y;
+	  cg_rects[i].size.width = cairo_rect.width;
+	  cg_rects[i].size.height = cairo_rect.height;
+	}
 
-      CGContextClipToRects (cg_context, cg_rects, n_rects);
+      CGContextClipToRects (context, cg_rects, n_rects);
 
-      g_free (rects);
       if (cg_rects != &rect)
         g_free (cg_rects);
     }
@@ -195,7 +195,7 @@ gdk_window_impl_quartz_finalize (GObject *object)
   check_grab_destroy (GDK_DRAWABLE_IMPL_QUARTZ (object)->wrapper);
 
   if (impl->paint_clip_region)
-    gdk_region_destroy (impl->paint_clip_region);
+    cairo_region_destroy (impl->paint_clip_region);
 
   if (impl->transient_for)
     g_object_unref (impl->transient_for);
@@ -230,18 +230,17 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable    *paintable,
   GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (paintable);
   GdkWindowObject *private = (GdkWindowObject*)window;
   int n_rects;
-  GdkRectangle *rects = NULL;
   GdkPixmap *bg_pixmap;
   GdkRegion *clipped_and_offset_region;
   gboolean free_clipped_and_offset_region = TRUE;
 
   bg_pixmap = private->bg_pixmap;
 
-  clipped_and_offset_region = gdk_region_copy (region);
+  clipped_and_offset_region = cairo_region_copy (region);
 
-  gdk_region_intersect (clipped_and_offset_region,
+  cairo_region_intersect (clipped_and_offset_region,
                         private->clip_region_with_children);
-  gdk_region_offset (clipped_and_offset_region,
+  cairo_region_translate (clipped_and_offset_region,
                      private->abs_x, private->abs_y);
 
   if (impl->begin_paint_count == 0)
@@ -250,14 +249,14 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable    *paintable,
       free_clipped_and_offset_region = FALSE;
     }
   else
-    gdk_region_union (impl->paint_clip_region, clipped_and_offset_region);
+    cairo_region_union (impl->paint_clip_region, clipped_and_offset_region);
 
   impl->begin_paint_count++;
 
   if (bg_pixmap == GDK_NO_BG)
     goto done;
 
-  gdk_region_get_rectangles (clipped_and_offset_region, &rects, &n_rects);
+  n_rects = cairo_region_num_rectangles (clipped_and_offset_region);
 
   if (n_rects == 0)
     goto done;
@@ -276,9 +275,11 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable    *paintable,
  
       for (i = 0; i < n_rects; i++)
         {
+          cairo_rectangle_int_t rect;
+          cairo_region_get_rectangle (clipped_and_offset_region, i, &rect);
           CGContextFillRect (cg_context,
-                             CGRectMake (rects[i].x, rects[i].y,
-                                         rects[i].width, rects[i].height));
+                             CGRectMake (rect.x, rect.y,
+                                         rect.width, rect.height));
         }
 
       gdk_quartz_drawable_release_context (GDK_DRAWABLE (impl), cg_context);
@@ -288,6 +289,7 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable    *paintable,
       int x, y;
       int x_offset, y_offset;
       int width, height;
+      cairo_int_rectangle_t rect;
       GdkGC *gc;
 
       x_offset = y_offset = 0;
@@ -320,14 +322,15 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable    *paintable,
       gdk_drawable_get_size (GDK_DRAWABLE (bg_pixmap), &width, &height);
 
       x = -x_offset;
-      while (x < (rects[0].x + rects[0].width))
+      cairo_region_get_rectangle (clipped_and_offset_region, 0, &rect);
+      while (x < (rect.x + rect.width))
         {
-          if (x + width >= rects[0].x)
+          if (x + width >= rect.x)
 	    {
               y = -y_offset;
-              while (y < (rects[0].y + rects[0].height))
+              while (y < (rect.y + rect.height))
                 {
-                  if (y + height >= rects[0].y)
+                  if (y + height >= rect.y)
                     gdk_draw_drawable (GDK_DRAWABLE (impl), gc, bg_pixmap, 0, 0, x, y, width, height);
 		  
                   y += height;
@@ -341,8 +344,7 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable    *paintable,
 
  done:
   if (free_clipped_and_offset_region)
-    gdk_region_destroy (clipped_and_offset_region);
-  g_free (rects);
+    cairo_region_destroy (clipped_and_offset_region);
 }
 
 static void
@@ -354,38 +356,41 @@ gdk_window_impl_quartz_end_paint (GdkPaintable *paintable)
 
   if (impl->begin_paint_count == 0)
     {
-      gdk_region_destroy (impl->paint_clip_region);
+      cairo_region_destroy (impl->paint_clip_region);
       impl->paint_clip_region = NULL;
     }
 }
 
 void
-_gdk_quartz_window_set_needs_display_in_rect (GdkWindow    *window,
-                                              GdkRectangle *rect)
+_gdk_quartz_window_set_needs_display_in_region (GdkWindow    *window,
+                                                GdkRegion    *region)
 {
   GdkWindowObject *private;
   GdkWindowImplQuartz *impl;
+  int i, n_rects;
 
   private = GDK_WINDOW_OBJECT (window);
   impl = GDK_WINDOW_IMPL_QUARTZ (private->impl);
 
   if (!impl->needs_display_region)
-    impl->needs_display_region = gdk_region_new ();
+    impl->needs_display_region = cairo_region_create ();
 
-  gdk_region_union_with_rect (impl->needs_display_region, rect);
-
-  [impl->view setNeedsDisplayInRect:NSMakeRect (rect->x, rect->y,
-                                                rect->width, rect->height)];
+  cairo_region_union (impl->needs_display_region, region);
 
+  n_rects = cairo_region_num_rectangles (region);
+  for (i = 0; i < n_rects; i++)
+    {
+      cairo_rectangle_int_t rect;
+      cairo_region_get_rectangle (region, i, &rect);
+      [impl->view setNeedsDisplayInRect:NSMakeRect (rect.x, rect.y,
+                                                    rect.width, rect.height)];
+    }
 }
 
 void
 _gdk_windowing_window_process_updates_recurse (GdkWindow *window,
                                                GdkRegion *region)
 {
-  int i, n_rects;
-  GdkRectangle *rects;
-
   /* Make sure to only flush each toplevel at most once if we're called
    * from process_all_updates.
    */
@@ -416,12 +421,7 @@ _gdk_windowing_window_process_updates_recurse (GdkWindow *window,
         }
     }
 
-  gdk_region_get_rectangles (region, &rects, &n_rects);
-
-  for (i = 0; i < n_rects; i++)
-    _gdk_quartz_window_set_needs_display_in_rect (window, &rects[i]);
-
-  g_free (rects);
+  _gdk_quartz_window_set_needs_display_in_region (window, region);
 
   /* NOTE: I'm not sure if we should displayIfNeeded here. It slows down a
    * lot (since it triggers the beam syncing) and things seem to work
@@ -1410,9 +1410,9 @@ move_resize_window_internal (GdkWindow *window,
           new_visible.width = old_visible.width;   /* parent has not changed size */
           new_visible.height = old_visible.height; /* parent has not changed size */
 
-          expose_region = gdk_region_rectangle (&new_visible);
-          old_region = gdk_region_rectangle (&old_visible);
-          gdk_region_subtract (expose_region, old_region);
+          expose_region = cairo_region_create_rectangle (&new_visible);
+          old_region = cairo_region_create_rectangle (&old_visible);
+          cairo_region_subtract (expose_region, old_region);
 
           /* Determine what (if any) part of the previously visible
            * part of the window can be copied without a redraw
@@ -1422,12 +1422,8 @@ move_resize_window_internal (GdkWindow *window,
           scroll_rect.y -= delta.height;
           gdk_rectangle_intersect (&scroll_rect, &old_visible, &scroll_rect);
 
-          if (!gdk_region_empty (expose_region))
+          if (!cairo_region_is_empty (expose_region))
             {
-              GdkRectangle* rects;
-              gint n_rects;
-              gint n;
-
               if (scroll_rect.width != 0 && scroll_rect.height != 0)
                 {
                   [impl->view scrollRect:NSMakeRect (scroll_rect.x,
@@ -1439,12 +1435,7 @@ move_resize_window_internal (GdkWindow *window,
 
               [impl->view setFrame:nsrect];
 
-              gdk_region_get_rectangles (expose_region, &rects, &n_rects);
-
-              for (n = 0; n < n_rects; ++n)
-                _gdk_quartz_window_set_needs_display_in_rect (window, &rects[n]);
-
-              g_free (rects);
+              _gdk_quartz_window_set_needs_display_in_region (window, expose_region);
             }
           else
             {
@@ -1452,8 +1443,8 @@ move_resize_window_internal (GdkWindow *window,
               [impl->view setNeedsDisplay:YES];
             }
 
-          gdk_region_destroy (expose_region);
-          gdk_region_destroy (old_region);
+          cairo_region_destroy (expose_region);
+          cairo_region_destroy (old_region);
         }
     }
 
diff --git a/gdk/win32/gdkdrawable-win32.c b/gdk/win32/gdkdrawable-win32.c
index 5839da9..10bcdf5 100644
--- a/gdk/win32/gdkdrawable-win32.c
+++ b/gdk/win32/gdkdrawable-win32.c
@@ -721,7 +721,7 @@ widen_bounds (GdkRectangle *bounds,
   bounds->width += 2 * pen_width;
   bounds->height += 2 * pen_width;
 
-  return gdk_region_rectangle (bounds);
+  return cairo_region_create_rectangle (bounds);
 }
 
 static void
@@ -799,7 +799,7 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable,
 		(filled ? 0 : LINE_ATTRIBUTES),
 		draw_rectangle, region, filled, x, y, width, height);
 
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
 }
 
 static void
@@ -897,7 +897,7 @@ gdk_win32_draw_arc (GdkDrawable *drawable,
 		GDK_GC_FOREGROUND | (filled ? 0 : LINE_ATTRIBUTES),
 		draw_arc, region, filled, x, y, width, height, angle1, angle2);
 
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
 }
 
 static void
@@ -981,7 +981,7 @@ gdk_win32_draw_polygon (GdkDrawable *drawable,
 		GDK_GC_FOREGROUND | (filled ? 0 : LINE_ATTRIBUTES),
 		draw_polygon, region, filled, pts, npoints);
 
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
   g_free (pts);
 }
 
@@ -1152,7 +1152,7 @@ gdk_win32_draw_segments (GdkDrawable *drawable,
   generic_draw (drawable, gc, GDK_GC_FOREGROUND | LINE_ATTRIBUTES,
 		draw_segments, region, segs, nsegs);
 
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
 }
 
 static void
@@ -1254,7 +1254,7 @@ gdk_win32_draw_lines (GdkDrawable *drawable,
 			      LINE_ATTRIBUTES,
 		draw_lines, region, pts, npoints);
 
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
   g_free (pts);
 }
 
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index e2f2471..db247fb 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -1249,7 +1249,7 @@ synthesize_expose_events (GdkWindow *window)
 	  event->expose.area.y = r.top;
 	  event->expose.area.width = r.right - r.left;
 	  event->expose.area.height = r.bottom - r.top;
-	  event->expose.region = gdk_region_rectangle (&(event->expose.area));
+	  event->expose.region = cairo_region_create_rectangle (&(event->expose.area));
 	  event->expose.count = 0;
   
 	  append_event (event);
@@ -1499,7 +1499,7 @@ _gdk_win32_hrgn_to_region (HRGN hrgn)
       return NULL;
     }
 
-  result = gdk_region_new ();
+  result = cairo_region_create ();
   rects = (RECT *) rgndata->Buffer;
   for (i = 0; i < rgndata->rdh.nCount; i++)
     {
@@ -1510,7 +1510,7 @@ _gdk_win32_hrgn_to_region (HRGN hrgn)
       r.width = rects[i].right - r.x;
       r.height = rects[i].bottom - r.y;
 
-      gdk_region_union_with_rect (result, &r);
+      cairo_region_union_rectangle (result, &r);
     }
 
   g_free (rgndata);
@@ -1598,9 +1598,9 @@ handle_wm_paint (MSG        *msg,
     }
 
   update_region = _gdk_win32_hrgn_to_region (hrgn);
-  if (!gdk_region_empty (update_region))
+  if (!cairo_region_is_empty (update_region))
     _gdk_window_invalidate_for_expose (window, update_region);
-  gdk_region_destroy (update_region);
+  cairo_region_destroy (update_region);
 
   DeleteObject (hrgn);
 }
diff --git a/gdk/win32/gdkgeometry-win32.c b/gdk/win32/gdkgeometry-win32.c
index 6cdb860..044479d 100644
--- a/gdk/win32/gdkgeometry-win32.c
+++ b/gdk/win32/gdkgeometry-win32.c
@@ -252,26 +252,26 @@ gdk_window_clip_changed (GdkWindow    *window,
   obj = (GdkWindowObject *) window;
   impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
   
-  old_clip_region = gdk_region_rectangle (old_clip);
-  new_clip_region = gdk_region_rectangle (new_clip);
+  old_clip_region = cairo_region_create_rectangle (old_clip);
+  new_clip_region = cairo_region_create_rectangle (new_clip);
 
   /* Trim invalid region of window to new clip rectangle
    */
   if (obj->update_area)
-    gdk_region_intersect (obj->update_area, new_clip_region);
+    cairo_region_intersect (obj->update_area, new_clip_region);
 
   /* Invalidate newly exposed portion of window
    */
-  gdk_region_subtract (new_clip_region, old_clip_region);
-  if (!gdk_region_empty (new_clip_region))
+  cairo_region_subtract (new_clip_region, old_clip_region);
+  if (!cairo_region_is_empty (new_clip_region))
     gdk_window_tmp_unset_bg (window);
   else
     {
-      gdk_region_destroy (new_clip_region);
+      cairo_region_destroy (new_clip_region);
       new_clip_region = NULL;
     }
 
-  gdk_region_destroy (old_clip_region);
+  cairo_region_destroy (old_clip_region);
 
   return new_clip_region;
 }
@@ -288,7 +288,7 @@ gdk_window_post_scroll (GdkWindow    *window,
 
   gdk_window_invalidate_region (window, new_clip_region, FALSE);
   g_print ("gdk_window_post_scroll\n");
-  gdk_region_destroy (new_clip_region);
+  cairo_region_destroy (new_clip_region);
 }
 
 #endif
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index 9a474b9..7077d64 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -338,7 +338,7 @@ free_cache_child (GdkCacheChild *child,
                   GdkDisplay    *display)
 {
   if (child->shape)
-    gdk_region_destroy (child->shape);
+    cairo_region_destroy (child->shape);
 
   if (child->shape_selected && display)
     {
@@ -397,7 +397,7 @@ gdk_window_cache_shape_filter (GdkXEvent *xev,
           child->shape_valid = FALSE;
           if (child->shape)
             {
-              gdk_region_destroy (child->shape);
+              cairo_region_destroy (child->shape);
               child->shape = NULL;
             }
         }
@@ -639,8 +639,8 @@ is_pointer_within_shape (GdkDisplay    *display,
                                         child->xid, ShapeInput);
       if (child->shape && input_shape)
         {
-          gdk_region_intersect (child->shape, input_shape);
-          gdk_region_destroy (input_shape);
+          cairo_region_intersect (child->shape, input_shape);
+          cairo_region_destroy (input_shape);
         }
       else if (input_shape)
         {
@@ -652,7 +652,7 @@ is_pointer_within_shape (GdkDisplay    *display,
     }
 
   return child->shape == NULL ||
-         gdk_region_point_in (child->shape, x_pos, y_pos);
+         cairo_region_contains_point (child->shape, x_pos, y_pos);
 }
 
 static Window
diff --git a/gdk/x11/gdkgeometry-x11.c b/gdk/x11/gdkgeometry-x11.c
index 7917031..3d572bd 100644
--- a/gdk/x11/gdkgeometry-x11.c
+++ b/gdk/x11/gdkgeometry-x11.c
@@ -148,11 +148,11 @@ queue_item_free (GdkWindowQueueItem *item)
     }
   
   if (item->type == GDK_WINDOW_QUEUE_ANTIEXPOSE)
-    gdk_region_destroy (item->u.antiexpose.area);
+    cairo_region_destroy (item->u.antiexpose.area);
   else
     {
       if (item->u.translate.area)
-	gdk_region_destroy (item->u.translate.area);
+	cairo_region_destroy (item->u.translate.area);
     }
   
   g_free (item);
@@ -235,7 +235,7 @@ _gdk_x11_window_queue_translation (GdkWindow *window,
 {
   GdkWindowQueueItem *item = g_new (GdkWindowQueueItem, 1);
   item->type = GDK_WINDOW_QUEUE_TRANSLATE;
-  item->u.translate.area = area ? gdk_region_copy (area) : NULL;
+  item->u.translate.area = area ? cairo_region_copy (area) : NULL;
   item->u.translate.dx = dx;
   item->u.translate.dy = dy;
 
@@ -265,7 +265,7 @@ _gdk_window_process_expose (GdkWindow    *window,
 			    gulong        serial,
 			    GdkRectangle *area)
 {
-  GdkRegion *invalidate_region = gdk_region_rectangle (area);
+  GdkRegion *invalidate_region = cairo_region_create_rectangle (area);
   GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window));
 
   if (display_x11->translate_queue)
@@ -288,19 +288,19 @@ _gdk_window_process_expose (GdkWindow    *window,
 			{
 			  GdkRegion *intersection;
 
-			  intersection = gdk_region_copy (invalidate_region);
-			  gdk_region_intersect (intersection, item->u.translate.area);
-			  gdk_region_subtract (invalidate_region, intersection);
-			  gdk_region_offset (intersection, item->u.translate.dx, item->u.translate.dy);
-			  gdk_region_union (invalidate_region, intersection);
-			  gdk_region_destroy (intersection);
+			  intersection = cairo_region_copy (invalidate_region);
+			  cairo_region_intersect (intersection, item->u.translate.area);
+			  cairo_region_subtract (invalidate_region, intersection);
+			  cairo_region_translate (intersection, item->u.translate.dx, item->u.translate.dy);
+			  cairo_region_union (invalidate_region, intersection);
+			  cairo_region_destroy (intersection);
 			}
 		      else
-			gdk_region_offset (invalidate_region, item->u.translate.dx, item->u.translate.dy);
+			cairo_region_translate (invalidate_region, item->u.translate.dx, item->u.translate.dy);
 		    }
 		  else		/* anti-expose */
 		    {
-		      gdk_region_subtract (invalidate_region, item->u.antiexpose.area);
+		      cairo_region_subtract (invalidate_region, item->u.antiexpose.area);
 		    }
 		}
 	    }
@@ -313,10 +313,10 @@ _gdk_window_process_expose (GdkWindow    *window,
 	}
     }
 
-  if (!gdk_region_empty (invalidate_region))
+  if (!cairo_region_is_empty (invalidate_region))
     _gdk_window_invalidate_for_expose (window, invalidate_region);
 
-  gdk_region_destroy (invalidate_region);
+  cairo_region_destroy (invalidate_region);
 }
 
 #define __GDK_GEOMETRY_X11_C__
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 31e3633..263dd17 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -1687,20 +1687,19 @@ gdk_window_x11_clear_region (GdkWindow *window,
 			     GdkRegion *region,
 			     gboolean   send_expose)
 {
-  GdkRectangle *rectangles;
-  int n_rectangles, i;
+  cairo_rectangle_int_t rect;
+  int n_rects, i;
 
-  gdk_region_get_rectangles  (region,
-			      &rectangles,
-			      &n_rectangles);
+  n_rects = cairo_region_num_rectangles (region);
 
-  for (i = 0; i < n_rectangles; i++)
-    XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
-		rectangles[i].x, rectangles[i].y,
-		rectangles[i].width, rectangles[i].height,
-		send_expose);
-
-  g_free (rectangles);
+  for (i = 0; i < n_rects; i++)
+    {
+      cairo_region_get_rectangle (region, i, &rect);
+      XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
+                  rect.x, rect.y,
+                  rect.width, rect.height,
+                  send_expose);
+    }
 }
 
 static void
@@ -4574,7 +4573,7 @@ _xwindow_get_shape (Display *xdisplay,
 			     shape_type, &rn, &ord);
 
   if (xrl == NULL || rn == 0)
-    return gdk_region_new (); /* Empty */
+    return cairo_region_create (); /* Empty */
 
   if (ord != YXBanded)
     {
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index d1e8da5..4a47afb 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -2676,9 +2676,9 @@ gtk_container_propagate_expose (GtkContainer   *container,
       g_object_ref (child_event->expose.window);
 
       child_event->expose.region = gtk_widget_region_intersect (child, event->region);
-      if (!gdk_region_empty (child_event->expose.region))
+      if (!cairo_region_is_empty (child_event->expose.region))
 	{
-	  gdk_region_get_clipbox (child_event->expose.region, &child_event->expose.area);
+	  cairo_region_get_extents (child_event->expose.region, &child_event->expose.area);
 	  gtk_widget_send_expose (child, child_event);
 	}
       gdk_event_free (child_event);
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index b46e660..699c4a0 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -1588,7 +1588,7 @@ gtk_icon_view_expose (GtkWidget *widget,
       area.width = item->width;
       area.height = item->height;
 	
-      if (gdk_region_rect_in (expose->region, &area) == GDK_OVERLAP_RECTANGLE_OUT)
+      if (cairo_region_contains_rectangle (expose->region, &area) == CAIRO_REGION_OVERLAP_OUT)
 	continue;
       
       gtk_icon_view_paint_item (icon_view, cr, item, &expose->area, 
@@ -1660,17 +1660,16 @@ gtk_icon_view_expose (GtkWidget *widget,
   
   if (icon_view->priv->doing_rubberband)
     {
-      GdkRectangle *rectangles;
+      cairo_rectangle_int_t rectangle;
       gint n_rectangles;
       
-      gdk_region_get_rectangles (expose->region,
-				 &rectangles,
-				 &n_rectangles);
+      n_rectangles = cairo_region_num_rectangles (expose->region);
       
       while (n_rectangles--)
-	gtk_icon_view_paint_rubberband (icon_view, cr, &rectangles[n_rectangles]);
-
-      g_free (rectangles);
+        {
+          cairo_region_get_rectangle (expose->region, n_rectangles--, &rectangle);
+	  gtk_icon_view_paint_rubberband (icon_view, cr, &rectangle);
+        }
     }
 
   cairo_destroy (cr);
@@ -2345,8 +2344,8 @@ gtk_icon_view_update_rubberband (gpointer data)
   new_area.width = ABS (x - icon_view->priv->rubberband_x1) + 1;
   new_area.height = ABS (y - icon_view->priv->rubberband_y1) + 1;
 
-  invalid_region = gdk_region_rectangle (&old_area);
-  gdk_region_union_with_rect (invalid_region, &new_area);
+  invalid_region = cairo_region_create_rectangle (&old_area);
+  cairo_region_union_rectangle (invalid_region, &new_area);
 
   gdk_rectangle_intersect (&old_area, &new_area, &common);
   if (common.width > 2 && common.height > 2)
@@ -2359,15 +2358,15 @@ gtk_icon_view_update_rubberband (gpointer data)
       common.width -= 2;
       common.height -= 2;
       
-      common_region = gdk_region_rectangle (&common);
+      common_region = cairo_region_create_rectangle (&common);
 
-      gdk_region_subtract (invalid_region, common_region);
-      gdk_region_destroy (common_region);
+      cairo_region_subtract (invalid_region, common_region);
+      cairo_region_destroy (common_region);
     }
   
   gdk_window_invalidate_region (icon_view->priv->bin_window, invalid_region, TRUE);
     
-  gdk_region_destroy (invalid_region);
+  cairo_region_destroy (invalid_region);
 
   icon_view->priv->rubberband_x2 = x;
   icon_view->priv->rubberband_y2 = y;  
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index f359107..41c4a6f 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -4015,7 +4015,7 @@ gtk_label_expose (GtkWidget      *widget,
                                                    x, y,
                                                    range,
                                                    1);
-	  gdk_region_intersect (clip, event->region);
+	  cairo_region_intersect (clip, event->region);
 
          /* FIXME should use gtk_paint, but it can't use a clip
            * region
@@ -4036,7 +4036,7 @@ gtk_label_expose (GtkWidget      *widget,
                                        &widget->style->base[state]);
 
           gdk_gc_set_clip_region (widget->style->black_gc, NULL);
-          gdk_region_destroy (clip);
+          cairo_region_destroy (clip);
         }
       else if (info)
         {
@@ -4086,7 +4086,7 @@ gtk_label_expose (GtkWidget      *widget,
               gdk_color_free (visited_link_color);
 
               gdk_gc_set_clip_region (widget->style->black_gc, NULL);
-              gdk_region_destroy (clip);
+              cairo_region_destroy (clip);
             }
 
           if (focus_link && gtk_widget_has_focus (widget))
@@ -4098,13 +4098,13 @@ gtk_label_expose (GtkWidget      *widget,
                                                        x, y,
                                                        range,
                                                        1);
-              gdk_region_get_clipbox (clip, &rect);
+              cairo_region_get_extents (clip, &rect);
 
               gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget),
                                &event->area, widget, "label",
                                rect.x, rect.y, rect.width, rect.height);
 
-              gdk_region_destroy (clip);
+              cairo_region_destroy (clip);
             }
         }
     }
diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c
index 1b9a7f2..136e55a 100644
--- a/gtk/gtktextdisplay.c
+++ b/gtk/gtktextdisplay.c
@@ -426,7 +426,7 @@ get_selected_clip (GtkTextRenderer    *text_renderer,
 {
   gint *ranges;
   gint n_ranges, i;
-  GdkRegion *clip_region = gdk_region_new ();
+  GdkRegion *clip_region = cairo_region_create ();
   GdkRegion *tmp_region;
 
   pango_layout_line_get_x_ranges (line, start_index, end_index, &ranges, &n_ranges);
@@ -440,12 +440,12 @@ get_selected_clip (GtkTextRenderer    *text_renderer,
       rect.width = PANGO_PIXELS (ranges[2*i + 1]) - PANGO_PIXELS (ranges[2*i]);
       rect.height = height;
       
-      gdk_region_union_with_rect (clip_region, &rect);
+      cairo_region_union_rectangle (clip_region, &rect);
     }
 
-  tmp_region = gdk_region_rectangle (&text_renderer->clip_rect);
-  gdk_region_intersect (clip_region, tmp_region);
-  gdk_region_destroy (tmp_region);
+  tmp_region = cairo_region_create_rectangle (&text_renderer->clip_rect);
+  cairo_region_intersect (clip_region, tmp_region);
+  cairo_region_destroy (tmp_region);
 
   g_free (ranges);
   return clip_region;
@@ -612,7 +612,7 @@ render_para (GtkTextRenderer    *text_renderer,
               gdk_gc_set_clip_region (fg_gc, NULL);
 	      gdk_pango_renderer_set_gc (GDK_PANGO_RENDERER (text_renderer), fg_gc);
 	      
-              gdk_region_destroy (clip_region);
+              cairo_region_destroy (clip_region);
 
               /* Paint in the ends of the line */
               if (line_rect.x > line_display->left_margin * PANGO_SCALE &&
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 22d25ab..69b7991 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -4044,8 +4044,8 @@ gtk_tree_view_update_rubber_band (GtkTreeView *tree_view)
   new_area.width = ABS (x - tree_view->priv->press_start_x) + 1;
   new_area.height = ABS (y - tree_view->priv->press_start_y) + 1;
 
-  invalid_region = gdk_region_rectangle (&old_area);
-  gdk_region_union_with_rect (invalid_region, &new_area);
+  invalid_region = cairo_region_create_rectangle (&old_area);
+  cairo_region_union_rectangle (invalid_region, &new_area);
 
   gdk_rectangle_intersect (&old_area, &new_area, &common);
   if (common.width > 2 && common.height > 2)
@@ -4058,15 +4058,15 @@ gtk_tree_view_update_rubber_band (GtkTreeView *tree_view)
       common.width -= 2;
       common.height -= 2;
 
-      common_region = gdk_region_rectangle (&common);
+      common_region = cairo_region_create_rectangle (&common);
 
-      gdk_region_subtract (invalid_region, common_region);
-      gdk_region_destroy (common_region);
+      cairo_region_subtract (invalid_region, common_region);
+      cairo_region_destroy (common_region);
     }
 
   gdk_window_invalidate_region (tree_view->priv->bin_window, invalid_region, TRUE);
 
-  gdk_region_destroy (invalid_region);
+  cairo_region_destroy (invalid_region);
 
   tree_view->priv->rubber_band_x = x;
   tree_view->priv->rubber_band_y = y;
@@ -4532,7 +4532,7 @@ gtk_tree_view_bin_expose (GtkWidget      *widget,
 	      cell_area.height -= grid_line_width;
 	    }
 
-	  if (gdk_region_rect_in (event->region, &background_area) == GDK_OVERLAP_RECTANGLE_OUT)
+	  if (cairo_region_contains_rectangle (event->region, &background_area) == CAIRO_REGION_OVERLAP_OUT)
 	    {
 	      cell_offset += column->width;
 	      continue;
@@ -5003,20 +5003,19 @@ gtk_tree_view_bin_expose (GtkWidget      *widget,
 done:
   gtk_tree_view_draw_grid_lines (tree_view, event, n_visible_columns);
 
- if (tree_view->priv->rubber_band_status == RUBBER_BAND_ACTIVE)
-   {
-     GdkRectangle *rectangles;
-     gint n_rectangles;
-
-     gdk_region_get_rectangles (event->region,
-				&rectangles,
-				&n_rectangles);
-
-     while (n_rectangles--)
-       gtk_tree_view_paint_rubber_band (tree_view, &rectangles[n_rectangles]);
-
-     g_free (rectangles);
-   }
+  if (tree_view->priv->rubber_band_status == RUBBER_BAND_ACTIVE)
+    {
+      GdkRectangle rectangle;
+      gint n_rectangles;
+ 
+      n_rectangles = cairo_region_num_rectangles (event->region);
+ 
+      while (n_rectangles--)
+        {
+          cairo_region_get_rectangle (event->region, n_rectangles, &rectangle);
+          gtk_tree_view_paint_rubber_band (tree_view, &rectangle);
+        }
+    }
 
   if (cursor_path)
     gtk_tree_path_free (cursor_path);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 610660e..edf87a0 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3913,7 +3913,7 @@ gtk_widget_invalidate_widget_windows (GtkWidget *widget,
       int x, y;
       
       gdk_window_get_position (widget->window, &x, &y);
-      gdk_region_offset (region, -x, -y);
+      cairo_region_translate (region, -x, -y);
     }
 
   gdk_window_invalidate_maybe_recurse (widget->window, region,
@@ -3952,9 +3952,9 @@ gtk_widget_queue_shallow_draw (GtkWidget *widget)
       rect.y += wy;
     }
   
-  region = gdk_region_rectangle (&rect);
+  region = cairo_region_create_rectangle (&rect);
   gtk_widget_invalidate_widget_windows (widget, region);
-  gdk_region_destroy (region);
+  cairo_region_destroy (region);
 }
 
 /**
@@ -4042,11 +4042,11 @@ gtk_widget_size_allocate (GtkWidget	*widget,
 	{
 	  /* Invalidate union(old_allaction,widget->allocation) in widget->window
 	   */
-	  GdkRegion *invalidate = gdk_region_rectangle (&widget->allocation);
-	  gdk_region_union_with_rect (invalidate, &old_allocation);
+	  GdkRegion *invalidate = cairo_region_create_rectangle (&widget->allocation);
+	  cairo_region_union_rectangle (invalidate, &old_allocation);
 
 	  gdk_window_invalidate_region (widget->window, invalidate, FALSE);
-	  gdk_region_destroy (invalidate);
+	  cairo_region_destroy (invalidate);
 	}
       
       if (size_changed)
@@ -4055,11 +4055,11 @@ gtk_widget_size_allocate (GtkWidget	*widget,
 	    {
 	      /* Invalidate union(old_allaction,widget->allocation) in widget->window and descendents owned by widget
 	       */
-	      GdkRegion *invalidate = gdk_region_rectangle (&widget->allocation);
-	      gdk_region_union_with_rect (invalidate, &old_allocation);
+	      GdkRegion *invalidate = cairo_region_create_rectangle (&widget->allocation);
+	      cairo_region_union_rectangle (invalidate, &old_allocation);
 
 	      gtk_widget_invalidate_widget_windows (widget, invalidate);
-	      gdk_region_destroy (invalidate);
+	      cairo_region_destroy (invalidate);
 	    }
 	}
     }
@@ -4067,9 +4067,9 @@ gtk_widget_size_allocate (GtkWidget	*widget,
   if ((size_changed || position_changed) && widget->parent &&
       gtk_widget_get_realized (widget->parent) && GTK_CONTAINER (widget->parent)->reallocate_redraws)
     {
-      GdkRegion *invalidate = gdk_region_rectangle (&widget->parent->allocation);
+      GdkRegion *invalidate = cairo_region_create_rectangle (&widget->parent->allocation);
       gtk_widget_invalidate_widget_windows (widget->parent, invalidate);
-      gdk_region_destroy (invalidate);
+      cairo_region_destroy (invalidate);
     }
 }
 
@@ -5188,7 +5188,7 @@ gtk_widget_intersect (GtkWidget	         *widget,
  *           widgets with their own window.
  * 
  * Computes the intersection of a @widget's area and @region, returning
- * the intersection. The result may be empty, use gdk_region_empty() to
+ * the intersection. The result may be empty, use cairo_region_is_empty() to
  * check.
  **/
 GdkRegion *
@@ -5203,9 +5203,9 @@ gtk_widget_region_intersect (GtkWidget       *widget,
 
   gtk_widget_get_draw_rectangle (widget, &rect);
   
-  dest = gdk_region_rectangle (&rect);
+  dest = cairo_region_create_rectangle (&rect);
  
-  gdk_region_intersect (dest, region);
+  cairo_region_intersect (dest, region);
 
   return dest;
 }
@@ -9659,7 +9659,7 @@ expose_window (GdkWindow *window)
   gdk_drawable_get_size (GDK_DRAWABLE (window),
 			 &event.expose.area.width,
 			 &event.expose.area.height);
-  event.expose.region = gdk_region_rectangle (&event.expose.area);
+  event.expose.region = cairo_region_create_rectangle (&event.expose.area);
 
   /* If this is not double buffered, force a double buffer so that
      redirection works. */
diff --git a/tests/testgtk.c b/tests/testgtk.c
index abd1f7f..0f02c21 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -457,8 +457,8 @@ window_expose_event (GtkWidget *widget,
                                child->allocation.y);
 
   /* draw no more than our expose event intersects our child */
-  region = gdk_region_rectangle (&child->allocation);
-  gdk_region_intersect (region, event->region);
+  region = cairo_region_create_rectangle (&child->allocation);
+  cairo_region_intersect (region, event->region);
   gdk_cairo_region (cr, region);
   cairo_clip (cr);
 
@@ -7747,7 +7747,7 @@ create_shapes (GtkWidget *widget)
       /* reset shape from mask to a region */
       x = 0;
       y = 0;
-      region = gdk_region_new ();
+      region = cairo_region_create ();
 
       while (x < 460)
         {
@@ -7759,7 +7759,7 @@ create_shapes (GtkWidget *widget)
               rect.width = 10;
               rect.height = 10;
 
-              gdk_region_union_with_rect (region, &rect);
+              cairo_region_union_rectangle (region, &rect);
               
               y += 20;
             }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]