testgtk: Use draw signal in layout test

This commit is contained in:
Benjamin Otte 2010-09-09 03:39:43 +02:00
parent 5442f5b9f2
commit e194bc14fd

View File

@ -9697,29 +9697,31 @@ create_mainloop (GtkWidget *widget)
gtk_widget_destroy (window);
}
gboolean
layout_expose_handler (GtkWidget *widget, GdkEventExpose *event)
static gboolean
layout_draw_handler (GtkWidget *widget, cairo_t *cr)
{
GtkLayout *layout;
GdkWindow *bin_window;
cairo_t *cr;
gint i,j;
GdkRectangle clip;
gint i,j,x,y;
gint imin, imax, jmin, jmax;
layout = GTK_LAYOUT (widget);
bin_window = gtk_layout_get_bin_window (layout);
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++)
@ -9730,8 +9732,6 @@ layout_expose_handler (GtkWidget *widget, GdkEventExpose *event)
cairo_fill (cr);
cairo_destroy (cr);
return FALSE;
}
@ -9784,8 +9784,8 @@ void create_layout (GtkWidget *widget)
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), NULL);
g_signal_connect (layout, "draw",
G_CALLBACK (layout_draw_handler), NULL);
gtk_layout_set_size (layout, 1600, 128000);