summaryrefslogtreecommitdiffstats
path: root/swaybar/state.c
blob: 900842e006898e3f2ffa1f7ae1705a949c71422d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdlib.h>

#include "list.h"
#include "config.h"
#include "status_line.h"
#include "state.h"

struct swaybar_state *init_state() {
	struct swaybar_state *state = calloc(1, sizeof(struct swaybar_state));
	state->config = init_config();
	state->status = init_status_line();
	state->output = malloc(sizeof(struct output));
	state->output->window = NULL;
	state->output->registry = NULL;
	state->output->workspaces = create_list();

	return state;
}

void free_workspace(void *item) {
	if (!item) {
		return;
	}
	struct workspace *ws = (struct workspace *)item;
	if (ws->name) {
		free(ws->name);
	}
	free(ws);
}