diff --git a/modules/i3-common.c b/modules/i3-common.c index ec5c53c..8f7d2d9 100644 --- a/modules/i3-common.c +++ b/modules/i3-common.c @@ -204,6 +204,8 @@ i3_receive_loop(int abort_fd, int sock, break; } + LOG_DBG("header: type=%x", hdr->type); + /* Json-c expects a NULL-terminated string */ char json_str[hdr->size + 1]; memcpy(json_str, &buf[sizeof(*hdr)], hdr->size); @@ -219,7 +221,6 @@ i3_receive_loop(int abort_fd, int sock, break; } - //err = pkt_handler(hdr, json, data); i3_ipc_callback_t pkt_handler = NULL; switch (hdr->type) { case I3_IPC_REPLY_TYPE_COMMAND: diff --git a/modules/i3.c b/modules/i3.c index bc6a8a6..00564ad 100644 --- a/modules/i3.c +++ b/modules/i3.c @@ -64,6 +64,7 @@ workspace_from_json(const struct json_object *json, struct workspace *ws) if (!json_object_object_get_ex(json, "name", &name) || !json_object_object_get_ex(json, "output", &output)) { + LOG_ERR("workspace reply/event without 'name' and/or 'output' property"); return false; } @@ -152,8 +153,10 @@ static bool handle_get_version_reply(int type, const struct json_object *json, void *_m) { struct json_object *version; - if (!json_object_object_get_ex(json, "human_readable", &version)) + if (!json_object_object_get_ex(json, "human_readable", &version)) { + LOG_ERR("version reply without 'humand_readable' property"); return false; + } LOG_INFO("i3: %s", json_object_get_string(version)); return true; @@ -163,8 +166,10 @@ static bool handle_subscribe_reply(int type, const struct json_object *json, void *_m) { struct json_object *success; - if (!json_object_object_get_ex(json, "success", &success)) + if (!json_object_object_get_ex(json, "success", &success)) { + LOG_ERR("subscribe reply without 'success' property"); return false; + } if (!json_object_get_boolean(success)) { LOG_ERR("failed to subscribe"); @@ -211,8 +216,10 @@ handle_workspace_event(int type, const struct json_object *json, void *_mod) struct private *m = mod->private; struct json_object *change; - if (!json_object_object_get_ex(json, "change", &change)) + if (!json_object_object_get_ex(json, "change", &change)) { + LOG_ERR("workspace event without 'change' property"); return false; + } const char *change_str = json_object_get_string(change); @@ -230,7 +237,10 @@ handle_workspace_event(int type, const struct json_object *json, void *_mod) struct json_object *current, *_current_name; if (!json_object_object_get_ex(json, "current", ¤t) || !json_object_object_get_ex(current, "name", &_current_name)) + { + LOG_ERR("workspace event without 'current' and/or 'name' properties"); return false; + } const char *current_name = json_object_get_string(_current_name); @@ -257,6 +267,7 @@ handle_workspace_event(int type, const struct json_object *json, void *_mod) !json_object_object_get_ex(old, "name", &_old_name) || !json_object_object_get_ex(current, "urgent", &urgent)) { + LOG_ERR("workspace 'focused' event without 'old', 'name' and/or 'urgent' property"); mtx_unlock(&mod->lock); return false; } @@ -287,6 +298,7 @@ handle_workspace_event(int type, const struct json_object *json, void *_mod) else if (is_urgent) { struct json_object *urgent; if (!json_object_object_get_ex(current, "urgent", &urgent)) { + LOG_ERR("workspace 'urgent' event without 'urgent' property"); mtx_unlock(&mod->lock); return false; } @@ -311,8 +323,10 @@ handle_window_event(int type, const struct json_object *json, void *_mod) struct private *m = mod->private; struct json_object *change; - if (!json_object_object_get_ex(json, "change", &change)) + if (!json_object_object_get_ex(json, "change", &change)) { + LOG_ERR("window event without 'change' property"); return false; + } const char *change_str = json_object_get_string(change); bool is_focus = strcmp(change_str, "focus") == 0; @@ -356,6 +370,7 @@ handle_window_event(int type, const struct json_object *json, void *_mod) !json_object_object_get_ex(container, "name", &name)) { mtx_unlock(&mod->lock); + LOG_ERR("window event without 'container' with 'id' and 'name'"); return false; }