some minor fixes regarding the new xinerama support
6644a6aa
1 file(s) · +48 −30
| 116 | 116 | ||
| 117 | 117 | typedef struct { |
|
| 118 | 118 | char symbol[4]; |
|
| 119 | + | float mfact; |
|
| 119 | 120 | int by, btx; /* bar geometry */ |
|
| 120 | 121 | int wx, wy, ww, wh; /* window area */ |
|
| 121 | 122 | unsigned int seltags; |
|
| 251 | 252 | static DC dc; |
|
| 252 | 253 | static Layout *lt[] = { NULL, NULL }; |
|
| 253 | 254 | static Monitor *mon = NULL, *selmon = NULL; |
|
| 254 | - | static unsigned int nmons; |
|
| 255 | + | static unsigned int nmons = 0; |
|
| 255 | 256 | static Window root; |
|
| 256 | 257 | /* configuration, allows nested code to access above variables */ |
|
| 257 | 258 | #include "config.h" |
|
| 1322 | 1323 | ||
| 1323 | 1324 | if(!arg || !lt[selmon->sellt]->arrange) |
|
| 1324 | 1325 | return; |
|
| 1325 | - | f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0; |
|
| 1326 | + | f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; |
|
| 1326 | 1327 | if(f < 0.1 || f > 0.9) |
|
| 1327 | 1328 | return; |
|
| 1328 | - | mfact = f; |
|
| 1329 | + | selmon->mfact = f; |
|
| 1329 | 1330 | arrange(); |
|
| 1330 | 1331 | } |
|
| 1331 | 1332 | ||
| 1483 | 1484 | ||
| 1484 | 1485 | /* master */ |
|
| 1485 | 1486 | c = nexttiled(m, clients); |
|
| 1486 | - | mw = mfact * m->ww; |
|
| 1487 | + | mw = m->mfact * m->ww; |
|
| 1487 | 1488 | resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw); |
|
| 1488 | 1489 | ||
| 1489 | 1490 | if(--n == 0) |
|
| 1581 | 1582 | void |
|
| 1582 | 1583 | updategeom(void) { |
|
| 1583 | 1584 | #ifdef XINERAMA |
|
| 1584 | - | int di, x, y, n; |
|
| 1585 | - | unsigned int dui, i = 0; |
|
| 1586 | - | Bool pquery; |
|
| 1585 | + | int n; |
|
| 1586 | + | unsigned int i = 0; |
|
| 1587 | 1587 | Client *c; |
|
| 1588 | - | Window dummy; |
|
| 1589 | 1588 | XineramaScreenInfo *info = NULL; |
|
| 1590 | 1589 | ||
| 1591 | 1590 | /* window area geometry */ |
|
| 1592 | 1591 | if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) { |
|
| 1593 | - | nmons = (unsigned int)n; |
|
| 1594 | - | for(c = clients; c; c = c->next) |
|
| 1595 | - | if(c->mon >= nmons) |
|
| 1596 | - | c->mon = nmons - 1; |
|
| 1597 | - | if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor) * nmons))) |
|
| 1598 | - | die("fatal: could not realloc() %u bytes\n", sizeof(Monitor) * nmons); |
|
| 1599 | - | pquery = XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui); |
|
| 1600 | - | for(i = 0; i < nmons; i++) { |
|
| 1592 | + | if(n != nmons) { |
|
| 1593 | + | for(c = clients; c; c = c->next) |
|
| 1594 | + | if(c->mon >= n) |
|
| 1595 | + | c->mon = n - 1; |
|
| 1596 | + | if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor) * n))) |
|
| 1597 | + | die("fatal: could not realloc() %u bytes\n", sizeof(Monitor) * nmons); |
|
| 1598 | + | } |
|
| 1599 | + | for(i = 0; i < n ; i++) { |
|
| 1601 | 1600 | /* TODO: consider re-using XineramaScreenInfo */ |
|
| 1602 | 1601 | mon[i].symbol[0] = '['; |
|
| 1603 | 1602 | mon[i].symbol[1] = '0' + info[i].screen_number; |
|
| 1604 | 1603 | mon[i].symbol[2] = ']'; |
|
| 1605 | 1604 | mon[i].symbol[3] = 0; |
|
| 1606 | - | mon[i].showbar = showbar; |
|
| 1607 | - | mon[i].topbar = topbar; |
|
| 1605 | + | if(!selmon) { /* not initialised yet */ |
|
| 1606 | + | mon[i].mfact = mfact; |
|
| 1607 | + | mon[i].showbar = showbar; |
|
| 1608 | + | mon[i].topbar = topbar; |
|
| 1609 | + | } |
|
| 1608 | 1610 | mon[i].wx = info[i].x_org; |
|
| 1609 | 1611 | mon[i].wy = mon[i].showbar && mon[i].topbar ? info[i].y_org + bh : info[i].y_org; |
|
| 1610 | 1612 | mon[i].ww = info[i].width; |
|
| 1615 | 1617 | mon[i].by = mon[i].topbar ? info[i].y_org : mon[i].wy + mon[i].wh; |
|
| 1616 | 1618 | else |
|
| 1617 | 1619 | mon[i].by = -bh; |
|
| 1618 | - | if(pquery && INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) |
|
| 1619 | - | selmon = &mon[i]; |
|
| 1620 | + | } |
|
| 1621 | + | nmons = (unsigned int)n; |
|
| 1622 | + | if(!selmon) { |
|
| 1623 | + | selmon = &mon[0]; |
|
| 1624 | + | int di, x, y; |
|
| 1625 | + | unsigned int dui; |
|
| 1626 | + | Window dummy; |
|
| 1627 | + | if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui)) |
|
| 1628 | + | for(i = 0; i < nmons; i++) |
|
| 1629 | + | if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) { |
|
| 1630 | + | selmon = &mon[i]; |
|
| 1631 | + | break; |
|
| 1632 | + | } |
|
| 1620 | 1633 | } |
|
| 1621 | 1634 | XFree(info); |
|
| 1622 | 1635 | } |
|
| 1623 | 1636 | else |
|
| 1624 | 1637 | #endif /* XINERAMA */ |
|
| 1625 | 1638 | { |
|
| 1626 | - | nmons = 1; |
|
| 1627 | - | if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor)))) |
|
| 1628 | - | die("fatal: could not realloc() %u bytes\n", sizeof(Monitor)); |
|
| 1629 | - | selmon = &mon[0]; |
|
| 1630 | - | mon[0].symbol[0] = '['; |
|
| 1631 | - | mon[0].symbol[1] = '0'; |
|
| 1632 | - | mon[0].symbol[2] = ']'; |
|
| 1633 | - | mon[0].symbol[3] = 0; |
|
| 1634 | - | mon[0].showbar = showbar; |
|
| 1635 | - | mon[0].topbar = topbar; |
|
| 1639 | + | if(!mon) { |
|
| 1640 | + | nmons = 1; |
|
| 1641 | + | if(!(mon = (Monitor *)malloc(sizeof(Monitor)))) |
|
| 1642 | + | die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); |
|
| 1643 | + | } |
|
| 1644 | + | if(!selmon) { |
|
| 1645 | + | mon[0].symbol[0] = '['; |
|
| 1646 | + | mon[0].symbol[1] = '0'; |
|
| 1647 | + | mon[0].symbol[2] = ']'; |
|
| 1648 | + | mon[0].symbol[3] = 0; |
|
| 1649 | + | mon[0].mfact = mfact; |
|
| 1650 | + | mon[0].showbar = showbar; |
|
| 1651 | + | mon[0].topbar = topbar; |
|
| 1652 | + | } |
|
| 1636 | 1653 | mon[0].wx = sx; |
|
| 1637 | 1654 | mon[0].wy = mon[0].showbar && mon[0].topbar ? sy + bh : sy; |
|
| 1638 | 1655 | mon[0].ww = sw; |
|
| 1643 | 1660 | mon[0].by = mon[0].topbar ? sy : mon[0].wy + mon[0].wh; |
|
| 1644 | 1661 | else |
|
| 1645 | 1662 | mon[0].by = -bh; |
|
| 1663 | + | selmon = &mon[0]; |
|
| 1646 | 1664 | } |
|
| 1647 | 1665 | } |
|
| 1648 | 1666 | ||