+void
+view(const char *arg) {
+ unsigned int i, j;
+ Bool tmp[LENGTH(tags)];
+
+ memcpy(tmp, seltags, TAGSZ);
+ if(arg == NULL) {
+ for(i = 0; i < LENGTH(tags); i++)
+ tmp[i] = (vtags[i] == selview->id);
+ }
+ else {
+ i = idxoftag(arg);
+ for(j = 0; j < LENGTH(tags); j++)
+ if(selview->id == vtags[i]) {
+ /* view tag of selview */
+ if(selview->id == vtags[j])
+ tmp[j] = False;
+ }
+ else {
+ /* only touch the view the focus should go */
+ if(vtags[j] == vtags[i])
+ tmp[j] = False;
+ }
+ selview = &views[vtags[i]];
+ tmp[i] = True;
+ }
+ if(memcmp(seltags, tmp, TAGSZ) != 0) {
+ memcpy(prevtags, seltags, TAGSZ);
+ memcpy(seltags, tmp, TAGSZ);
+ arrange();
+ }
+}
+
+View *
+viewat() {
+ int i, x, y;
+ Window win;
+ unsigned int mask;
+
+ XQueryPointer(dpy, root, &win, &win, &x, &y, &i, &i, &mask);
+ for(i = 0; i < nviews; i++) {
+ if((x >= views[i].x && x < views[i].x + views[i].w)
+ && (y >= views[i].y && y < views[i].y + views[i].h))
+ return &views[i];
+ }
+ return NULL;
+}
+
+void
+viewprevtag(const char *arg) {
+ static Bool tmp[LENGTH(tags)];
+
+ memcpy(tmp, seltags, TAGSZ);
+ memcpy(seltags, prevtags, TAGSZ);
+ memcpy(prevtags, tmp, TAGSZ);
+ arrange();
+}
+