module/i3: 'pid' is not a standard property of windows event

Don't fail (and terminate the i3 plugin) if we receive a window event
where the 'container' doesn't have a 'pid' property.

This means we won't be able to determine the application the window
belongs to.

Closes #2
This commit is contained in:
Daniel Eklöf 2020-01-24 18:42:37 +01:00
parent 9675b86478
commit f4e456a0ad
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -350,11 +350,10 @@ handle_window_event(int type, const struct json_object *json, void *_mod)
}
struct json_object *container, *id, *name, *pid;
struct json_object *container, *id, *name;
if (!json_object_object_get_ex(json, "container", &container) ||
!json_object_object_get_ex(container, "id", &id) ||
!json_object_object_get_ex(container, "name", &name) ||
!json_object_object_get_ex(container, "pid", &pid))
!json_object_object_get_ex(container, "name", &name))
{
mtx_unlock(&mod->lock);
return false;
@ -382,6 +381,8 @@ handle_window_event(int type, const struct json_object *json, void *_mod)
*/
struct json_object *app_id;
struct json_object *pid;
if (json_object_object_get_ex(container, "app_id", &app_id) &&
json_object_get_string(app_id) != NULL)
{
@ -391,7 +392,9 @@ handle_window_event(int type, const struct json_object *json, void *_mod)
}
/* If PID has changed, update application name from /proc/<pid>/comm */
else if (ws->window.pid != json_object_get_int(pid)) {
else if (json_object_object_get_ex(container, "pid", &pid) &&
ws->window.pid != json_object_get_int(pid))
{
ws->window.pid = json_object_get_int(pid);
char path[64];