Sort workspace on bar by num

This commit is contained in:
Mikkel Oscar Lyderik 2015-12-17 01:39:15 +01:00
parent 5a9cc96446
commit 54c3e8458b

View file

@ -98,6 +98,19 @@ void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
(color & 0xFF) / 256.0); (color & 0xFF) / 256.0);
} }
int workspace_cmp(const void *left, const void *right) {
const struct workspace *a = left, *b = right;
if (a->num > b->num) {
return 1;
}
if (a->num < b->num) {
return -1;
}
return 0;
}
void ipc_update_workspaces() { void ipc_update_workspaces() {
if (workspaces) { if (workspaces) {
free_flat_list(workspaces); free_flat_list(workspaces);
@ -138,6 +151,9 @@ void ipc_update_workspaces() {
json_object_put(ws_json); json_object_put(ws_json);
} }
// sort by num
list_sort(workspaces, workspace_cmp);
json_object_put(results); json_object_put(results);
free(res); free(res);
} }