aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/config.h8
-rw-r--r--include/sway/input/input-manager.h1
-rw-r--r--sway/commands.c3
-rw-r--r--sway/commands/input.c28
-rw-r--r--sway/commands/input/accel_profile.c2
-rw-r--r--sway/commands/input/click_method.c4
-rw-r--r--sway/commands/input/drag_lock.c2
-rw-r--r--sway/commands/input/dwt.c2
-rw-r--r--sway/commands/input/events.c6
-rw-r--r--sway/commands/input/left_handed.c2
-rw-r--r--sway/commands/input/middle_emulation.c2
-rw-r--r--sway/commands/input/natural_scroll.c2
-rw-r--r--sway/commands/input/pointer_accel.c2
-rw-r--r--sway/commands/input/scroll_method.c2
-rw-r--r--sway/commands/input/tap.c3
-rw-r--r--sway/commands/input/xkb_layout.c3
-rw-r--r--sway/commands/input/xkb_model.c3
-rw-r--r--sway/commands/input/xkb_options.c3
-rw-r--r--sway/commands/input/xkb_rules.c3
-rw-r--r--sway/commands/input/xkb_variant.c3
-rw-r--r--sway/config.c10
21 files changed, 69 insertions, 25 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index 0a9c4595..1ab96b51 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -350,6 +350,11 @@ struct sway_config {
350 list_t *command_policies; 350 list_t *command_policies;
351 list_t *feature_policies; 351 list_t *feature_policies;
352 list_t *ipc_policies; 352 list_t *ipc_policies;
353
354 // Context for command handlers
355 struct {
356 struct input_config *input_config;
357 } handler_context;
353}; 358};
354 359
355void pid_workspace_add(struct pid_workspace *pw); 360void pid_workspace_add(struct pid_workspace *pw);
@@ -375,6 +380,9 @@ bool read_config(FILE *file, struct sway_config *config);
375 * Free config struct 380 * Free config struct
376 */ 381 */
377void free_config(struct sway_config *config); 382void free_config(struct sway_config *config);
383
384void config_clear_handler_context(struct sway_config *config);
385
378void free_sway_variable(struct sway_variable *var); 386void free_sway_variable(struct sway_variable *var);
379/** 387/**
380 * Does variable replacement for a string based on the config's currently loaded variables. 388 * Does variable replacement for a string based on the config's currently loaded variables.
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h
index 53064eed..8388f930 100644
--- a/include/sway/input/input-manager.h
+++ b/include/sway/input/input-manager.h
@@ -5,7 +5,6 @@
5#include "sway/config.h" 5#include "sway/config.h"
6#include "list.h" 6#include "list.h"
7 7
8extern struct input_config *current_input_config;
9extern struct seat_config *current_seat_config; 8extern struct seat_config *current_seat_config;
10 9
11/** 10/**
diff --git a/sway/commands.c b/sway/commands.c
index 1005cf68..fd2e1514 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -70,10 +70,7 @@ 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;
74 current_input_config = input;
75 sway_input_manager_apply_input_config(input_manager, input); 73 sway_input_manager_apply_input_config(input_manager, input);
76 current_input_config = old_input_config;
77} 74}
78 75
79void apply_seat_config(struct seat_config *seat) { 76void apply_seat_config(struct seat_config *seat) {
diff --git a/sway/commands/input.c b/sway/commands/input.c
index 5ea39f62..5de65621 100644
--- a/sway/commands/input.c
+++ b/sway/commands/input.c
@@ -11,8 +11,12 @@ struct cmd_results *cmd_input(int argc, char **argv) {
11 } 11 }
12 12
13 if (config->reading && strcmp("{", argv[1]) == 0) { 13 if (config->reading && strcmp("{", argv[1]) == 0) {
14 current_input_config = new_input_config(argv[0]); 14 free_input_config(config->handler_context.input_config);
15 wlr_log(L_DEBUG, "entering input block: %s", current_input_config->identifier); 15 config->handler_context.input_config = new_input_config(argv[0]);
16 if (!config->handler_context.input_config) {
17 return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config");
18 }
19 wlr_log(L_DEBUG, "entering input block: %s", argv[0]);
16 return cmd_results_new(CMD_BLOCK_INPUT, NULL, NULL); 20 return cmd_results_new(CMD_BLOCK_INPUT, NULL, NULL);
17 } 21 }
18 22
@@ -20,15 +24,16 @@ struct cmd_results *cmd_input(int argc, char **argv) {
20 return error; 24 return error;
21 } 25 }
22 26
27 bool has_context = (config->handler_context.input_config != NULL);
28 if (!has_context) {
29 // caller did not give a context so create one just for this command
30 config->handler_context.input_config = new_input_config(argv[0]);
31 }
32
23 int argc_new = argc-2; 33 int argc_new = argc-2;
24 char **argv_new = argv+2; 34 char **argv_new = argv+2;
25 35
26 struct cmd_results *res; 36 struct cmd_results *res;
27 struct input_config *old_input_config = current_input_config;
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 }
32 if (strcasecmp("accel_profile", argv[1]) == 0) { 37 if (strcasecmp("accel_profile", argv[1]) == 0) {
33 res = input_cmd_accel_profile(argc_new, argv_new); 38 res = input_cmd_accel_profile(argc_new, argv_new);
34 } else if (strcasecmp("click_method", argv[1]) == 0) { 39 } else if (strcasecmp("click_method", argv[1]) == 0) {
@@ -64,7 +69,12 @@ struct cmd_results *cmd_input(int argc, char **argv) {
64 } else { 69 } else {
65 res = cmd_results_new(CMD_INVALID, "input <device>", "Unknown command %s", argv[1]); 70 res = cmd_results_new(CMD_INVALID, "input <device>", "Unknown command %s", argv[1]);
66 } 71 }
67 free_input_config(current_input_config); 72
68 current_input_config = old_input_config; 73 if (!has_context) {
74 // clean up the context we created earlier
75 free_input_config(config->handler_context.input_config);
76 config->handler_context.input_config = NULL;
77 }
78
69 return res; 79 return res;
70} 80}
diff --git a/sway/commands/input/accel_profile.c b/sway/commands/input/accel_profile.c
index f72b7d48..37d6e133 100644
--- a/sway/commands/input/accel_profile.c
+++ b/sway/commands/input/accel_profile.c
@@ -9,6 +9,8 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
9 if ((error = checkarg(argc, "accel_profile", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "accel_profile", EXPECTED_AT_LEAST, 1))) {
10 return error; 10 return error;
11 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
12 if (!current_input_config) { 14 if (!current_input_config) {
13 return cmd_results_new(CMD_FAILURE, "accel_profile", 15 return cmd_results_new(CMD_FAILURE, "accel_profile",
14 "No input device defined."); 16 "No input device defined.");
diff --git a/sway/commands/input/click_method.c b/sway/commands/input/click_method.c
index 22eb15f7..8f1f0aa7 100644
--- a/sway/commands/input/click_method.c
+++ b/sway/commands/input/click_method.c
@@ -6,12 +6,12 @@
6#include "log.h" 6#include "log.h"
7 7
8struct cmd_results *input_cmd_click_method(int argc, char **argv) { 8struct cmd_results *input_cmd_click_method(int argc, char **argv) {
9 wlr_log(L_DEBUG, "click_method for device: %d %s",
10 current_input_config==NULL, current_input_config->identifier);
11 struct cmd_results *error = NULL; 9 struct cmd_results *error = NULL;
12 if ((error = checkarg(argc, "click_method", EXPECTED_AT_LEAST, 1))) { 10 if ((error = checkarg(argc, "click_method", EXPECTED_AT_LEAST, 1))) {
13 return error; 11 return error;
14 } 12 }
13 struct input_config *current_input_config =
14 config->handler_context.input_config;
15 if (!current_input_config) { 15 if (!current_input_config) {
16 return cmd_results_new(CMD_FAILURE, "click_method", 16 return cmd_results_new(CMD_FAILURE, "click_method",
17 "No input device defined."); 17 "No input device defined.");
diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c
index 1783978a..8273a7d4 100644
--- a/sway/commands/input/drag_lock.c
+++ b/sway/commands/input/drag_lock.c
@@ -9,6 +9,8 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
9 if ((error = checkarg(argc, "drag_lock", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "drag_lock", EXPECTED_AT_LEAST, 1))) {
10 return error; 10 return error;
11 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
12 if (!current_input_config) { 14 if (!current_input_config) {
13 return cmd_results_new(CMD_FAILURE, 15 return cmd_results_new(CMD_FAILURE,
14 "drag_lock", "No input device defined."); 16 "drag_lock", "No input device defined.");
diff --git a/sway/commands/input/dwt.c b/sway/commands/input/dwt.c
index 8108a110..995a2f47 100644
--- a/sway/commands/input/dwt.c
+++ b/sway/commands/input/dwt.c
@@ -9,6 +9,8 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
9 if ((error = checkarg(argc, "dwt", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "dwt", EXPECTED_AT_LEAST, 1))) {
10 return error; 10 return error;
11 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
12 if (!current_input_config) { 14 if (!current_input_config) {
13 return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined.");
14 } 16 }
diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c
index a1bfbacd..2217f5ce 100644
--- a/sway/commands/input/events.c
+++ b/sway/commands/input/events.c
@@ -6,16 +6,18 @@
6#include "log.h" 6#include "log.h"
7 7
8struct cmd_results *input_cmd_events(int argc, char **argv) { 8struct cmd_results *input_cmd_events(int argc, char **argv) {
9 wlr_log(L_DEBUG, "events for device: %s",
10 current_input_config->identifier);
11 struct cmd_results *error = NULL; 9 struct cmd_results *error = NULL;
12 if ((error = checkarg(argc, "events", EXPECTED_AT_LEAST, 1))) { 10 if ((error = checkarg(argc, "events", EXPECTED_AT_LEAST, 1))) {
13 return error; 11 return error;
14 } 12 }
13 struct input_config *current_input_config =
14 config->handler_context.input_config;
15 if (!current_input_config) { 15 if (!current_input_config) {
16 return cmd_results_new(CMD_FAILURE, "events", 16 return cmd_results_new(CMD_FAILURE, "events",
17 "No input device defined."); 17 "No input device defined.");
18 } 18 }
19 wlr_log(L_DEBUG, "events for device: %s",
20 current_input_config->identifier);
19 struct input_config *new_config = 21 struct input_config *new_config =
20 new_input_config(current_input_config->identifier); 22 new_input_config(current_input_config->identifier);
21 23
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c
index 35740df3..94b8e03e 100644
--- a/sway/commands/input/left_handed.c
+++ b/sway/commands/input/left_handed.c
@@ -9,6 +9,8 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
9 if ((error = checkarg(argc, "left_handed", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "left_handed", EXPECTED_AT_LEAST, 1))) {
10 return error; 10 return error;
11 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
12 if (!current_input_config) { 14 if (!current_input_config) {
13 return cmd_results_new(CMD_FAILURE, "left_handed", 15 return cmd_results_new(CMD_FAILURE, "left_handed",
14 "No input device defined."); 16 "No input device defined.");
diff --git a/sway/commands/input/middle_emulation.c b/sway/commands/input/middle_emulation.c
index 7bc08ae6..a551fd51 100644
--- a/sway/commands/input/middle_emulation.c
+++ b/sway/commands/input/middle_emulation.c
@@ -9,6 +9,8 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
9 if ((error = checkarg(argc, "middle_emulation", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "middle_emulation", EXPECTED_AT_LEAST, 1))) {
10 return error; 10 return error;
11 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
12 if (!current_input_config) { 14 if (!current_input_config) {
13 return cmd_results_new(CMD_FAILURE, "middle_emulation", 15 return cmd_results_new(CMD_FAILURE, "middle_emulation",
14 "No input device defined."); 16 "No input device defined.");
diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c
index a7dcdc2c..c4e19b78 100644
--- a/sway/commands/input/natural_scroll.c
+++ b/sway/commands/input/natural_scroll.c
@@ -9,6 +9,8 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
9 if ((error = checkarg(argc, "natural_scroll", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "natural_scroll", EXPECTED_AT_LEAST, 1))) {
10 return error; 10 return error;
11 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
12 if (!current_input_config) { 14 if (!current_input_config) {
13 return cmd_results_new(CMD_FAILURE, "natural_scoll", 15 return cmd_results_new(CMD_FAILURE, "natural_scoll",
14 "No input device defined."); 16 "No input device defined.");
diff --git a/sway/commands/input/pointer_accel.c b/sway/commands/input/pointer_accel.c
index d2261a63..171063aa 100644
--- a/sway/commands/input/pointer_accel.c
+++ b/sway/commands/input/pointer_accel.c
@@ -9,6 +9,8 @@ struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
9 if ((error = checkarg(argc, "pointer_accel", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "pointer_accel", EXPECTED_AT_LEAST, 1))) {
10 return error; 10 return error;
11 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
12 if (!current_input_config) { 14 if (!current_input_config) {
13 return cmd_results_new(CMD_FAILURE, 15 return cmd_results_new(CMD_FAILURE,
14 "pointer_accel", "No input device defined."); 16 "pointer_accel", "No input device defined.");
diff --git a/sway/commands/input/scroll_method.c b/sway/commands/input/scroll_method.c
index 035262cf..0a1c57ac 100644
--- a/sway/commands/input/scroll_method.c
+++ b/sway/commands/input/scroll_method.c
@@ -9,6 +9,8 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
9 if ((error = checkarg(argc, "scroll_method", EXPECTED_AT_LEAST, 1))) { 9 if ((error = checkarg(argc, "scroll_method", EXPECTED_AT_LEAST, 1))) {
10 return error; 10 return error;
11 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
12 if (!current_input_config) { 14 if (!current_input_config) {
13 return cmd_results_new(CMD_FAILURE, "scroll_method", 15 return cmd_results_new(CMD_FAILURE, "scroll_method",
14 "No input device defined."); 16 "No input device defined.");
diff --git a/sway/commands/input/tap.c b/sway/commands/input/tap.c
index ecab9a5b..e7f03058 100644
--- a/sway/commands/input/tap.c
+++ b/sway/commands/input/tap.c
@@ -6,11 +6,12 @@
6#include "log.h" 6#include "log.h"
7 7
8struct cmd_results *input_cmd_tap(int argc, char **argv) { 8struct cmd_results *input_cmd_tap(int argc, char **argv) {
9 wlr_log(L_DEBUG, "tap for device: %s", current_input_config->identifier);
10 struct cmd_results *error = NULL; 9 struct cmd_results *error = NULL;
11 if ((error = checkarg(argc, "tap", EXPECTED_AT_LEAST, 1))) { 10 if ((error = checkarg(argc, "tap", EXPECTED_AT_LEAST, 1))) {
12 return error; 11 return error;
13 } 12 }
13 struct input_config *current_input_config =
14 config->handler_context.input_config;
14 if (!current_input_config) { 15 if (!current_input_config) {
15 return cmd_results_new(CMD_FAILURE, "tap", "No input device defined."); 16 return cmd_results_new(CMD_FAILURE, "tap", "No input device defined.");
16 } 17 }
diff --git a/sway/commands/input/xkb_layout.c b/sway/commands/input/xkb_layout.c
index 25db1a33..867e65d3 100644
--- a/sway/commands/input/xkb_layout.c
+++ b/sway/commands/input/xkb_layout.c
@@ -5,11 +5,12 @@
5#include "log.h" 5#include "log.h"
6 6
7struct cmd_results *input_cmd_xkb_layout(int argc, char **argv) { 7struct cmd_results *input_cmd_xkb_layout(int argc, char **argv) {
8 wlr_log(L_DEBUG, "xkb layout for device: %s", current_input_config->identifier);
9 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "xkb_layout", EXPECTED_EQUAL_TO, 1))) { 9 if ((error = checkarg(argc, "xkb_layout", EXPECTED_EQUAL_TO, 1))) {
11 return error; 10 return error;
12 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
13 if (!current_input_config) { 14 if (!current_input_config) {
14 return cmd_results_new(CMD_FAILURE, "xkb_layout", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "xkb_layout", "No input device defined.");
15 } 16 }
diff --git a/sway/commands/input/xkb_model.c b/sway/commands/input/xkb_model.c
index 819b796b..e8c8e04e 100644
--- a/sway/commands/input/xkb_model.c
+++ b/sway/commands/input/xkb_model.c
@@ -5,11 +5,12 @@
5#include "log.h" 5#include "log.h"
6 6
7struct cmd_results *input_cmd_xkb_model(int argc, char **argv) { 7struct cmd_results *input_cmd_xkb_model(int argc, char **argv) {
8 wlr_log(L_DEBUG, "xkb model for device: %s", current_input_config->identifier);
9 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "xkb_model", EXPECTED_EQUAL_TO, 1))) { 9 if ((error = checkarg(argc, "xkb_model", EXPECTED_EQUAL_TO, 1))) {
11 return error; 10 return error;
12 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
13 if (!current_input_config) { 14 if (!current_input_config) {
14 return cmd_results_new(CMD_FAILURE, "xkb_model", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "xkb_model", "No input device defined.");
15 } 16 }
diff --git a/sway/commands/input/xkb_options.c b/sway/commands/input/xkb_options.c
index ff5f83ec..e9ddd6e3 100644
--- a/sway/commands/input/xkb_options.c
+++ b/sway/commands/input/xkb_options.c
@@ -5,11 +5,12 @@
5#include "log.h" 5#include "log.h"
6 6
7struct cmd_results *input_cmd_xkb_options(int argc, char **argv) { 7struct cmd_results *input_cmd_xkb_options(int argc, char **argv) {
8 wlr_log(L_DEBUG, "xkb options for device: %s", current_input_config->identifier);
9 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "xkb_options", EXPECTED_EQUAL_TO, 1))) { 9 if ((error = checkarg(argc, "xkb_options", EXPECTED_EQUAL_TO, 1))) {
11 return error; 10 return error;
12 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
13 if (!current_input_config) { 14 if (!current_input_config) {
14 return cmd_results_new(CMD_FAILURE, "xkb_options", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "xkb_options", "No input device defined.");
15 } 16 }
diff --git a/sway/commands/input/xkb_rules.c b/sway/commands/input/xkb_rules.c
index aafe0003..926d0ac1 100644
--- a/sway/commands/input/xkb_rules.c
+++ b/sway/commands/input/xkb_rules.c
@@ -5,11 +5,12 @@
5#include "log.h" 5#include "log.h"
6 6
7struct cmd_results *input_cmd_xkb_rules(int argc, char **argv) { 7struct cmd_results *input_cmd_xkb_rules(int argc, char **argv) {
8 wlr_log(L_DEBUG, "xkb rules for device: %s", current_input_config->identifier);
9 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "xkb_rules", EXPECTED_EQUAL_TO, 1))) { 9 if ((error = checkarg(argc, "xkb_rules", EXPECTED_EQUAL_TO, 1))) {
11 return error; 10 return error;
12 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
13 if (!current_input_config) { 14 if (!current_input_config) {
14 return cmd_results_new(CMD_FAILURE, "xkb_rules", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "xkb_rules", "No input device defined.");
15 } 16 }
diff --git a/sway/commands/input/xkb_variant.c b/sway/commands/input/xkb_variant.c
index 89a61fdc..0e3ffd41 100644
--- a/sway/commands/input/xkb_variant.c
+++ b/sway/commands/input/xkb_variant.c
@@ -5,11 +5,12 @@
5#include "log.h" 5#include "log.h"
6 6
7struct cmd_results *input_cmd_xkb_variant(int argc, char **argv) { 7struct cmd_results *input_cmd_xkb_variant(int argc, char **argv) {
8 wlr_log(L_DEBUG, "xkb variant for device: %s", current_input_config->identifier);
9 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "xkb_variant", EXPECTED_EQUAL_TO, 1))) { 9 if ((error = checkarg(argc, "xkb_variant", EXPECTED_EQUAL_TO, 1))) {
11 return error; 10 return error;
12 } 11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
13 if (!current_input_config) { 14 if (!current_input_config) {
14 return cmd_results_new(CMD_FAILURE, "xkb_variant", "No input device defined."); 15 return cmd_results_new(CMD_FAILURE, "xkb_variant", "No input device defined.");
15 } 16 }
diff --git a/sway/config.c b/sway/config.c
index 5ec45b17..54357625 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -54,6 +54,8 @@ static void free_mode(struct sway_mode *mode) {
54} 54}
55 55
56void free_config(struct sway_config *config) { 56void free_config(struct sway_config *config) {
57 config_clear_handler_context(config);
58
57 int i; 59 int i;
58 60
59 if (!config) { 61 if (!config) {
@@ -480,6 +482,11 @@ bool load_include_configs(const char *path, struct sway_config *config) {
480 return true; 482 return true;
481} 483}
482 484
485void config_clear_handler_context(struct sway_config *config) {
486 free_input_config(config->handler_context.input_config);
487
488 memset(&config->handler_context, 0, sizeof(config->handler_context));
489}
483 490
484bool read_config(FILE *file, struct sway_config *config) { 491bool read_config(FILE *file, struct sway_config *config) {
485 bool success = true; 492 bool success = true;
@@ -592,8 +599,6 @@ bool read_config(FILE *file, struct sway_config *config) {
592 599
593 case CMD_BLOCK_INPUT: 600 case CMD_BLOCK_INPUT:
594 wlr_log(L_DEBUG, "End of input block"); 601 wlr_log(L_DEBUG, "End of input block");
595 free_input_config(current_input_config);
596 current_input_config = NULL;
597 block = CMD_BLOCK_END; 602 block = CMD_BLOCK_END;
598 break; 603 break;
599 604
@@ -635,6 +640,7 @@ bool read_config(FILE *file, struct sway_config *config) {
635 640
636 default:; 641 default:;
637 } 642 }
643 config_clear_handler_context(config);
638 default:; 644 default:;
639 } 645 }
640 free(line); 646 free(line);