[gtk+/rendering-cleanup-next: 127/153] testoffscreen: Connect to draw signal



commit 3df1e569cb745be6683ae387dbebfc942e588984
Author: Benjamin Otte <otte redhat com>
Date:   Thu Sep 9 01:52:14 2010 +0200

    testoffscreen: Connect to draw signal

 tests/testoffscreen.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/tests/testoffscreen.c b/tests/testoffscreen.c
index ad2c1a0..28cfb87 100644
--- a/tests/testoffscreen.c
+++ b/tests/testoffscreen.c
@@ -20,26 +20,31 @@ combo_changed_cb (GtkWidget *combo,
 }
 
 static gboolean
-layout_expose_handler (GtkWidget      *widget,
-                       GdkEventExpose *event)
+layout_draw_handler (GtkWidget *widget,
+                     cairo_t   *cr,
+                     int        width,
+                     int        height)
 {
   GtkLayout *layout = GTK_LAYOUT (widget);
   GdkWindow *bin_window = gtk_layout_get_bin_window (layout);
-  cairo_t *cr;
+  GdkRectangle clip;
 
-  gint i,j;
+  gint i, j, x, y;
   gint imin, imax, jmin, jmax;
 
-  if (event->window != bin_window)
+  if (!gtk_cairo_should_draw_window (cr, bin_window))
     return FALSE;
 
-  imin = (event->area.x) / 10;
-  imax = (event->area.x + event->area.width + 9) / 10;
+  gdk_window_get_position (bin_window, &x, &y);
+  cairo_translate (cr, x, y);
 
-  jmin = (event->area.y) / 10;
-  jmax = (event->area.y + event->area.height + 9) / 10;
+  gdk_cairo_get_clip_rectangle (cr, &clip);
 
-  cr = gdk_cairo_create (bin_window);
+  imin = (clip.x) / 10;
+  imax = (clip.x + clip.width + 9) / 10;
+
+  jmin = (clip.y) / 10;
+  jmax = (clip.y + clip.height + 9) / 10;
 
   for (i = imin; i < imax; i++)
     for (j = jmin; j < jmax; j++)
@@ -50,8 +55,6 @@ layout_expose_handler (GtkWidget      *widget,
 
   cairo_fill (cr);
 
-  cairo_destroy (cr);
-
   return FALSE;
 }
 
@@ -103,8 +106,8 @@ create_layout (GtkWidget *vbox)
   gtk_layout_set_vadjustment (layout, vadjustment);
 
   gtk_widget_set_events (layout_widget, GDK_EXPOSURE_MASK);
-  g_signal_connect (layout, "expose_event",
-		    G_CALLBACK (layout_expose_handler),
+  g_signal_connect (layout, "draw",
+		    G_CALLBACK (layout_draw_handler),
                     NULL);
 
   gtk_layout_set_size (layout, 1600, 128000);



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