- if (dir == CYCLE_NEXT)
- select_desktop((mon->desk->next == NULL ? mon->desk_head : mon->desk->next));
- else if (dir == CYCLE_PREV)
- select_desktop((mon->desk->prev == NULL ? mon->desk_tail : mon->desk->prev));
-}
-
-void nearest_leaf(monitor_t *m, desktop_t *d, node_t *n, nearest_arg_t dir, skip_client_t skip)
-{
- if (n == NULL)
- return;
-
- PUTS("nearest leaf");
-
- node_t *x = NULL;
-
- for (node_t *f = first_extrema(d->root); f != NULL; f = next_leaf(f))
- if (skip == SKIP_NONE || (skip == SKIP_TILED && !is_tiled(f->client)) || (skip == SKIP_FLOATING && is_tiled(f->client))
- || (skip == SKIP_CLASS_DIFFER && strcmp(f->client->class_name, n->client->class_name) == 0)
- || (skip == SKIP_CLASS_EQUAL && strcmp(f->client->class_name, n->client->class_name) != 0))
- if ((dir == NEAREST_OLDER
- && (f->client->uid < n->client->uid)
- && (x == NULL || f->client->uid > x->client->uid))
- || (dir == NEAREST_NEWER
- && (f->client->uid > n->client->uid)
- && (x == NULL || f->client->uid < x->client->uid)))
- x = f;
+ desktop_t *f = (dir == CYCLE_PREV ? d->prev : d->next);
+ if (f == NULL)
+ f = (dir == CYCLE_PREV ? m->desk_tail : m->desk_head);