version 1.3, 2017/06/07 14:37:30 |
version 1.4, 2017/06/08 07:48:04 |
|
|
|
|
enum window_client_sort_type { |
enum window_client_sort_type { |
WINDOW_CLIENT_BY_NAME, |
WINDOW_CLIENT_BY_NAME, |
|
WINDOW_CLIENT_BY_SIZE, |
WINDOW_CLIENT_BY_CREATION_TIME, |
WINDOW_CLIENT_BY_CREATION_TIME, |
WINDOW_CLIENT_BY_ACTIVITY_TIME, |
WINDOW_CLIENT_BY_ACTIVITY_TIME, |
}; |
}; |
static const char *window_client_sort_list[] = { |
static const char *window_client_sort_list[] = { |
"name", |
"name", |
|
"size", |
"creation time", |
"creation time", |
"activity time" |
"activity time" |
}; |
}; |
|
|
} |
} |
|
|
static int |
static int |
|
window_client_cmp_size(const void *a0, const void *b0) |
|
{ |
|
const struct window_client_itemdata *const *a = a0; |
|
const struct window_client_itemdata *const *b = b0; |
|
|
|
if ((*a)->c->tty.sx < (*b)->c->tty.sx) |
|
return (-1); |
|
if ((*a)->c->tty.sx > (*b)->c->tty.sx) |
|
return (1); |
|
if ((*a)->c->tty.sy < (*b)->c->tty.sy) |
|
return (-1); |
|
if ((*a)->c->tty.sy > (*b)->c->tty.sy) |
|
return (1); |
|
return (strcmp((*a)->c->name, (*b)->c->name)); |
|
} |
|
|
|
static int |
window_client_cmp_creation_time(const void *a0, const void *b0) |
window_client_cmp_creation_time(const void *a0, const void *b0) |
{ |
{ |
const struct window_client_itemdata *const *a = a0; |
const struct window_client_itemdata *const *a = a0; |
|
|
return (-1); |
return (-1); |
if (timercmp(&(*a)->c->creation_time, &(*b)->c->creation_time, <)) |
if (timercmp(&(*a)->c->creation_time, &(*b)->c->creation_time, <)) |
return (1); |
return (1); |
return (0); |
return (strcmp((*a)->c->name, (*b)->c->name)); |
} |
} |
|
|
static int |
static int |
|
|
return (-1); |
return (-1); |
if (timercmp(&(*a)->c->activity_time, &(*b)->c->activity_time, <)) |
if (timercmp(&(*a)->c->activity_time, &(*b)->c->activity_time, <)) |
return (1); |
return (1); |
return (0); |
return (strcmp((*a)->c->name, (*b)->c->name)); |
} |
} |
|
|
static void |
static void |
|
|
qsort(data->item_list, data->item_size, sizeof *data->item_list, |
qsort(data->item_list, data->item_size, sizeof *data->item_list, |
window_client_cmp_name); |
window_client_cmp_name); |
break; |
break; |
|
case WINDOW_CLIENT_BY_SIZE: |
|
qsort(data->item_list, data->item_size, sizeof *data->item_list, |
|
window_client_cmp_size); |
|
break; |
case WINDOW_CLIENT_BY_CREATION_TIME: |
case WINDOW_CLIENT_BY_CREATION_TIME: |
qsort(data->item_list, data->item_size, sizeof *data->item_list, |
qsort(data->item_list, data->item_size, sizeof *data->item_list, |
window_client_cmp_creation_time); |
window_client_cmp_creation_time); |
|
|
tim = ctime(&c->activity_time.tv_sec); |
tim = ctime(&c->activity_time.tv_sec); |
*strchr(tim, '\n') = '\0'; |
*strchr(tim, '\n') = '\0'; |
|
|
xasprintf(&text, "session %s (%s)", c->session->name, tim); |
xasprintf(&text, "session %s (%ux%u, %s)", c->session->name, |
|
c->tty.sx, c->tty.sy, tim); |
mode_tree_add(data->data, NULL, item, (uint64_t)c, c->name, |
mode_tree_add(data->data, NULL, item, (uint64_t)c, c->name, |
text, -1); |
text, -1); |
free(text); |
free(text); |