fix duplicate keys in space_windows_change INFO (#498)

This commit is contained in:
Felix Kratz 2024-02-04 13:55:31 +01:00
parent 6801874d08
commit 9c88e3c957

View file

@ -123,13 +123,26 @@ static void app_windows_post_event_for_space(struct app_windows* windows, uint64
pid_count[j]++;
if (!pid_name[j]) {
pid_name[j] = workspace_copy_app_name_for_pid(pid_list[j]);
length += pid_name[j] ? strlen(pid_name[j]) + 16 : 0;
length += pid_name[j] ? (strlen(pid_name[j]) + 16) : 0;
}
break;
}
}
}
for (int i = 0; i < windows->num_windows; i++) {
for (int j = i + 1; j < windows->num_windows; j++) {
if (pid_name[i]
&& pid_name[j]
&& strcmp(pid_name[i], pid_name[j]) == 0) {
free(pid_name[j]);
pid_name[j] = NULL;
pid_count[i] += pid_count[j];
}
}
}
char payload[length];
memset(payload, 0, length);
snprintf(payload, length, "{\n"
@ -156,7 +169,6 @@ static void app_windows_post_event_for_space(struct app_windows* windows, uint64
cursor = payload + strlen(payload);
}
snprintf(cursor, length - (cursor - payload), "\n\t}\n}\n");
struct event event = { payload, SPACE_WINDOWS_CHANGED };
event_post(&event);