[gtk+/rendering-cleanup: 65/95] quartz: Fix up _gdk_quartz_window_translate



commit add93dbf4d3a0dafd4deb811852dc96738b652a5
Author: Kristian Rietveld <kris gtk org>
Date:   Sat Jul 24 10:52:10 2010 +0200

    quartz: Fix up _gdk_quartz_window_translate

 gdk/quartz/gdkgeometry-quartz.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/gdk/quartz/gdkgeometry-quartz.c b/gdk/quartz/gdkgeometry-quartz.c
index bde84aa..bd602e3 100644
--- a/gdk/quartz/gdkgeometry-quartz.c
+++ b/gdk/quartz/gdkgeometry-quartz.c
@@ -22,32 +22,48 @@
 
 #include "gdkprivate-quartz.h"
 
-/* FIXME: Tis function has never been compiled.
- * Please make it work. */
 void
 _gdk_quartz_window_translate (GdkWindow      *window,
                               cairo_region_t *area,
                               gint            dx,
                               gint            dy)
 {
+  cairo_region_t *invalidate, *scrolled;
   GdkWindowObject *private = (GdkWindowObject *)window;
   GdkWindowImplQuartz *impl = (GdkWindowImplQuartz *)private->impl;
   GdkRectangle extents;
 
   cairo_region_get_extents (area, &extents);
 
-  [window_impl->view scrollRect:NSMakeRect (extents.x, extents.y, extents.width, extents.height)
-                             by:NSMakeSize (dx, dy)];
+  [impl->view scrollRect:NSMakeRect (extents.x - dx, extents.y - dy,
+                                     extents.width, extents.height)
+              by:NSMakeSize (dx, dy)];
 
   if (impl->needs_display_region)
     {
+      cairo_region_t *intersection;
+
+      /* Invalidate already invalidated area that was moved at new
+       * location.
+       */
       intersection = cairo_region_copy (impl->needs_display_region);
-      cairo_region_intersect_rectangle (intersection, extents);
+      cairo_region_intersect (intersection, area);
       cairo_region_translate (intersection, dx, dy);
 
       _gdk_quartz_window_set_needs_display_in_region (window, intersection);
       cairo_region_destroy (intersection);
     }
+
+  /* Calculate newly exposed area that needs invalidation */
+  scrolled = cairo_region_copy (area);
+  cairo_region_translate (scrolled, dx, dy);
+
+  invalidate = cairo_region_copy (area);
+  cairo_region_subtract (invalidate, scrolled);
+  cairo_region_destroy (scrolled);
+
+  _gdk_quartz_window_set_needs_display_in_region (window, invalidate);
+  cairo_region_destroy (invalidate);
 }
 
 gboolean



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