Commit 2f710f0f authored by Behdad Esfahbod's avatar Behdad Esfahbod Committed by Behdad Esfahbod

Throttle invalidating to at most 40 times per second, using a timeout.

2006-02-10  Behdad Esfahbod  <behdad@gnome.org>

        * src/vte.c (_vte_invalidate_cells): Throttle invalidating to at most
        40 times per second, using a timeout.
parent bd9905c8
2006-02-10 Behdad Esfahbod <behdad@gnome.org>
* src/vte.c (_vte_invalidate_cells): Throttle invalidating to at most
40 times per second, using a timeout.
2006-02-10 Behdad Esfahbod <behdad@gnome.org>
* src/vteseq.c: Removed the huge sequence handler table. Changed to
......
......@@ -220,6 +220,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;
......
......@@ -190,6 +190,34 @@ _vte_terminal_set_default_attributes(VteTerminal *terminal)
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. */
void
_vte_invalidate_cells(VteTerminal *terminal,
......@@ -249,8 +277,20 @@ _vte_invalidate_cells(VteTerminal *terminal,
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 40fps. */
terminal->pvt->update_timer = g_timeout_add (25, vte_update_timeout, terminal);
}
}
/* Redraw the entire visible portion of the window. */
......@@ -273,6 +313,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);
......@@ -7222,6 +7266,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. */
terminal->pvt = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment