aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c68
1 files changed, 66 insertions, 2 deletions
diff --git a/sway/config.c b/sway/config.c
index 312e0779..627ed94f 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -31,8 +31,70 @@
31 31
32struct sway_config *config = NULL; 32struct sway_config *config = NULL;
33 33
34static void free_mode(struct sway_mode *mode) {
35 int i;
36
37 if (!mode) {
38 return;
39 }
40 free(mode->name);
41 if (mode->keysym_bindings) {
42 for (i = 0; i < mode->keysym_bindings->length; i++) {
43 free_sway_binding(mode->keysym_bindings->items[i]);
44 }
45 list_free(mode->keysym_bindings);
46 }
47 if (mode->keycode_bindings) {
48 for (i = 0; i < mode->keycode_bindings->length; i++) {
49 free_sway_binding(mode->keycode_bindings->items[i]);
50 }
51 list_free(mode->keycode_bindings);
52 }
53 free(mode);
54}
55
34void free_config(struct sway_config *config) { 56void free_config(struct sway_config *config) {
35 // TODO 57 int i;
58
59 if (!config) {
60 return;
61 }
62
63 // TODO: handle all currently unhandled lists as we add implementations
64 list_free(config->symbols);
65 if (config->modes) {
66 for (i = 0; i < config->modes->length; i++) {
67 free_mode(config->modes->items[i]);
68 }
69 list_free(config->modes);
70 }
71 list_free(config->bars);
72 list_free(config->cmd_queue);
73 list_free(config->workspace_outputs);
74 list_free(config->pid_workspaces);
75 list_free(config->output_configs);
76 if (config->input_configs) {
77 for (i = 0; i < config->input_configs->length; i++) {
78 free_input_config(config->input_configs->items[i]);
79 }
80 list_free(config->input_configs);
81 }
82 list_free(config->seat_configs);
83 list_free(config->criteria);
84 list_free(config->no_focus);
85 list_free(config->active_bar_modifiers);
86 list_free(config->config_chain);
87 list_free(config->command_policies);
88 list_free(config->feature_policies);
89 list_free(config->ipc_policies);
90 free(config->current_bar);
91 free(config->floating_scroll_up_cmd);
92 free(config->floating_scroll_down_cmd);
93 free(config->floating_scroll_left_cmd);
94 free(config->floating_scroll_right_cmd);
95 free(config->font);
96 free((char *)config->current_config);
97 free(config);
36} 98}
37 99
38static void config_defaults(struct sway_config *config) { 100static void config_defaults(struct sway_config *config) {
@@ -186,6 +248,7 @@ static char *get_config_path(void) {
186 if (file_exists(path)) { 248 if (file_exists(path)) {
187 return path; 249 return path;
188 } 250 }
251 free(path);
189 } 252 }
190 } 253 }
191 254
@@ -446,7 +509,7 @@ bool read_config(FILE *file, struct sway_config *config) {
446 break; 509 break;
447 510
448 case CMD_DEFER: 511 case CMD_DEFER:
449 sway_log(L_DEBUG, "Defferring command `%s'", line); 512 sway_log(L_DEBUG, "Deferring command `%s'", line);
450 list_add(config->cmd_queue, strdup(line)); 513 list_add(config->cmd_queue, strdup(line));
451 break; 514 break;
452 515
@@ -524,6 +587,7 @@ bool read_config(FILE *file, struct sway_config *config) {
524 587
525 case CMD_BLOCK_INPUT: 588 case CMD_BLOCK_INPUT:
526 sway_log(L_DEBUG, "End of input block"); 589 sway_log(L_DEBUG, "End of input block");
590 free_input_config(current_input_config);
527 current_input_config = NULL; 591 current_input_config = NULL;
528 block = CMD_BLOCK_END; 592 block = CMD_BLOCK_END;
529 break; 593 break;