+ /* bar geometry setup */
+ for(m = newmons; m; m = m->next) {
+ /* TODO: consider removing the following values from config.h */
+ m->clients = NULL;
+ m->sel = NULL;
+ m->stack = NULL;
+ m->seltags = 0;
+ m->sellt = 0;
+ m->tagset[0] = m->tagset[1] = 1;
+ m->mfact = mfact;
+ m->showbar = showbar;
+ m->topbar = topbar;
+ updatebarpos(m);
+ /* reassign all clients with same screen number */
+ for(tm = mons; tm; tm = tm->next)
+ if(tm->screen_number == m->screen_number) {
+ m->clients = tm->clients;
+ m->sel = m->stack = tm->stack;
+ tm->clients = NULL;
+ tm->stack = NULL;
+ for(c = m->clients; c; c = c->next)
+ c->mon = m;
+ }
+ }
+
+ /* 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->sel = 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);