aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorNathan Rossi <nathan@nathanrossi.com>2020-01-30 23:50:07 +1000
committerSimon Ser <contact@emersion.fr>2020-01-30 15:03:54 +0100
commitffbf10d07b19a052e2b6d5ef524f7201fe0012c8 (patch)
treeee95e047733e2d1138dd204d0b69b795c3ecbac0 /sway
parent1dbc7f7521a66111b3607b60821dac0c4b86602d (diff)
downloadsway-ffbf10d07b19a052e2b6d5ef524f7201fe0012c8.tar.xz
ipc: Handle unsupported binding event types
Handle binding event types that cannot be encoded gracefully by dropping the event. This prevents issues for binding types like BINDING_SWITCH, where the event would cause a crash.
Diffstat (limited to 'sway')
-rw-r--r--sway/ipc-server.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 9c4f7a64..54b33ca6 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -421,7 +421,8 @@ void ipc_event_binding(struct sway_binding *binding) {
json_object *symbols = json_object_new_array();
json_object *symbol = NULL;
- if (binding->type == BINDING_KEYCODE) { // bindcode: populate input_codes
+ switch (binding->type) {
+ case BINDING_KEYCODE:; // bindcode: populate input_codes
uint32_t keycode;
for (int i = 0; i < binding->keys->length; ++i) {
keycode = *(uint32_t *)binding->keys->items[i];
@@ -430,7 +431,11 @@ void ipc_event_binding(struct sway_binding *binding) {
input_code = keycode;
}
}
- } else { // bindsym/mouse: populate symbols
+ break;
+
+ case BINDING_KEYSYM:
+ case BINDING_MOUSESYM:
+ case BINDING_MOUSECODE:; // bindsym/mouse: populate symbols
uint32_t keysym;
char buffer[64];
for (int i = 0; i < binding->keys->length; ++i) {
@@ -451,6 +456,14 @@ void ipc_event_binding(struct sway_binding *binding) {
json_object_array_add(symbols, str);
}
}
+ break;
+
+ default:
+ sway_log(SWAY_DEBUG, "Unsupported ipc binding event");
+ json_object_put(input_codes);
+ json_object_put(symbols);
+ json_object_put(json_binding);
+ return; // do not send any event
}
json_object_object_add(json_binding, "input_codes", input_codes);