[gtk+] Ensure that queue_translation is paired with the right X operation



commit 939e55223cefb14ec4a6866c073bd79ee75eaccc
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Aug 13 14:25:35 2009 +0200

    Ensure that queue_translation is paired with the right X operation
    
    The X11 queue_translation operation uses NextRequest to get the serial
    of the XCopyArea operation where the translation should end. However,
    if the gc passed to gdk_draw_drawable has a non-flushed clip region
    (which it commonly has now for the window clipping) then the next
    operation will be the GC flush, not the XCopyArea.
    
    To handle this right we now pass in the GC to be used to
    queue_translation and ensure that it is flushed before calling
    NextRequest().

 gdk/directfb/gdkwindow-directfb.c |    1 +
 gdk/gdkoffscreenwindow.c          |    1 +
 gdk/gdkwindow.c                   |   10 +++++-----
 gdk/gdkwindowimpl.h               |    1 +
 gdk/quartz/gdkgeometry-quartz.c   |    1 +
 gdk/quartz/gdkprivate-quartz.h    |    1 +
 gdk/win32/gdkwindow-win32.c       |    1 +
 gdk/x11/gdkgeometry-x11.c         |    6 ++++++
 gdk/x11/gdkprivate-x11.h          |    1 +
 9 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/gdk/directfb/gdkwindow-directfb.c b/gdk/directfb/gdkwindow-directfb.c
index 42196f7..a7d3d30 100644
--- a/gdk/directfb/gdkwindow-directfb.c
+++ b/gdk/directfb/gdkwindow-directfb.c
@@ -1957,6 +1957,7 @@ gdk_directfb_window_input_shape_combine_region (GdkWindow       *window,
 
 static void
 gdk_directfb_window_queue_translation (GdkWindow *window,
+				       GdkGC     *gc,
                                        GdkRegion *region,
                                        gint       dx,
                                        gint       dy)
diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c
index f14f831..0029708 100644
--- a/gdk/gdkoffscreenwindow.c
+++ b/gdk/gdkoffscreenwindow.c
@@ -1149,6 +1149,7 @@ gdk_offscreen_window_queue_antiexpose (GdkWindow *window,
 
 static void
 gdk_offscreen_window_queue_translation (GdkWindow *window,
+					GdkGC     *gc,
 					GdkRegion *area,
 					gint       dx,
 					gint       dy)
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index eaca781..1c1bb32 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -2828,16 +2828,16 @@ 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);
+  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); /* Temporarily move to source area */
+  gdk_region_offset (dest_region, -dx, -dy); /* Move to source region */
   GDK_WINDOW_IMPL_GET_IFACE (private->impl)->queue_translation ((GdkWindow *)impl_window,
+								tmp_gc,
 								dest_region, dx, dy);
-  gdk_region_offset (dest_region, dx, dy); /* back to dest area */
 
-  gdk_region_get_clipbox (dest_region, &copy_rect);
-
-  gdk_gc_set_clip_region (tmp_gc, dest_region);
   gdk_draw_drawable (impl_window->impl,
 		     tmp_gc,
 		     private->impl,
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index ad1ae6b..b8de474 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -118,6 +118,7 @@ struct _GdkWindowImplIface
   gboolean     (* queue_antiexpose)     (GdkWindow       *window,
 					 GdkRegion       *update_area);
   void         (* queue_translation)    (GdkWindow       *window,
+					 GdkGC           *gc,
 					 GdkRegion       *area,
 					 gint            dx,
 					 gint            dy);
diff --git a/gdk/quartz/gdkgeometry-quartz.c b/gdk/quartz/gdkgeometry-quartz.c
index eceb071..3e0a26f 100644
--- a/gdk/quartz/gdkgeometry-quartz.c
+++ b/gdk/quartz/gdkgeometry-quartz.c
@@ -24,6 +24,7 @@
 
 void
 _gdk_quartz_window_queue_translation (GdkWindow *window,
+				      GdkGC     *gc,
                                       GdkRegion *area,
                                       gint       dx,
                                       gint       dy)
diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h
index 9590d9b..2152b6e 100644
--- a/gdk/quartz/gdkprivate-quartz.h
+++ b/gdk/quartz/gdkprivate-quartz.h
@@ -187,6 +187,7 @@ void        _gdk_quartz_window_scroll      (GdkWindow       *window,
                                             gint             dx,
                                             gint             dy);
 void        _gdk_quartz_window_queue_translation (GdkWindow *window,
+						  GdkGC     *gc,
                                                   GdkRegion *area,
                                                   gint       dx,
                                                   gint       dy);
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index d341449..1380f0b 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -3576,6 +3576,7 @@ _gdk_win32_window_queue_antiexpose (GdkWindow *window,
  */
 static void
 _gdk_win32_window_queue_translation (GdkWindow *window,
+				     GdkGC     *gc,
 				     GdkRegion *area,
 				     gint       dx,
 				     gint       dy)
diff --git a/gdk/x11/gdkgeometry-x11.c b/gdk/x11/gdkgeometry-x11.c
index b00ef05..8efeea9 100644
--- a/gdk/x11/gdkgeometry-x11.c
+++ b/gdk/x11/gdkgeometry-x11.c
@@ -231,6 +231,7 @@ gdk_window_queue (GdkWindow          *window,
 
 void
 _gdk_x11_window_queue_translation (GdkWindow *window,
+				   GdkGC     *gc,
 				   GdkRegion *area,
 				   gint       dx,
 				   gint       dy)
@@ -241,6 +242,11 @@ _gdk_x11_window_queue_translation (GdkWindow *window,
   item->u.translate.dx = dx;
   item->u.translate.dy = dy;
 
+  /* Ensure that the gc is flushed so that we get the right
+     serial from NextRequest in gdk_window_queue, i.e. the
+     the serial for the XCopyArea, not the ones from flushing
+     the gc. */
+  _gdk_x11_gc_flush (gc);
   gdk_window_queue (window, item);
 }
 
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 871fa74..bfbf3d9 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -130,6 +130,7 @@ void _gdk_window_process_expose    (GdkWindow     *window,
 gboolean _gdk_x11_window_queue_antiexpose  (GdkWindow *window,
 					    GdkRegion *area);
 void     _gdk_x11_window_queue_translation (GdkWindow *window,
+					    GdkGC     *gc,
 					    GdkRegion *area,
 					    gint       dx,
 					    gint       dy);



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