diff options
-rw-r--r-- | sway/commands.c | 4 | ||||
-rw-r--r-- | sway/commands/input.c | 7 | ||||
-rw-r--r-- | sway/config.c | 68 | ||||
-rw-r--r-- | sway/main.c | 4 |
4 files changed, 78 insertions, 5 deletions
diff --git a/sway/commands.c b/sway/commands.c index b0078a46..c1c6dc5d 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -70,8 +70,10 @@ void apply_input_config(struct input_config *input) { | |||
70 | list_add(config->input_configs, input); | 70 | list_add(config->input_configs, input); |
71 | } | 71 | } |
72 | 72 | ||
73 | struct input_config *old_input_config = current_input_config; | ||
73 | current_input_config = input; | 74 | current_input_config = input; |
74 | sway_input_manager_apply_input_config(input_manager, input); | 75 | sway_input_manager_apply_input_config(input_manager, input); |
76 | current_input_config = old_input_config; | ||
75 | } | 77 | } |
76 | 78 | ||
77 | void apply_seat_config(struct seat_config *seat) { | 79 | void apply_seat_config(struct seat_config *seat) { |
@@ -195,7 +197,7 @@ static struct cmd_handler *find_handler(char *line, enum cmd_status block) { | |||
195 | struct cmd_results *handle_command(char *_exec) { | 197 | struct cmd_results *handle_command(char *_exec) { |
196 | // Even though this function will process multiple commands we will only | 198 | // Even though this function will process multiple commands we will only |
197 | // return the last error, if any (for now). (Since we have access to an | 199 | // return the last error, if any (for now). (Since we have access to an |
198 | // error string we could e.g. concatonate all errors there.) | 200 | // error string we could e.g. concatenate all errors there.) |
199 | struct cmd_results *results = NULL; | 201 | struct cmd_results *results = NULL; |
200 | char *exec = strdup(_exec); | 202 | char *exec = strdup(_exec); |
201 | char *head = exec; | 203 | char *head = exec; |
diff --git a/sway/commands/input.c b/sway/commands/input.c index ccb1d276..edf45e4c 100644 --- a/sway/commands/input.c +++ b/sway/commands/input.c | |||
@@ -24,7 +24,11 @@ struct cmd_results *cmd_input(int argc, char **argv) { | |||
24 | char **argv_new = argv+2; | 24 | char **argv_new = argv+2; |
25 | 25 | ||
26 | struct cmd_results *res; | 26 | struct cmd_results *res; |
27 | struct input_config *old_input_config = current_input_config; | ||
27 | current_input_config = new_input_config(argv[0]); | 28 | current_input_config = new_input_config(argv[0]); |
29 | if (!current_input_config) { | ||
30 | return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config"); | ||
31 | } | ||
28 | if (strcasecmp("accel_profile", argv[1]) == 0) { | 32 | if (strcasecmp("accel_profile", argv[1]) == 0) { |
29 | res = input_cmd_accel_profile(argc_new, argv_new); | 33 | res = input_cmd_accel_profile(argc_new, argv_new); |
30 | } else if (strcasecmp("click_method", argv[1]) == 0) { | 34 | } else if (strcasecmp("click_method", argv[1]) == 0) { |
@@ -60,6 +64,7 @@ struct cmd_results *cmd_input(int argc, char **argv) { | |||
60 | } else { | 64 | } else { |
61 | res = cmd_results_new(CMD_INVALID, "input <device>", "Unknown command %s", argv[1]); | 65 | res = cmd_results_new(CMD_INVALID, "input <device>", "Unknown command %s", argv[1]); |
62 | } | 66 | } |
63 | current_input_config = NULL; | 67 | free_input_config(current_input_config); |
68 | current_input_config = old_input_config; | ||
64 | return res; | 69 | return res; |
65 | } | 70 | } |
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 | ||
32 | struct sway_config *config = NULL; | 32 | struct sway_config *config = NULL; |
33 | 33 | ||
34 | static 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 | |||
34 | void free_config(struct sway_config *config) { | 56 | void 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 | ||
38 | static void config_defaults(struct sway_config *config) { | 100 | static 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; |
diff --git a/sway/main.c b/sway/main.c index c18e2677..f2f24be3 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -380,7 +380,7 @@ int main(int argc, char **argv) { | |||
380 | // prevent ipc from crashing sway | 380 | // prevent ipc from crashing sway |
381 | signal(SIGPIPE, SIG_IGN); | 381 | signal(SIGPIPE, SIG_IGN); |
382 | 382 | ||
383 | wlr_log(L_INFO, "Starting sway version " SWAY_VERSION "\n"); | 383 | wlr_log(L_INFO, "Starting sway version " SWAY_VERSION); |
384 | 384 | ||
385 | init_layout(); | 385 | init_layout(); |
386 | 386 | ||
@@ -414,6 +414,8 @@ int main(int argc, char **argv) { | |||
414 | server_run(&server); | 414 | server_run(&server); |
415 | } | 415 | } |
416 | 416 | ||
417 | wlr_log(L_INFO, "Shutting down sway"); | ||
418 | |||
417 | server_fini(&server); | 419 | server_fini(&server); |
418 | 420 | ||
419 | ipc_terminate(); | 421 | ipc_terminate(); |