summaryrefslogtreecommitdiffstats
path: root/sway/commands/input/events.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/input/events.c')
-rw-r--r--sway/commands/input/events.c59
1 files changed, 31 insertions, 28 deletions
diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c
index cd2985ee..9405181a 100644
--- a/sway/commands/input/events.c
+++ b/sway/commands/input/events.c
@@ -74,34 +74,36 @@ static void toggle_select_send_events_for_device(struct input_config *ic,
74 ic->send_events = mode_for_name(argv[index % argc]); 74 ic->send_events = mode_for_name(argv[index % argc]);
75} 75}
76 76
77static void toggle_send_events(struct input_config *ic, int argc, char **argv) { 77static void toggle_send_events(int argc, char **argv) {
78 struct sway_input_device *input_device = NULL; 78 struct input_config *ic = config->handler_context.input_config;
79 wl_list_for_each(input_device, &server.input->devices, link) { 79 bool wildcard = strcmp(ic->identifier, "*") == 0;
80 if (strcmp(input_device->identifier, ic->identifier) == 0) { 80 const char *type = strncmp(ic->identifier, "type:", strlen("type:")) == 0
81 if (argc) { 81 ? ic->identifier + strlen("type:") : NULL;
82 toggle_select_send_events_for_device(ic, input_device, 82 struct sway_input_device *device = NULL;
83 argc, argv); 83 wl_list_for_each(device, &server.input->devices, link) {
84 } else { 84 if (wildcard || type) {
85 toggle_supported_send_events_for_device(ic, input_device); 85 ic = new_input_config(device->identifier);
86 if (!ic) {
87 continue;
86 } 88 }
87 return; 89 if (type && strcmp(input_device_get_type(device), type) != 0) {
90 continue;
91 }
92 } else if (strcmp(ic->identifier, device->identifier) != 0) {
93 continue;
88 } 94 }
89 }
90}
91 95
92static void toggle_wildcard_send_events(int argc, char **argv) {
93 struct sway_input_device *input_device = NULL;
94 wl_list_for_each(input_device, &server.input->devices, link) {
95 struct input_config *ic = new_input_config(input_device->identifier);
96 if (!ic) {
97 break;
98 }
99 if (argc) { 96 if (argc) {
100 toggle_select_send_events_for_device(ic, input_device, argc, argv); 97 toggle_select_send_events_for_device(ic, device, argc, argv);
101 } else { 98 } else {
102 toggle_supported_send_events_for_device(ic, input_device); 99 toggle_supported_send_events_for_device(ic, device);
100 }
101
102 if (wildcard || type) {
103 store_input_config(ic, NULL);
104 } else {
105 return;
103 } 106 }
104 store_input_config(ic, NULL);
105 } 107 }
106} 108}
107 109
@@ -132,15 +134,16 @@ struct cmd_results *input_cmd_events(int argc, char **argv) {
132 "Invalid toggle mode %s", argv[i]); 134 "Invalid toggle mode %s", argv[i]);
133 } 135 }
134 } 136 }
135 if (strcmp(ic->identifier, "*") == 0) { 137
136 // Update the device input configs and then reset the wildcard 138 toggle_send_events(argc - 1, argv + 1);
139
140 if (strcmp(ic->identifier, "*") == 0 ||
141 strncmp(ic->identifier, "type:", strlen("type:")) == 0) {
142 // Update the device input configs and then reset the type/wildcard
137 // config send events mode so that is does not override the device 143 // config send events mode so that is does not override the device
138 // ones. The device ones will be applied when attempting to apply 144 // ones. The device ones will be applied when attempting to apply
139 // the wildcard config 145 // the type/wildcard config
140 toggle_wildcard_send_events(argc - 1, argv + 1);
141 ic->send_events = INT_MIN; 146 ic->send_events = INT_MIN;
142 } else {
143 toggle_send_events(ic, argc - 1, argv + 1);
144 } 147 }
145 } else { 148 } else {
146 return cmd_results_new(CMD_INVALID, 149 return cmd_results_new(CMD_INVALID,