+ /* reassign left over clients of disappeared monitors */
+ for(tm = mons; tm; tm = tm->next) {
+ while(tm->clients) {
+ c = tm->clients->next;
+ tm->clients->next = newmons->clients;
+ tm->clients->mon = newmons;
+ newmons->clients = tm->clients;
+ tm->clients = c;
+ }
+ while(tm->stack) {
+ c = tm->stack->snext;
+ tm->stack->snext = newmons->stack;
+ newmons->stack = tm->stack;
+ tm->stack = c;
+ }
+ }
+
+ /* select focused monitor */
+ if(!selmon) {
+ selmon = newmons;
+ int di, x, y;
+ unsigned int dui;
+ Window dummy;
+ if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
+ for(m = newmons; m; m = m->next)
+ if(INRECT(x, y, m->wx, m->wy, m->ww, m->wh)) {
+ selmon = m;
+ break;
+ }
+ }
+
+ /* final assignment of new monitors */
+ cleanupmons();
+ mons = newmons;
+}
+
+void
+updatenumlockmask(void) {
+ unsigned int i, j;
+ XModifierKeymap *modmap;
+
+ numlockmask = 0;
+ modmap = XGetModifierMapping(dpy);
+ for(i = 0; i < 8; i++)
+ for(j = 0; j < modmap->max_keypermod; j++)
+ if(modmap->modifiermap[i * modmap->max_keypermod + j]
+ == XKeysymToKeycode(dpy, XK_Num_Lock))
+ numlockmask = (1 << i);
+ XFreeModifiermap(modmap);