diff --git a/gdk/quartz/gdkimage-quartz.c b/gdk/quartz/gdkimage-quartz.c
index ce032aa..3a2d08f 100644
--- a/gdk/quartz/gdkimage-quartz.c
+++ b/gdk/quartz/gdkimage-quartz.c
@@ -131,15 +131,14 @@ _gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
     {
       GdkQuartzView *view;
       NSBitmapImageRep *rep;
-      NSRect rect;
       guchar *data;
       int x, y;
       NSSize size;
-            
-      rect = NSMakeRect (src_x, src_y, width, height);
       
       if (GDK_WINDOW_IMPL_QUARTZ (drawable) == GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (_gdk_root)->impl))
         {
+          CGRect rect = CGRectMake (src_x, src_y, width, height);
+
           /* Special case for the root window. */
           CGImageRef root_image_ref = CGWindowListCreateImage (rect,
                                                                kCGWindowListOptionOnScreenOnly,
@@ -150,6 +149,8 @@ _gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
         }
       else
         {
+          NSRect rect = NSMakeRect (src_x, src_y, width, height);
+
           view = GDK_WINDOW_IMPL_QUARTZ (drawable)->view;
 
           /* We return the image even if we can't copy to it. */
