diff options
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 78 |
1 files changed, 48 insertions, 30 deletions
| @@ -116,6 +116,7 @@ typedef struct { | |||
| 116 | 116 | ||
| 117 | typedef struct { | 117 | typedef struct { |
| 118 | char symbol[4]; | 118 | char symbol[4]; |
| 119 | float mfact; | ||
| 119 | int by, btx; /* bar geometry */ | 120 | int by, btx; /* bar geometry */ |
| 120 | int wx, wy, ww, wh; /* window area */ | 121 | int wx, wy, ww, wh; /* window area */ |
| 121 | unsigned int seltags; | 122 | unsigned int seltags; |
| @@ -251,7 +252,7 @@ static Display *dpy; | |||
| 251 | static DC dc; | 252 | static DC dc; |
| 252 | static Layout *lt[] = { NULL, NULL }; | 253 | static Layout *lt[] = { NULL, NULL }; |
| 253 | static Monitor *mon = NULL, *selmon = NULL; | 254 | static Monitor *mon = NULL, *selmon = NULL; |
| 254 | static unsigned int nmons; | 255 | static unsigned int nmons = 0; |
| 255 | static Window root; | 256 | static Window root; |
| 256 | /* configuration, allows nested code to access above variables */ | 257 | /* configuration, allows nested code to access above variables */ |
| 257 | #include "config.h" | 258 | #include "config.h" |
| @@ -1322,10 +1323,10 @@ setmfact(const Arg *arg) { | |||
| 1322 | 1323 | ||
| 1323 | if(!arg || !lt[selmon->sellt]->arrange) | 1324 | if(!arg || !lt[selmon->sellt]->arrange) |
| 1324 | return; | 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 | if(f < 0.1 || f > 0.9) | 1327 | if(f < 0.1 || f > 0.9) |
| 1327 | return; | 1328 | return; |
| 1328 | mfact = f; | 1329 | selmon->mfact = f; |
| 1329 | arrange(); | 1330 | arrange(); |
| 1330 | } | 1331 | } |
| 1331 | 1332 | ||
| @@ -1483,7 +1484,7 @@ tile(Monitor *m) { | |||
| 1483 | 1484 | ||
| 1484 | /* master */ | 1485 | /* master */ |
| 1485 | c = nexttiled(m, clients); | 1486 | c = nexttiled(m, clients); |
| 1486 | mw = mfact * m->ww; | 1487 | mw = m->mfact * m->ww; |
| 1487 | resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw); | 1488 | resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw); |
| 1488 | 1489 | ||
| 1489 | if(--n == 0) | 1490 | if(--n == 0) |
| @@ -1581,30 +1582,31 @@ unmapnotify(XEvent *e) { | |||
| 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; |
| @@ -1615,24 +1617,39 @@ updategeom(void) { | |||
| 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; |
| @@ -1643,6 +1660,7 @@ updategeom(void) { | |||
| 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 | ||
