- int di, x, y, n;
- unsigned int dui, i = 0;
- Bool pquery;
- Client *c;
- Window dummy;
- XineramaScreenInfo *info = NULL;
-
- /* window area geometry */
- if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) {
- nmons = (unsigned int)n;
- for(c = clients; c; c = c->next)
- if(c->mon >= nmons)
- c->mon = nmons - 1;
- if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor) * nmons)))
- die("fatal: could not realloc() %u bytes\n", sizeof(Monitor) * nmons);
- pquery = XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
- for(i = 0; i < nmons; i++) {
- /* TODO: consider re-using XineramaScreenInfo */
- mon[i].wx = info[i].x_org;
- mon[i].wy = info[i].y_org;
- mon[i].ww = info[i].width;
- mon[i].wh = info[i].height;
- mon[i].seltags = 0;
- mon[i].sellt = 0;
- if(pquery && INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height))
- selmon = &mon[i];
- }
- /* bar adjustments of selmon */
- selmon->wy = showbar && topbar ? selmon->wy + bh : selmon->wy;
- selmon->wh = showbar ? selmon->wh - bh : selmon->wh;
+ if(XineramaIsActive(dpy)) {
+ int i, j, n, nn;
+ Monitor *m;
+ XineramaScreenInfo *info = XineramaQueryScreens(dpy, &nn);
+ XineramaScreenInfo *unique = NULL;
+
+ info = XineramaQueryScreens(dpy, &nn);
+ for(n = 0, m = mons; m; m = m->next, n++);
+ /* only consider unique geometries as separate screens */
+ if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * nn)))
+ die("fatal: could not malloc() %u bytes\n", sizeof(XineramaScreenInfo) * nn);
+ for(i = 0, j = 0; i < nn; i++)
+ if(isuniquegeom(unique, j, &info[i]))
+ memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));