some more refactoring, bar toggle fixes
a3bbdb1b
1 file(s) · +27 −17
| 124 | 124 | int screen_number; |
|
| 125 | 125 | float mfact; |
|
| 126 | 126 | int by, btx; /* bar geometry */ |
|
| 127 | + | int my, mh; /* vertical screen size*/ |
|
| 127 | 128 | int wx, wy, ww, wh; /* window area */ |
|
| 128 | 129 | unsigned int seltags; |
|
| 129 | 130 | unsigned int sellt; |
|
| 209 | 210 | static void unmanage(Client *c); |
|
| 210 | 211 | static void unmapnotify(XEvent *e); |
|
| 211 | 212 | static void updategeom(void); |
|
| 213 | + | static void updatebarpos(Monitor *m); |
|
| 212 | 214 | static void updatebars(void); |
|
| 213 | 215 | static void updatenumlockmask(void); |
|
| 214 | 216 | static void updatesizehints(Client *c); |
|
| 389 | 391 | XButtonPressedEvent *ev = &e->xbutton; |
|
| 390 | 392 | ||
| 391 | 393 | click = ClkRootWin; |
|
| 392 | - | if(ev->window == selmon->barwin) { |
|
| 394 | + | if(ev->window == selmon->barwin && ev->x >= selmon->btx) { |
|
| 393 | 395 | i = 0; |
|
| 394 | 396 | x = selmon->btx; |
|
| 395 | 397 | do |
|
| 597 | 599 | ||
| 598 | 600 | void |
|
| 599 | 601 | drawbar(Monitor *m) { |
|
| 602 | + | char buf[2]; |
|
| 600 | 603 | int x; |
|
| 601 | 604 | unsigned int i, occ = 0, urg = 0; |
|
| 602 | 605 | unsigned long *col; |
|
| 613 | 616 | dc.x = 0; |
|
| 614 | 617 | #ifdef XINERAMA |
|
| 615 | 618 | { |
|
| 616 | - | /* |
|
| 617 | - | dc.w = TEXTW(m->symbol); |
|
| 618 | - | drawtext(NULL, selmon == m ? dc.sel : dc.norm, False); |
|
| 619 | + | buf[0] = m->screen_number + '0'; |
|
| 620 | + | buf[1] = '\0'; |
|
| 621 | + | dc.w = TEXTW(buf); |
|
| 622 | + | drawtext(buf, selmon == m ? dc.sel : dc.norm, True); |
|
| 619 | 623 | dc.x += dc.w; |
|
| 620 | - | */ |
|
| 621 | 624 | } |
|
| 622 | 625 | #endif /* XINERAMA */ |
|
| 623 | 626 | m->btx = dc.x; |
|
| 1525 | 1528 | void |
|
| 1526 | 1529 | togglebar(const Arg *arg) { |
|
| 1527 | 1530 | selmon->showbar = !selmon->showbar; |
|
| 1528 | - | updategeom(); |
|
| 1531 | + | updatebarpos(selmon); |
|
| 1529 | 1532 | XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); |
|
| 1530 | 1533 | arrange(); |
|
| 1531 | 1534 | } |
|
| 1615 | 1618 | } |
|
| 1616 | 1619 | ||
| 1617 | 1620 | void |
|
| 1621 | + | updatebarpos(Monitor *m) { |
|
| 1622 | + | m->wy = m->my; |
|
| 1623 | + | m->wh = m->mh; |
|
| 1624 | + | if(m->showbar) { |
|
| 1625 | + | m->wh -= bh; |
|
| 1626 | + | m->by = m->topbar ? m->wy : m->wy + m->wh; |
|
| 1627 | + | m->wy = m->topbar ? m->wy + bh : m->wy; |
|
| 1628 | + | } |
|
| 1629 | + | else |
|
| 1630 | + | m->by = -bh; |
|
| 1631 | + | } |
|
| 1632 | + | ||
| 1633 | + | void |
|
| 1618 | 1634 | updategeom(void) { |
|
| 1619 | 1635 | int i, n; |
|
| 1620 | 1636 | Client *c; |
|
| 1639 | 1655 | for(i = 0, m = newmons; m; m = m->next, i++) { |
|
| 1640 | 1656 | m->screen_number = info[i].screen_number; |
|
| 1641 | 1657 | m->wx = info[i].x_org; |
|
| 1642 | - | m->wy = info[i].y_org; |
|
| 1658 | + | m->my = m->wy = info[i].y_org; |
|
| 1643 | 1659 | m->ww = info[i].width; |
|
| 1644 | - | m->wh = info[i].height; |
|
| 1660 | + | m->mh = m->wh = info[i].height; |
|
| 1645 | 1661 | } |
|
| 1646 | 1662 | XFree(info); |
|
| 1647 | 1663 | } |
|
| 1651 | 1667 | { |
|
| 1652 | 1668 | m->screen_number = 0; |
|
| 1653 | 1669 | m->wx = sx; |
|
| 1654 | - | m->wy = sy; |
|
| 1670 | + | m->my = m->wy = sy; |
|
| 1655 | 1671 | m->ww = sw; |
|
| 1656 | - | m->wh = sh; |
|
| 1672 | + | m->mh = m->wh = sh; |
|
| 1657 | 1673 | } |
|
| 1658 | 1674 | ||
| 1659 | 1675 | /* bar geometry setup */ |
|
| 1665 | 1681 | m->mfact = mfact; |
|
| 1666 | 1682 | m->showbar = showbar; |
|
| 1667 | 1683 | m->topbar = topbar; |
|
| 1668 | - | if(m->showbar) { |
|
| 1669 | - | m->wh -= bh; |
|
| 1670 | - | m->by = m->topbar ? m->wy : m->wy + m->wh; |
|
| 1671 | - | m->wy = m->topbar ? m->wy + bh : m->wy; |
|
| 1672 | - | } |
|
| 1673 | - | else |
|
| 1674 | - | m->by = -bh; |
|
| 1684 | + | updatebarpos(m); |
|
| 1675 | 1685 | /* reassign all clients with same screen number */ |
|
| 1676 | 1686 | for(c = clients; c; c = c->next) |
|
| 1677 | 1687 | if(c->m->screen_number == m->screen_number) |
|