From 3827d3758c2b5150c8eeb0eaa2d5759fbbcdb77c Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 15 Feb 2012 21:02:40 +0000 Subject: [PATCH] Render only once for all matching assignments (Thanks rami) Fixes: #608 --- src/assignments.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/assignments.c b/src/assignments.c index eae87272..09793c38 100644 --- a/src/assignments.c +++ b/src/assignments.c @@ -17,6 +17,8 @@ void run_assignments(i3Window *window) { DLOG("Checking if any assignments match this window\n"); + bool needs_tree_render = false; + /* Check if any assignments match */ Assignment *current; TAILQ_FOREACH(current, &assignments, assignments) { @@ -45,7 +47,7 @@ void run_assignments(i3Window *window) { free(full_command); if (command_output->needs_tree_render) - tree_render(); + needs_tree_render = true; free(command_output->json_output); } @@ -55,6 +57,10 @@ void run_assignments(i3Window *window) { window->ran_assignments = srealloc(window->ran_assignments, sizeof(Assignment*) * window->nr_assignments); window->ran_assignments[window->nr_assignments-1] = current; } + + /* If any of the commands required re-rendering, we will do that now. */ + if (needs_tree_render) + tree_render(); } /* -- 2.39.5