diff options
| -rw-r--r-- | dwm.c | 113 |
1 files changed, 72 insertions, 41 deletions
| @@ -191,7 +191,7 @@ void zoom(const char *arg); | |||
| 191 | char stext[256], buf[256]; | 191 | char stext[256], buf[256]; |
| 192 | int screen, sx, sy, sw, sh; | 192 | int screen, sx, sy, sw, sh; |
| 193 | int (*xerrorxlib)(Display *, XErrorEvent *); | 193 | int (*xerrorxlib)(Display *, XErrorEvent *); |
| 194 | unsigned int bh, blw = 0; | 194 | int bx, by, bw, bh, blw, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh; |
| 195 | unsigned int numlockmask = 0; | 195 | unsigned int numlockmask = 0; |
| 196 | void (*handler[LASTEvent]) (XEvent *) = { | 196 | void (*handler[LASTEvent]) (XEvent *) = { |
| 197 | [ButtonPress] = buttonpress, | 197 | [ButtonPress] = buttonpress, |
| @@ -407,8 +407,8 @@ configurenotify(XEvent *e) { | |||
| 407 | sw = ev->width; | 407 | sw = ev->width; |
| 408 | sh = ev->height; | 408 | sh = ev->height; |
| 409 | XFreePixmap(dpy, dc.drawable); | 409 | XFreePixmap(dpy, dc.drawable); |
| 410 | dc.drawable = XCreatePixmap(dpy, root, BW, bh, DefaultDepth(dpy, screen)); | 410 | dc.drawable = XCreatePixmap(dpy, root, bw, bh, DefaultDepth(dpy, screen)); |
| 411 | XMoveResizeWindow(dpy, barwin, BX, BY, BW, bh); | 411 | XMoveResizeWindow(dpy, barwin, bx, by, bw, bh); |
| 412 | arrange(); | 412 | arrange(); |
| 413 | } | 413 | } |
| 414 | } | 414 | } |
| @@ -508,10 +508,10 @@ drawbar(void) { | |||
| 508 | drawtext(lt->symbol, dc.norm, False); | 508 | drawtext(lt->symbol, dc.norm, False); |
| 509 | x = dc.x + dc.w; | 509 | x = dc.x + dc.w; |
| 510 | dc.w = textw(stext); | 510 | dc.w = textw(stext); |
| 511 | dc.x = BW - dc.w; | 511 | dc.x = bw - dc.w; |
| 512 | if(dc.x < x) { | 512 | if(dc.x < x) { |
| 513 | dc.x = x; | 513 | dc.x = x; |
| 514 | dc.w = BW - x; | 514 | dc.w = bw - x; |
| 515 | } | 515 | } |
| 516 | drawtext(stext, dc.norm, False); | 516 | drawtext(stext, dc.norm, False); |
| 517 | if((dc.w = dc.x - x) > bh) { | 517 | if((dc.w = dc.x - x) > bh) { |
| @@ -523,7 +523,7 @@ drawbar(void) { | |||
| 523 | else | 523 | else |
| 524 | drawtext(NULL, dc.norm, False); | 524 | drawtext(NULL, dc.norm, False); |
| 525 | } | 525 | } |
| 526 | XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, BW, bh, 0, 0); | 526 | XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); |
| 527 | XSync(dpy, False); | 527 | XSync(dpy, False); |
| 528 | } | 528 | } |
| 529 | 529 | ||
| @@ -981,14 +981,14 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 981 | c->border = wa->border_width; | 981 | c->border = wa->border_width; |
| 982 | } | 982 | } |
| 983 | else { | 983 | else { |
| 984 | if(c->x + c->w + 2 * c->border > WX + WW) | 984 | if(c->x + c->w + 2 * c->border > wx + ww) |
| 985 | c->x = WX + WW - c->w - 2 * c->border; | 985 | c->x = wx + ww - c->w - 2 * c->border; |
| 986 | if(c->y + c->h + 2 * c->border > WY + WH) | 986 | if(c->y + c->h + 2 * c->border > wy + wh) |
| 987 | c->y = WY + WH - c->h - 2 * c->border; | 987 | c->y = wy + wh - c->h - 2 * c->border; |
| 988 | if(c->x < WX) | 988 | if(c->x < wx) |
| 989 | c->x = WX; | 989 | c->x = wx; |
| 990 | if(c->y < WY) | 990 | if(c->y < wy) |
| 991 | c->y = WY; | 991 | c->y = wy; |
| 992 | c->border = BORDERPX; | 992 | c->border = BORDERPX; |
| 993 | } | 993 | } |
| 994 | 994 | ||
| @@ -1045,7 +1045,7 @@ monocle(void) { | |||
| 1045 | 1045 | ||
| 1046 | for(c = clients; c; c = c->next) | 1046 | for(c = clients; c; c = c->next) |
| 1047 | if(isvisible(c)) | 1047 | if(isvisible(c)) |
| 1048 | resize(c, MOX, MOY, MOW, MOH, RESIZEHINTS); | 1048 | resize(c, mox, moy, mow, moh, RESIZEHINTS); |
| 1049 | } | 1049 | } |
| 1050 | 1050 | ||
| 1051 | void | 1051 | void |
| @@ -1076,14 +1076,14 @@ movemouse(Client *c) { | |||
| 1076 | XSync(dpy, False); | 1076 | XSync(dpy, False); |
| 1077 | nx = ocx + (ev.xmotion.x - x1); | 1077 | nx = ocx + (ev.xmotion.x - x1); |
| 1078 | ny = ocy + (ev.xmotion.y - y1); | 1078 | ny = ocy + (ev.xmotion.y - y1); |
| 1079 | if(abs(WX - nx) < SNAP) | 1079 | if(abs(wx - nx) < SNAP) |
| 1080 | nx = WX; | 1080 | nx = wx; |
| 1081 | else if(abs((WX + WW) - (nx + c->w + 2 * c->border)) < SNAP) | 1081 | else if(abs((wx + ww) - (nx + c->w + 2 * c->border)) < SNAP) |
| 1082 | nx = WX + WW - c->w - 2 * c->border; | 1082 | nx = wx + ww - c->w - 2 * c->border; |
| 1083 | if(abs(WY - ny) < SNAP) | 1083 | if(abs(wy - ny) < SNAP) |
| 1084 | ny = WY; | 1084 | ny = wy; |
| 1085 | else if(abs((WY + WH) - (ny + c->h + 2 * c->border)) < SNAP) | 1085 | else if(abs((wy + wh) - (ny + c->h + 2 * c->border)) < SNAP) |
| 1086 | ny = WY + WH - c->h - 2 * c->border; | 1086 | ny = wy + wh - c->h - 2 * c->border; |
| 1087 | if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) | 1087 | if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) |
| 1088 | togglefloating(NULL); | 1088 | togglefloating(NULL); |
| 1089 | if((lt->isfloating) || c->isfloating) | 1089 | if((lt->isfloating) || c->isfloating) |
| @@ -1451,6 +1451,35 @@ setup(void) { | |||
| 1451 | /* init layouts */ | 1451 | /* init layouts */ |
| 1452 | lt = &layouts[0]; | 1452 | lt = &layouts[0]; |
| 1453 | 1453 | ||
| 1454 | /* bar position */ | ||
| 1455 | bx = BX; | ||
| 1456 | by = BY; | ||
| 1457 | bw = BW; | ||
| 1458 | |||
| 1459 | /* window area */ | ||
| 1460 | wx = WX; | ||
| 1461 | wy = WY; | ||
| 1462 | ww = WW; | ||
| 1463 | wh = WH; | ||
| 1464 | |||
| 1465 | /* master area */ | ||
| 1466 | mx = MX; | ||
| 1467 | my = MY; | ||
| 1468 | mw = MW; | ||
| 1469 | mh = MH; | ||
| 1470 | |||
| 1471 | /* tile area */ | ||
| 1472 | tx = TX; | ||
| 1473 | ty = TY; | ||
| 1474 | tw = TW; | ||
| 1475 | th = TH; | ||
| 1476 | |||
| 1477 | /* monocle area */ | ||
| 1478 | mox = MOX; | ||
| 1479 | moy = MOY; | ||
| 1480 | mow = MOW; | ||
| 1481 | moh = MOH; | ||
| 1482 | |||
| 1454 | /* init bar */ | 1483 | /* init bar */ |
| 1455 | for(blw = i = 0; i < LENGTH(layouts); i++) { | 1484 | for(blw = i = 0; i < LENGTH(layouts); i++) { |
| 1456 | i = textw(layouts[i].symbol); | 1485 | i = textw(layouts[i].symbol); |
| @@ -1462,7 +1491,9 @@ setup(void) { | |||
| 1462 | wa.background_pixmap = ParentRelative; | 1491 | wa.background_pixmap = ParentRelative; |
| 1463 | wa.event_mask = ButtonPressMask|ExposureMask; | 1492 | wa.event_mask = ButtonPressMask|ExposureMask; |
| 1464 | 1493 | ||
| 1465 | barwin = XCreateWindow(dpy, root, BX, BY, BW, bh, 0, DefaultDepth(dpy, screen), | 1494 | |
| 1495 | |||
| 1496 | barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen), | ||
| 1466 | CopyFromParent, DefaultVisual(dpy, screen), | 1497 | CopyFromParent, DefaultVisual(dpy, screen), |
| 1467 | CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); | 1498 | CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); |
| 1468 | XDefineCursor(dpy, barwin, cursor[CurNormal]); | 1499 | XDefineCursor(dpy, barwin, cursor[CurNormal]); |
| @@ -1558,20 +1589,20 @@ tilehstack(unsigned int n) { | |||
| 1558 | if(n == 0) | 1589 | if(n == 0) |
| 1559 | return; | 1590 | return; |
| 1560 | 1591 | ||
| 1561 | x = TX; | 1592 | x = tx; |
| 1562 | w = (TW) / n; | 1593 | w = tw / n; |
| 1563 | if(w < bh) | 1594 | if(w < bh) |
| 1564 | w = TW; | 1595 | w = tw; |
| 1565 | 1596 | ||
| 1566 | for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) | 1597 | for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) |
| 1567 | if(i > 0) { | 1598 | if(i > 0) { |
| 1568 | if(i > 1 && i == n) /* remainder */ | 1599 | if(i > 1 && i == n) /* remainder */ |
| 1569 | tileresize(c, x, TY, ((TX) + (TW)) - x - 2 * c->border, | 1600 | tileresize(c, x, ty, (tx + tw) - x - 2 * c->border, |
| 1570 | TH - 2 * c->border); | 1601 | th - 2 * c->border); |
| 1571 | else | 1602 | else |
| 1572 | tileresize(c, x, TY, w - 2 * c->border, | 1603 | tileresize(c, x, ty, w - 2 * c->border, |
| 1573 | TH - 2 * c->border); | 1604 | th - 2 * c->border); |
| 1574 | if(w != TW) | 1605 | if(w != tw) |
| 1575 | x = c->x + c->w + 2 * c->border; | 1606 | x = c->x + c->w + 2 * c->border; |
| 1576 | } | 1607 | } |
| 1577 | } | 1608 | } |
| @@ -1586,9 +1617,9 @@ tilemaster(void) { | |||
| 1586 | if(n == 0) | 1617 | if(n == 0) |
| 1587 | return 0; | 1618 | return 0; |
| 1588 | if(n == 1) | 1619 | if(n == 1) |
| 1589 | tileresize(mc, MOX, MOY, (MOW) - 2 * mc->border, (MOH) - 2 * mc->border); | 1620 | tileresize(mc, mox, moy, mow - 2 * mc->border, moh - 2 * mc->border); |
| 1590 | else | 1621 | else |
| 1591 | tileresize(mc, MX, MY, (MW) - 2 * mc->border, (MH) - 2 * mc->border); | 1622 | tileresize(mc, mx, my, mw - 2 * mc->border, mh - 2 * mc->border); |
| 1592 | return n - 1; | 1623 | return n - 1; |
| 1593 | } | 1624 | } |
| 1594 | 1625 | ||
| @@ -1605,20 +1636,20 @@ tilevstack(unsigned int n) { | |||
| 1605 | if(n == 0) | 1636 | if(n == 0) |
| 1606 | return; | 1637 | return; |
| 1607 | 1638 | ||
| 1608 | y = TY; | 1639 | y = ty; |
| 1609 | h = (TH) / n; | 1640 | h = th / n; |
| 1610 | if(h < bh) | 1641 | if(h < bh) |
| 1611 | h = TH; | 1642 | h = th; |
| 1612 | 1643 | ||
| 1613 | for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) | 1644 | for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) |
| 1614 | if(i > 0) { | 1645 | if(i > 0) { |
| 1615 | if(i > 1 && i == n) /* remainder */ | 1646 | if(i > 1 && i == n) /* remainder */ |
| 1616 | tileresize(c, TX, y, (TW) - 2 * c->border, | 1647 | tileresize(c, tx, y, tw - 2 * c->border, |
| 1617 | ((TY) + (TH)) - y - 2 * c->border); | 1648 | (ty + th) - y - 2 * c->border); |
| 1618 | else | 1649 | else |
| 1619 | tileresize(c, TX, y, (TW) - 2 * c->border, | 1650 | tileresize(c, tx, y, tw - 2 * c->border, |
| 1620 | h - 2 * c->border); | 1651 | h - 2 * c->border); |
| 1621 | if(h != TH) | 1652 | if(h != th) |
| 1622 | y = c->y + c->h + 2 * c->border; | 1653 | y = c->y + c->h + 2 * c->border; |
| 1623 | } | 1654 | } |
| 1624 | } | 1655 | } |
