aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-10-23 17:34:52 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2016-10-23 17:34:52 +0200
commit6928184a3d59b8a1fcf6f5349e76c342a57409b5 (patch)
tree225fc25c8fe0cbe966bddc84c6918aa4cf4ab880
parentf7155f3919317d5592a66bfdf1343836f77be929 (diff)
downloadxK-6928184a3d59b8a1fcf6f5349e76c342a57409b5.tar.gz
xK-6928184a3d59b8a1fcf6f5349e76c342a57409b5.tar.xz
xK-6928184a3d59b8a1fcf6f5349e76c342a57409b5.zip
degesch: defer prompt refreshing
Now that we do it each time we receive a message from the server.
-rw-r--r--degesch.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/degesch.c b/degesch.c
index adc2c3e..4eabdeb 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1977,6 +1977,7 @@ struct app_context
struct input *input; ///< User interface
+ struct poller_idle prompt_event; ///< Deferred prompt refresh
struct poller_idle input_event; ///< Pending input event
struct str_vector pending_input; ///< Pending input lines
@@ -2107,7 +2108,14 @@ app_context_free (struct app_context *self)
free (self->editor_filename);
}
-static void refresh_prompt (struct app_context *ctx);
+static void
+refresh_prompt (struct app_context *ctx)
+{
+ // XXX: the need for this conditional could probably be resolved
+ // by some clever reordering
+ if (ctx->prompt_event.poller)
+ poller_idle_set (&ctx->prompt_event);
+}
// --- Configuration -----------------------------------------------------------
@@ -5860,10 +5868,10 @@ input_maybe_set_prompt (struct input *self, char *new_prompt)
CALL_ (self, set_prompt, new_prompt);
}
-// TODO: do this in an idle task so as to not call this unnecessarily
static void
-refresh_prompt (struct app_context *ctx)
+on_refresh_prompt (struct app_context *ctx)
{
+ poller_idle_reset (&ctx->prompt_event);
bool have_attributes = !!get_attribute_printer (stdout);
struct str prompt;
@@ -13290,6 +13298,10 @@ init_poller_events (struct app_context *ctx)
ctx->autoaway_tmr.dispatcher = (poller_timer_fn) on_autoaway_timer;
ctx->autoaway_tmr.user_data = ctx;
+ poller_idle_init (&ctx->prompt_event, &ctx->poller);
+ ctx->prompt_event.dispatcher = (poller_idle_fn) on_refresh_prompt;
+ ctx->prompt_event.user_data = ctx;
+
poller_idle_init (&ctx->input_event, &ctx->poller);
ctx->input_event.dispatcher = (poller_idle_fn) on_pending_input;
ctx->input_event.user_data = ctx;
@@ -13528,7 +13540,7 @@ main (int argc, char *argv[])
config_schema_call_changed (ctx.config.root);
// Initialize input so that we can switch to new buffers
- refresh_prompt (&ctx);
+ on_refresh_prompt (&ctx);
ctx.input->add_functions = input_add_functions;
CALL_ (ctx.input, start, argv[0]);
toggle_bracketed_paste (true);