*/
void got_output_reply(char *reply) {
DLOG("Clearing old output configuration...\n");
- i3_output *o_walk;
- SLIST_FOREACH(o_walk, outputs, slist) {
- destroy_window(o_walk);
- }
- FREE_SLIST(outputs, i3_output);
+ free_outputs();
DLOG("Parsing outputs JSON...\n");
parse_outputs_json(reply);
DLOG("Reconfiguring windows...\n");
reconfig_windows(false);
+ i3_output *o_walk;
SLIST_FOREACH(o_walk, outputs, slist) {
kick_tray_clients(o_walk);
}
return 1;
}
+static void clear_output(i3_output *output) {
+ FREE(output->name);
+ FREE(output->workspaces);
+ FREE(output->trayclients);
+}
+
/*
* We hit the end of a map (rect or a new output)
*
if (!handle_output) {
DLOG("Ignoring output \"%s\", not configured to handle it.\n",
params->outputs_walk->name);
- FREE(params->outputs_walk->name);
- FREE(params->outputs_walk->workspaces);
- FREE(params->outputs_walk->trayclients);
+ clear_output(params->outputs_walk);
FREE(params->outputs_walk);
FREE(params->cur_key);
return 1;
target->primary = params->outputs_walk->primary;
target->ws = params->outputs_walk->ws;
target->rect = params->outputs_walk->rect;
+
+ clear_output(params->outputs_walk);
+ FREE(params->outputs_walk);
}
return 1;
}
*/
void parse_outputs_json(char *json) {
struct outputs_json_params params;
-
params.outputs_walk = NULL;
params.cur_key = NULL;
params.json = json;
yajl_free(handle);
}
+/*
+ * free() all outputs data structures.
+ *
+ */
+void free_outputs(void) {
+ free_workspaces();
+
+ i3_output *outputs_walk;
+ if (outputs == NULL) {
+ return;
+ }
+ SLIST_FOREACH(outputs_walk, outputs, slist) {
+ destroy_window(outputs_walk);
+ if (outputs_walk->trayclients != NULL && !TAILQ_EMPTY(outputs_walk->trayclients)) {
+ FREE_TAILQ(outputs_walk->trayclients, trayclient);
+ }
+ clear_output(outputs_walk);
+ }
+ FREE_SLIST(outputs, i3_output);
+}
+
/*
* Returns the output with the given name
*
*
*/
void clean_xcb(void) {
- i3_output *o_walk;
- free_workspaces();
- SLIST_FOREACH(o_walk, outputs, slist) {
- destroy_window(o_walk);
- FREE(o_walk->trayclients);
- FREE(o_walk->workspaces);
- FREE(o_walk->name);
- }
- FREE_SLIST(outputs, i3_output);
- FREE(outputs);
+ free_outputs();
free_font();