diff options
author | 2015-12-14 02:39:24 +0100 | |
---|---|---|
committer | 2015-12-14 12:56:45 +0100 | |
commit | 74152043f4da7182339f181317960aa6cd01cffa (patch) | |
tree | 5baaf0a8650cc376cc53dcacefca00f6af626537 /sway/config.c | |
parent | Fix rendering of borders on workspaces (swaybar) (diff) | |
download | sway-74152043f4da7182339f181317960aa6cd01cffa.tar.gz sway-74152043f4da7182339f181317960aa6cd01cffa.tar.zst sway-74152043f4da7182339f181317960aa6cd01cffa.zip |
Implement 'bar { }' block parsing
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sway/config.c b/sway/config.c index 6c22556f..d5b75adf 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -38,6 +38,14 @@ static void free_mode(struct sway_mode *mode) { | |||
38 | free(mode); | 38 | free(mode); |
39 | } | 39 | } |
40 | 40 | ||
41 | static void free_bar(struct bar_config *bar) { | ||
42 | free(bar->mode); | ||
43 | free(bar->hidden_state); | ||
44 | free(bar->status_command); | ||
45 | free(bar->font); | ||
46 | free(bar); | ||
47 | } | ||
48 | |||
41 | void free_output_config(struct output_config *oc) { | 49 | void free_output_config(struct output_config *oc) { |
42 | free(oc->name); | 50 | free(oc->name); |
43 | free(oc); | 51 | free(oc); |
@@ -61,6 +69,11 @@ static void free_config(struct sway_config *config) { | |||
61 | } | 69 | } |
62 | list_free(config->modes); | 70 | list_free(config->modes); |
63 | 71 | ||
72 | for (i = 0; i < config->bars->length; ++i) { | ||
73 | free_bar(config->bars->items[i]); | ||
74 | } | ||
75 | list_free(config->bars); | ||
76 | |||
64 | free_flat_list(config->cmd_queue); | 77 | free_flat_list(config->cmd_queue); |
65 | 78 | ||
66 | for (i = 0; i < config->workspace_outputs->length; ++i) { | 79 | for (i = 0; i < config->workspace_outputs->length; ++i) { |
@@ -88,6 +101,7 @@ static bool file_exists(const char *path) { | |||
88 | static void config_defaults(struct sway_config *config) { | 101 | static void config_defaults(struct sway_config *config) { |
89 | config->symbols = create_list(); | 102 | config->symbols = create_list(); |
90 | config->modes = create_list(); | 103 | config->modes = create_list(); |
104 | config->bars = create_list(); | ||
91 | config->workspace_outputs = create_list(); | 105 | config->workspace_outputs = create_list(); |
92 | config->criteria = create_list(); | 106 | config->criteria = create_list(); |
93 | config->output_configs = create_list(); | 107 | config->output_configs = create_list(); |
@@ -248,11 +262,26 @@ bool read_config(FILE *file, bool is_active) { | |||
248 | } | 262 | } |
249 | break; | 263 | break; |
250 | 264 | ||
265 | case CMD_BLOCK_BAR: | ||
266 | if (block == CMD_BLOCK_END) { | ||
267 | block = CMD_BLOCK_BAR; | ||
268 | } else { | ||
269 | sway_log(L_ERROR, "Invalid block '%s'", line); | ||
270 | } | ||
271 | break; | ||
272 | |||
251 | case CMD_BLOCK_END: | 273 | case CMD_BLOCK_END: |
252 | switch(block) { | 274 | switch(block) { |
253 | case CMD_BLOCK_MODE: | 275 | case CMD_BLOCK_MODE: |
254 | sway_log(L_DEBUG, "End of mode block"); | 276 | sway_log(L_DEBUG, "End of mode block"); |
255 | config->current_mode = config->modes->items[0]; | 277 | config->current_mode = config->modes->items[0]; |
278 | block = CMD_BLOCK_END; | ||
279 | break; | ||
280 | |||
281 | case CMD_BLOCK_BAR: | ||
282 | sway_log(L_DEBUG, "End of bar block"); | ||
283 | config->current_bar = NULL; | ||
284 | block = CMD_BLOCK_END; | ||
256 | break; | 285 | break; |
257 | 286 | ||
258 | case CMD_BLOCK_END: | 287 | case CMD_BLOCK_END: |