Index: src/vte.c
===================================================================
RCS file: /cvs/gnome/vte/src/vte.c,v
retrieving revision 1.432
diff -u -p -d -r1.432 vte.c
--- src/vte.c	3 Feb 2006 14:34:10 -0000	1.432
+++ src/vte.c	9 Feb 2006 23:13:02 -0000
@@ -253,6 +253,9 @@ struct _VteTerminalPrivate {
 		GString *status_line_contents;
 	} normal_screen, alternate_screen, *screen;
 
+	GdkRegion *update_region;
+	gint update_timer;
+
 	/* Selection information. */
 	GArray *word_chars;
 	gboolean has_selection;
@@ -597,6 +600,34 @@ vte_terminal_set_default_attributes(VteT
 	terminal->pvt->screen->fill_defaults = terminal->pvt->screen->defaults;
 }
 
+static gboolean
+vte_update_timeout(VteTerminal *terminal)
+{
+	terminal->pvt->update_timer = 0;
+	if (terminal->pvt->update_region) {
+		gdk_window_invalidate_region(GTK_WIDGET(terminal)->window,
+					     terminal->pvt->update_region, FALSE);
+		gdk_region_destroy (terminal->pvt->update_region);
+		terminal->pvt->update_region = NULL;
+	}
+
+	return FALSE;
+}
+
+static void
+vte_free_update_timer (VteTerminal *terminal)
+{
+	if (terminal->pvt->update_timer) {
+		g_source_remove (terminal->pvt->update_timer);
+		terminal->pvt->update_timer = 0;
+	}
+
+	if (terminal->pvt->update_region) {
+		gdk_region_destroy (terminal->pvt->update_region);
+		terminal->pvt->update_region = NULL;
+	}
+}
+
 /* Cause certain cells to be repainted. */
 static void
 vte_invalidate_cells(VteTerminal *terminal,
@@ -656,8 +687,20 @@ vte_invalidate_cells(VteTerminal *termin
 		rect.height += VTE_PAD_WIDTH;
 	}
 
-	/* Invalidate the rectangle. */
-	gdk_window_invalidate_rect(widget->window, &rect, FALSE);
+	if (terminal->pvt->update_timer) {
+		if (!terminal->pvt->update_region)
+			terminal->pvt->update_region = gdk_region_rectangle (&rect);
+		else
+			gdk_region_union_with_rect (terminal->pvt->update_region, &rect);
+	} else {
+		/* Invalidate the rectangle. */
+		gdk_window_invalidate_rect(widget->window, &rect, FALSE);
+
+		/* Set a timer such that we do not invalidate for a while. */
+		/* This limits the number of times we draw to 40 Hz. */
+		terminal->pvt->update_timer = g_timeout_add (25, vte_update_timeout, terminal);
+	}
+
 }
 
 /* Redraw the entire visible portion of the window. */
@@ -680,6 +723,10 @@ vte_invalidate_all(VteTerminal *terminal
 		return;
 	}
 
+	if (terminal->pvt->update_timer) {
+		vte_free_update_timer (terminal);
+	}
+
 	/* Expose the entire widget area. */
 	width = height = 0;
 	gdk_drawable_get_size(widget->window, &width, &height);
@@ -12038,6 +12085,10 @@ vte_terminal_finalize(GObject *object)
 	}
 	_vte_termcap_free(terminal->pvt->termcap);
 	terminal->pvt->termcap = NULL;
+
+	if (terminal->pvt->update_timer) {
+		vte_free_update_timer (terminal);
+	}
 
 	/* Done with our private data. */
 	g_free(terminal->pvt);

