int neighbours(int y, int x) { int n = 0; /* Alive neighbours */ /* The curses coordinate system puts y=0 to the top, so y-1 means checking * for above and y+1 means the bottom */ /* Check for boundaries and then sum up the alive cells */ if(y < LMAX) { n += ALIVE(y+1,x); /* Bottom */ } if(y > 0) { n += ALIVE(y-1,x); /* Top */ } if(x < CMAX) { n += ALIVE(y, x+1); /* Right */ if(y > 0) { n += ALIVE(y-1, x+1); /* Top right */ } if(y < LMAX) { n += ALIVE(y+1, x+1); /* Bottom right */ } } if(x > 0) { n += ALIVE(y, x-1); /* Left */ if(y > 0) { n += ALIVE(y-1, x-1); /* Top left */ } if(y < LMAX) { n += ALIVE(y+1, x-1); /* Bottom left */ } } return n; }
Window subSubtleFocus(int focus) { int sid = 0; SubClient *c = NULL; SubScreen *s = NULL; /* Get current screen */ s = subScreenCurrent(&sid); /* Find next window */ if(focus) { int i; /* Check focus history */ for(i = 1; i < HISTORYSIZE; i++) { if((c = CLIENT(subSubtleFind(subtle->windows.focus[i], CLIENTID)))) { /* Check visibility on current screen */ if(c->screen == sid && ALIVE(c) && VISIBLE(subtle->visible_tags, c) && c->win != subtle->windows.focus[0]) { subClientFocus(c); subClientWarp(c, True); return c->win; } } } /* Check client list backwards to get fullscreen first */ for(i = subtle->clients->ndata - 1; i > 0; i--) { c = CLIENT(subtle->clients->data[i]); /* Check visibility on current screen */ if(c->screen == sid && ALIVE(c) && VISIBLE(subtle->visible_tags, c) && c->win != subtle->windows.focus[0]) { subClientFocus(c); subClientWarp(c, True); return c->win; } } } /* Fallback to root */ subtle->windows.focus[0] = ROOT; subGrabSet(ROOT); XSetInputFocus(subtle->dpy, ROOT, RevertToPointerRoot, CurrentTime); subScreenUpdate(); subScreenRender(); /* EWMH: Current destop */ subEwmhSetCardinals(ROOT, SUB_EWMH_NET_CURRENT_DESKTOP, (long *)&s->vid, 1); return ROOT; } /* }}} */