From 8153e40f2aae132601fb3f3f69f75a71a456a67f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 1 Jun 2021 17:40:59 +0200 Subject: [PATCH] module/sway-xkb: ignore non-keyboards in input event handler This is already being done in the initial query response. Not doing it in the input event handler too leads to an assertion if there are multiple devices with the same ID. Hopefully fixes #54 --- modules/sway-xkb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/sway-xkb.c b/modules/sway-xkb.c index 83d4d10..d6960d9 100644 --- a/modules/sway-xkb.c +++ b/modules/sway-xkb.c @@ -175,6 +175,15 @@ handle_input_event(int type, const struct json_object *json, void *_mod) return false; const char *id = json_object_get_string(identifier); + + struct json_object *input_type; + if (!json_object_object_get_ex(obj, "type", &input_type)) + return false; + if (strcmp(json_object_get_string(input_type), "keyboard") != 0) { + LOG_DBG("ignoring non-keyboard input '%s'", id); + return true; + } + struct input *input = NULL; for (size_t i = 0; i < m->num_inputs; i++) { struct input *maybe_input = &m->inputs[i];