i3bar: free output data structures
This commit is contained in:
parent
a05663c59e
commit
54c79e4b2f
|
@ -33,6 +33,12 @@ void parse_outputs_json(char* json);
|
||||||
*/
|
*/
|
||||||
void init_outputs(void);
|
void init_outputs(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* free() all outputs data structures.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void free_outputs(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the output with the given name
|
* Returns the output with the given name
|
||||||
*
|
*
|
||||||
|
|
|
@ -64,17 +64,14 @@ void got_subscribe_reply(char *reply) {
|
||||||
*/
|
*/
|
||||||
void got_output_reply(char *reply) {
|
void got_output_reply(char *reply) {
|
||||||
DLOG("Clearing old output configuration...\n");
|
DLOG("Clearing old output configuration...\n");
|
||||||
i3_output *o_walk;
|
free_outputs();
|
||||||
SLIST_FOREACH(o_walk, outputs, slist) {
|
|
||||||
destroy_window(o_walk);
|
|
||||||
}
|
|
||||||
FREE_SLIST(outputs, i3_output);
|
|
||||||
|
|
||||||
DLOG("Parsing outputs JSON...\n");
|
DLOG("Parsing outputs JSON...\n");
|
||||||
parse_outputs_json(reply);
|
parse_outputs_json(reply);
|
||||||
DLOG("Reconfiguring windows...\n");
|
DLOG("Reconfiguring windows...\n");
|
||||||
reconfig_windows(false);
|
reconfig_windows(false);
|
||||||
|
|
||||||
|
i3_output *o_walk;
|
||||||
SLIST_FOREACH(o_walk, outputs, slist) {
|
SLIST_FOREACH(o_walk, outputs, slist) {
|
||||||
kick_tray_clients(o_walk);
|
kick_tray_clients(o_walk);
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,5 @@ int main(int argc, char **argv) {
|
||||||
clean_xcb();
|
clean_xcb();
|
||||||
ev_default_destroy();
|
ev_default_destroy();
|
||||||
|
|
||||||
free_workspaces();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,12 @@ static int outputs_start_map_cb(void *params_) {
|
||||||
return 1;
|
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)
|
* We hit the end of a map (rect or a new output)
|
||||||
*
|
*
|
||||||
|
@ -199,9 +205,7 @@ static int outputs_end_map_cb(void *params_) {
|
||||||
if (!handle_output) {
|
if (!handle_output) {
|
||||||
DLOG("Ignoring output \"%s\", not configured to handle it.\n",
|
DLOG("Ignoring output \"%s\", not configured to handle it.\n",
|
||||||
params->outputs_walk->name);
|
params->outputs_walk->name);
|
||||||
FREE(params->outputs_walk->name);
|
clear_output(params->outputs_walk);
|
||||||
FREE(params->outputs_walk->workspaces);
|
|
||||||
FREE(params->outputs_walk->trayclients);
|
|
||||||
FREE(params->outputs_walk);
|
FREE(params->outputs_walk);
|
||||||
FREE(params->cur_key);
|
FREE(params->cur_key);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -217,6 +221,9 @@ static int outputs_end_map_cb(void *params_) {
|
||||||
target->primary = params->outputs_walk->primary;
|
target->primary = params->outputs_walk->primary;
|
||||||
target->ws = params->outputs_walk->ws;
|
target->ws = params->outputs_walk->ws;
|
||||||
target->rect = params->outputs_walk->rect;
|
target->rect = params->outputs_walk->rect;
|
||||||
|
|
||||||
|
clear_output(params->outputs_walk);
|
||||||
|
FREE(params->outputs_walk);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +267,6 @@ void init_outputs(void) {
|
||||||
*/
|
*/
|
||||||
void parse_outputs_json(char *json) {
|
void parse_outputs_json(char *json) {
|
||||||
struct outputs_json_params params;
|
struct outputs_json_params params;
|
||||||
|
|
||||||
params.outputs_walk = NULL;
|
params.outputs_walk = NULL;
|
||||||
params.cur_key = NULL;
|
params.cur_key = NULL;
|
||||||
params.json = json;
|
params.json = json;
|
||||||
|
@ -286,6 +292,27 @@ void parse_outputs_json(char *json) {
|
||||||
yajl_free(handle);
|
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
|
* Returns the output with the given name
|
||||||
*
|
*
|
||||||
|
|
|
@ -1517,16 +1517,7 @@ void init_tray_colors(void) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void clean_xcb(void) {
|
void clean_xcb(void) {
|
||||||
i3_output *o_walk;
|
free_outputs();
|
||||||
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_font();
|
free_font();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue