- if (col != 0) {
- col_t *next = get_next(lcol, col > 0)->data;
- set_focus(next->row->win);
+ 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);