From 8f20ab88c90feefc7b88d4b27b02800c2d9f4e20 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 6 May 2016 05:35:02 -0400 Subject: make the redraw rate limit configurable --- src/config.c | 5 +++++ src/config.h | 2 ++ src/window-xlib.c | 9 +++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/config.c b/src/config.c index 3f9da3b..ca9abc6 100644 --- a/src/config.c +++ b/src/config.c @@ -44,6 +44,8 @@ static void runes_config_set_defaults(RunesTerm *t) config->audible_bell = 1; config->bell_is_urgent = 1; + config->redraw_rate = 5; + config->cursorcolor = cairo_pattern_create_rgb(0.0, 1.0, 0.0); config->mousecursorcolor = cairo_pattern_create_rgb(1.0, 1.0, 1.0); @@ -497,6 +499,9 @@ static void runes_config_set(RunesTerm *t, char *key, char *val) else if (!strcmp(key, "scrollback_length")) { config->scrollback_length = runes_config_parse_uint(val); } + else if (!strcmp(key, "redraw_rate")) { + config->redraw_rate = runes_config_parse_uint(val); + } else if (!strcmp(key, "command")) { config->cmd = runes_config_parse_string(val); } diff --git a/src/config.h b/src/config.h index b718f8b..1da07a2 100644 --- a/src/config.h +++ b/src/config.h @@ -17,6 +17,8 @@ struct runes_config { int scroll_lines; int scrollback_length; + int redraw_rate; + char *cmd; char *font_name; diff --git a/src/window-xlib.c b/src/window-xlib.c index 64abafc..3182e31 100644 --- a/src/window-xlib.c +++ b/src/window-xlib.c @@ -518,9 +518,14 @@ static int runes_window_backend_check_recent(RunesTerm *t) { RunesWindowBackend *w = &t->w; struct timespec now; + int rate = t->config.redraw_rate; + + if (rate == 0) { + return 0; + } clock_gettime(CLOCK_REALTIME, &now); - now.tv_nsec -= 10000000; + now.tv_nsec -= rate * 1000000; if (now.tv_nsec < 0) { now.tv_sec -= 1; now.tv_nsec += 1000000000; @@ -528,7 +533,7 @@ static int runes_window_backend_check_recent(RunesTerm *t) if (now.tv_sec < w->last_redraw.tv_sec || (now.tv_sec == w->last_redraw.tv_sec && now.tv_nsec < w->last_redraw.tv_nsec)) { if (!w->delaying) { runes_loop_timer_set( - t->loop, 10, 0, t, runes_window_backend_delay_cb); + t->loop, rate, 0, t, runes_window_backend_delay_cb); w->delaying = 1; } return 1; -- cgit v1.2.3-54-g00ecf