summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dwm.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/dwm.c b/dwm.c
index 7e4e177..66193ef 100644
--- a/dwm.c
+++ b/dwm.c
@@ -124,6 +124,7 @@ struct Monitor {
124 int screen_number; 124 int screen_number;
125 float mfact; 125 float mfact;
126 int by, btx; /* bar geometry */ 126 int by, btx; /* bar geometry */
127 int my, mh; /* vertical screen size*/
127 int wx, wy, ww, wh; /* window area */ 128 int wx, wy, ww, wh; /* window area */
128 unsigned int seltags; 129 unsigned int seltags;
129 unsigned int sellt; 130 unsigned int sellt;
@@ -209,6 +210,7 @@ static void toggleview(const Arg *arg);
209static void unmanage(Client *c); 210static void unmanage(Client *c);
210static void unmapnotify(XEvent *e); 211static void unmapnotify(XEvent *e);
211static void updategeom(void); 212static void updategeom(void);
213static void updatebarpos(Monitor *m);
212static void updatebars(void); 214static void updatebars(void);
213static void updatenumlockmask(void); 215static void updatenumlockmask(void);
214static void updatesizehints(Client *c); 216static void updatesizehints(Client *c);
@@ -389,7 +391,7 @@ buttonpress(XEvent *e) {
389 XButtonPressedEvent *ev = &e->xbutton; 391 XButtonPressedEvent *ev = &e->xbutton;
390 392
391 click = ClkRootWin; 393 click = ClkRootWin;
392 if(ev->window == selmon->barwin) { 394 if(ev->window == selmon->barwin && ev->x >= selmon->btx) {
393 i = 0; 395 i = 0;
394 x = selmon->btx; 396 x = selmon->btx;
395 do 397 do
@@ -597,6 +599,7 @@ die(const char *errstr, ...) {
597 599
598void 600void
599drawbar(Monitor *m) { 601drawbar(Monitor *m) {
602 char buf[2];
600 int x; 603 int x;
601 unsigned int i, occ = 0, urg = 0; 604 unsigned int i, occ = 0, urg = 0;
602 unsigned long *col; 605 unsigned long *col;
@@ -613,11 +616,11 @@ drawbar(Monitor *m) {
613 dc.x = 0; 616 dc.x = 0;
614#ifdef XINERAMA 617#ifdef XINERAMA
615 { 618 {
616 /* 619 buf[0] = m->screen_number + '0';
617 dc.w = TEXTW(m->symbol); 620 buf[1] = '\0';
618 drawtext(NULL, selmon == m ? dc.sel : dc.norm, False); 621 dc.w = TEXTW(buf);
622 drawtext(buf, selmon == m ? dc.sel : dc.norm, True);
619 dc.x += dc.w; 623 dc.x += dc.w;
620 */
621 } 624 }
622#endif /* XINERAMA */ 625#endif /* XINERAMA */
623 m->btx = dc.x; 626 m->btx = dc.x;
@@ -1525,7 +1528,7 @@ tile(Monitor *m) {
1525void 1528void
1526togglebar(const Arg *arg) { 1529togglebar(const Arg *arg) {
1527 selmon->showbar = !selmon->showbar; 1530 selmon->showbar = !selmon->showbar;
1528 updategeom(); 1531 updatebarpos(selmon);
1529 XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); 1532 XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
1530 arrange(); 1533 arrange();
1531} 1534}
@@ -1615,6 +1618,19 @@ updatebars(void) {
1615} 1618}
1616 1619
1617void 1620void
1621updatebarpos(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
1633void
1618updategeom(void) { 1634updategeom(void) {
1619 int i, n; 1635 int i, n;
1620 Client *c; 1636 Client *c;
@@ -1639,9 +1655,9 @@ updategeom(void) {
1639 for(i = 0, m = newmons; m; m = m->next, i++) { 1655 for(i = 0, m = newmons; m; m = m->next, i++) {
1640 m->screen_number = info[i].screen_number; 1656 m->screen_number = info[i].screen_number;
1641 m->wx = info[i].x_org; 1657 m->wx = info[i].x_org;
1642 m->wy = info[i].y_org; 1658 m->my = m->wy = info[i].y_org;
1643 m->ww = info[i].width; 1659 m->ww = info[i].width;
1644 m->wh = info[i].height; 1660 m->mh = m->wh = info[i].height;
1645 } 1661 }
1646 XFree(info); 1662 XFree(info);
1647 } 1663 }
@@ -1651,9 +1667,9 @@ updategeom(void) {
1651 { 1667 {
1652 m->screen_number = 0; 1668 m->screen_number = 0;
1653 m->wx = sx; 1669 m->wx = sx;
1654 m->wy = sy; 1670 m->my = m->wy = sy;
1655 m->ww = sw; 1671 m->ww = sw;
1656 m->wh = sh; 1672 m->mh = m->wh = sh;
1657 } 1673 }
1658 1674
1659 /* bar geometry setup */ 1675 /* bar geometry setup */
@@ -1665,13 +1681,7 @@ updategeom(void) {
1665 m->mfact = mfact; 1681 m->mfact = mfact;
1666 m->showbar = showbar; 1682 m->showbar = showbar;
1667 m->topbar = topbar; 1683 m->topbar = topbar;
1668 if(m->showbar) { 1684 updatebarpos(m);
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;
1675 /* reassign all clients with same screen number */ 1685 /* reassign all clients with same screen number */
1676 for(c = clients; c; c = c->next) 1686 for(c = clients; c; c = c->next)
1677 if(c->m->screen_number == m->screen_number) 1687 if(c->m->screen_number == m->screen_number)