+ if (cols != 0) {
+ list_t *dpy, *col, *row, *ndpy, *ncol = NULL;
+ if (wm_focus) {
+ searchl(wm_tag, wm_focus, &dpy, &col, &row);
+ ncol = cols > 0 ? col->next : col->prev;
+ } else {
+ dpy = list_find(wm_tag->dpys, wm_dpy);
+ }
+ if (ncol == NULL) {
+ ndpy = get_next(dpy, cols > 0);
+ ncol = cols > 0 ? DPY(ndpy)->cols :
+ list_last(DPY(ndpy)->cols);
+ wm_dpy = ndpy->data;
+ }
+ if (ncol && COL(ncol) && COL(ncol)->row)
+ set_focus(COL(ncol)->row->win);
+ else
+ sys_focus(wm->root);
+ }
+}
+
+static tag_t *tag_new(list_t *screens, int name)
+{
+ tag_t *tag = new0(tag_t);
+ tag->name = name;
+ for (list_t *cur = screens; cur; cur = cur->next) {
+ dpy_t *dpy = new0(dpy_t);
+ dpy->geom = cur->data;
+ tag->dpys = list_append(tag->dpys, dpy);
+ }
+ tag->dpy = tag->dpys->data;
+ return tag;
+}
+
+static tag_t *tag_find(int name)
+{
+ tag_t *tag = NULL;
+ for (list_t *cur = wm->tags; cur; cur = cur->next)
+ if (name == TAG(cur)->name) {
+ tag = cur->data;
+ break;
+ }
+ if (!tag) {
+ tag = tag_new(wm->screens, name);
+ wm->tags = list_insert(wm->tags, tag);