1579 } |
1580 } |
1580 |
1581 |
1581 void |
1582 void |
1582 updategeom(void) { |
1583 updategeom(void) { |
1583 #ifdef XINERAMA |
1584 #ifdef XINERAMA |
1584 int di, x, y, n; |
1585 int n; |
1585 unsigned int dui, i = 0; |
1586 unsigned int i = 0; |
1586 Bool pquery; |
|
1587 Client *c; |
1587 Client *c; |
1588 Window dummy; |
|
1589 XineramaScreenInfo *info = NULL; |
1588 XineramaScreenInfo *info = NULL; |
1590 |
1589 |
1591 /* window area geometry */ |
1590 /* window area geometry */ |
1592 if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) { |
1591 if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) { |
1593 nmons = (unsigned int)n; |
1592 if(n != nmons) { |
1594 for(c = clients; c; c = c->next) |
1593 for(c = clients; c; c = c->next) |
1595 if(c->mon >= nmons) |
1594 if(c->mon >= n) |
1596 c->mon = nmons - 1; |
1595 c->mon = n - 1; |
1597 if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor) * nmons))) |
1596 if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor) * n))) |
1598 die("fatal: could not realloc() %u bytes\n", sizeof(Monitor) * nmons); |
1597 die("fatal: could not realloc() %u bytes\n", sizeof(Monitor) * nmons); |
1599 pquery = XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui); |
1598 } |
1600 for(i = 0; i < nmons; i++) { |
1599 for(i = 0; i < n ; i++) { |
1601 /* TODO: consider re-using XineramaScreenInfo */ |
1600 /* TODO: consider re-using XineramaScreenInfo */ |
1602 mon[i].symbol[0] = '['; |
1601 mon[i].symbol[0] = '['; |
1603 mon[i].symbol[1] = '0' + info[i].screen_number; |
1602 mon[i].symbol[1] = '0' + info[i].screen_number; |
1604 mon[i].symbol[2] = ']'; |
1603 mon[i].symbol[2] = ']'; |
1605 mon[i].symbol[3] = 0; |
1604 mon[i].symbol[3] = 0; |
1606 mon[i].showbar = showbar; |
1605 if(!selmon) { /* not initialised yet */ |
1607 mon[i].topbar = topbar; |
1606 mon[i].mfact = mfact; |
|
1607 mon[i].showbar = showbar; |
|
1608 mon[i].topbar = topbar; |
|
1609 } |
1608 mon[i].wx = info[i].x_org; |
1610 mon[i].wx = info[i].x_org; |
1609 mon[i].wy = mon[i].showbar && mon[i].topbar ? info[i].y_org + bh : info[i].y_org; |
1611 mon[i].wy = mon[i].showbar && mon[i].topbar ? info[i].y_org + bh : info[i].y_org; |
1610 mon[i].ww = info[i].width; |
1612 mon[i].ww = info[i].width; |
1611 mon[i].wh = mon[i].showbar ? info[i].height - bh : info[i].height; |
1613 mon[i].wh = mon[i].showbar ? info[i].height - bh : info[i].height; |
1612 mon[i].seltags = 0; |
1614 mon[i].seltags = 0; |
1613 mon[i].sellt = 0; |
1615 mon[i].sellt = 0; |
1614 if(mon[i].showbar) |
1616 if(mon[i].showbar) |
1615 mon[i].by = mon[i].topbar ? info[i].y_org : mon[i].wy + mon[i].wh; |
1617 mon[i].by = mon[i].topbar ? info[i].y_org : mon[i].wy + mon[i].wh; |
1616 else |
1618 else |
1617 mon[i].by = -bh; |
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)) |
1620 } |
1619 selmon = &mon[i]; |
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 XFree(info); |
1634 XFree(info); |
1622 } |
1635 } |
1623 else |
1636 else |
1624 #endif /* XINERAMA */ |
1637 #endif /* XINERAMA */ |
1625 { |
1638 { |
1626 nmons = 1; |
1639 if(!mon) { |
1627 if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor)))) |
1640 nmons = 1; |
1628 die("fatal: could not realloc() %u bytes\n", sizeof(Monitor)); |
1641 if(!(mon = (Monitor *)malloc(sizeof(Monitor)))) |
1629 selmon = &mon[0]; |
1642 die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); |
1630 mon[0].symbol[0] = '['; |
1643 } |
1631 mon[0].symbol[1] = '0'; |
1644 if(!selmon) { |
1632 mon[0].symbol[2] = ']'; |
1645 mon[0].symbol[0] = '['; |
1633 mon[0].symbol[3] = 0; |
1646 mon[0].symbol[1] = '0'; |
1634 mon[0].showbar = showbar; |
1647 mon[0].symbol[2] = ']'; |
1635 mon[0].topbar = topbar; |
1648 mon[0].symbol[3] = 0; |
|
1649 mon[0].mfact = mfact; |
|
1650 mon[0].showbar = showbar; |
|
1651 mon[0].topbar = topbar; |
|
1652 } |
1636 mon[0].wx = sx; |
1653 mon[0].wx = sx; |
1637 mon[0].wy = mon[0].showbar && mon[0].topbar ? sy + bh : sy; |
1654 mon[0].wy = mon[0].showbar && mon[0].topbar ? sy + bh : sy; |
1638 mon[0].ww = sw; |
1655 mon[0].ww = sw; |
1639 mon[0].wh = mon[0].showbar ? sh - bh : sh; |
1656 mon[0].wh = mon[0].showbar ? sh - bh : sh; |
1640 mon[0].seltags = 0; |
1657 mon[0].seltags = 0; |
1641 mon[0].sellt = 0; |
1658 mon[0].sellt = 0; |
1642 if(mon[0].showbar) |
1659 if(mon[0].showbar) |
1643 mon[0].by = mon[0].topbar ? sy : mon[0].wy + mon[0].wh; |
1660 mon[0].by = mon[0].topbar ? sy : mon[0].wy + mon[0].wh; |
1644 else |
1661 else |
1645 mon[0].by = -bh; |
1662 mon[0].by = -bh; |
|
1663 selmon = &mon[0]; |
1646 } |
1664 } |
1647 } |
1665 } |
1648 |
1666 |
1649 void |
1667 void |
1650 updatenumlockmask(void) { |
1668 updatenumlockmask(void) { |