Render only once for all matching assignments (Thanks rami)

Fixes: #608
This commit is contained in:
Michael Stapelberg 2012-02-15 21:02:40 +00:00
parent e114b3dba2
commit 3827d3758c
1 changed files with 7 additions and 1 deletions

View File

@ -17,6 +17,8 @@
void run_assignments(i3Window *window) { void run_assignments(i3Window *window) {
DLOG("Checking if any assignments match this window\n"); DLOG("Checking if any assignments match this window\n");
bool needs_tree_render = false;
/* Check if any assignments match */ /* Check if any assignments match */
Assignment *current; Assignment *current;
TAILQ_FOREACH(current, &assignments, assignments) { TAILQ_FOREACH(current, &assignments, assignments) {
@ -45,7 +47,7 @@ void run_assignments(i3Window *window) {
free(full_command); free(full_command);
if (command_output->needs_tree_render) if (command_output->needs_tree_render)
tree_render(); needs_tree_render = true;
free(command_output->json_output); 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 = srealloc(window->ran_assignments, sizeof(Assignment*) * window->nr_assignments);
window->ran_assignments[window->nr_assignments-1] = current; 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();
} }
/* /*