added bx, by, bw, wx, wy, ww, wh, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh ad variables
47b19744
1 file(s) · +72 −41
| 191 | 191 | char stext[256], buf[256]; |
|
| 192 | 192 | int screen, sx, sy, sw, sh; |
|
| 193 | 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 | 195 | unsigned int numlockmask = 0; |
|
| 196 | 196 | void (*handler[LASTEvent]) (XEvent *) = { |
|
| 197 | 197 | [ButtonPress] = buttonpress, |
|
| 407 | 407 | sw = ev->width; |
|
| 408 | 408 | sh = ev->height; |
|
| 409 | 409 | XFreePixmap(dpy, dc.drawable); |
|
| 410 | - | dc.drawable = XCreatePixmap(dpy, root, BW, bh, DefaultDepth(dpy, screen)); |
|
| 411 | - | XMoveResizeWindow(dpy, barwin, BX, BY, BW, bh); |
|
| 410 | + | dc.drawable = XCreatePixmap(dpy, root, bw, bh, DefaultDepth(dpy, screen)); |
|
| 411 | + | XMoveResizeWindow(dpy, barwin, bx, by, bw, bh); |
|
| 412 | 412 | arrange(); |
|
| 413 | 413 | } |
|
| 414 | 414 | } |
|
| 508 | 508 | drawtext(lt->symbol, dc.norm, False); |
|
| 509 | 509 | x = dc.x + dc.w; |
|
| 510 | 510 | dc.w = textw(stext); |
|
| 511 | - | dc.x = BW - dc.w; |
|
| 511 | + | dc.x = bw - dc.w; |
|
| 512 | 512 | if(dc.x < x) { |
|
| 513 | 513 | dc.x = x; |
|
| 514 | - | dc.w = BW - x; |
|
| 514 | + | dc.w = bw - x; |
|
| 515 | 515 | } |
|
| 516 | 516 | drawtext(stext, dc.norm, False); |
|
| 517 | 517 | if((dc.w = dc.x - x) > bh) { |
|
| 523 | 523 | else |
|
| 524 | 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 | 527 | XSync(dpy, False); |
|
| 528 | 528 | } |
|
| 529 | 529 | ||
| 981 | 981 | c->border = wa->border_width; |
|
| 982 | 982 | } |
|
| 983 | 983 | else { |
|
| 984 | - | if(c->x + c->w + 2 * c->border > WX + WW) |
|
| 985 | - | c->x = WX + WW - c->w - 2 * c->border; |
|
| 986 | - | if(c->y + c->h + 2 * c->border > WY + WH) |
|
| 987 | - | c->y = WY + WH - c->h - 2 * c->border; |
|
| 988 | - | if(c->x < WX) |
|
| 989 | - | c->x = WX; |
|
| 990 | - | if(c->y < WY) |
|
| 991 | - | c->y = WY; |
|
| 984 | + | if(c->x + c->w + 2 * c->border > wx + ww) |
|
| 985 | + | c->x = wx + ww - c->w - 2 * c->border; |
|
| 986 | + | if(c->y + c->h + 2 * c->border > wy + wh) |
|
| 987 | + | c->y = wy + wh - c->h - 2 * c->border; |
|
| 988 | + | if(c->x < wx) |
|
| 989 | + | c->x = wx; |
|
| 990 | + | if(c->y < wy) |
|
| 991 | + | c->y = wy; |
|
| 992 | 992 | c->border = BORDERPX; |
|
| 993 | 993 | } |
|
| 994 | 994 | ||
| 1045 | 1045 | ||
| 1046 | 1046 | for(c = clients; c; c = c->next) |
|
| 1047 | 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 | 1051 | void |
|
| 1076 | 1076 | XSync(dpy, False); |
|
| 1077 | 1077 | nx = ocx + (ev.xmotion.x - x1); |
|
| 1078 | 1078 | ny = ocy + (ev.xmotion.y - y1); |
|
| 1079 | - | if(abs(WX - nx) < SNAP) |
|
| 1080 | - | nx = WX; |
|
| 1081 | - | else if(abs((WX + WW) - (nx + c->w + 2 * c->border)) < SNAP) |
|
| 1082 | - | nx = WX + WW - c->w - 2 * c->border; |
|
| 1083 | - | if(abs(WY - ny) < SNAP) |
|
| 1084 | - | ny = WY; |
|
| 1085 | - | else if(abs((WY + WH) - (ny + c->h + 2 * c->border)) < SNAP) |
|
| 1086 | - | ny = WY + WH - c->h - 2 * c->border; |
|
| 1079 | + | if(abs(wx - nx) < SNAP) |
|
| 1080 | + | nx = wx; |
|
| 1081 | + | else if(abs((wx + ww) - (nx + c->w + 2 * c->border)) < SNAP) |
|
| 1082 | + | nx = wx + ww - c->w - 2 * c->border; |
|
| 1083 | + | if(abs(wy - ny) < SNAP) |
|
| 1084 | + | ny = wy; |
|
| 1085 | + | else if(abs((wy + wh) - (ny + c->h + 2 * c->border)) < SNAP) |
|
| 1086 | + | ny = wy + wh - c->h - 2 * c->border; |
|
| 1087 | 1087 | if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) |
|
| 1088 | 1088 | togglefloating(NULL); |
|
| 1089 | 1089 | if((lt->isfloating) || c->isfloating) |
|
| 1451 | 1451 | /* init layouts */ |
|
| 1452 | 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 | 1483 | /* init bar */ |
|
| 1455 | 1484 | for(blw = i = 0; i < LENGTH(layouts); i++) { |
|
| 1456 | 1485 | i = textw(layouts[i].symbol); |
|
| 1462 | 1491 | wa.background_pixmap = ParentRelative; |
|
| 1463 | 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 | 1497 | CopyFromParent, DefaultVisual(dpy, screen), |
|
| 1467 | 1498 | CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); |
|
| 1468 | 1499 | XDefineCursor(dpy, barwin, cursor[CurNormal]); |
|
| 1558 | 1589 | if(n == 0) |
|
| 1559 | 1590 | return; |
|
| 1560 | 1591 | ||
| 1561 | - | x = TX; |
|
| 1562 | - | w = (TW) / n; |
|
| 1592 | + | x = tx; |
|
| 1593 | + | w = tw / n; |
|
| 1563 | 1594 | if(w < bh) |
|
| 1564 | - | w = TW; |
|
| 1595 | + | w = tw; |
|
| 1565 | 1596 | ||
| 1566 | 1597 | for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) |
|
| 1567 | 1598 | if(i > 0) { |
|
| 1568 | 1599 | if(i > 1 && i == n) /* remainder */ |
|
| 1569 | - | tileresize(c, x, TY, ((TX) + (TW)) - x - 2 * c->border, |
|
| 1570 | - | TH - 2 * c->border); |
|
| 1600 | + | tileresize(c, x, ty, (tx + tw) - x - 2 * c->border, |
|
| 1601 | + | th - 2 * c->border); |
|
| 1571 | 1602 | else |
|
| 1572 | - | tileresize(c, x, TY, w - 2 * c->border, |
|
| 1573 | - | TH - 2 * c->border); |
|
| 1574 | - | if(w != TW) |
|
| 1603 | + | tileresize(c, x, ty, w - 2 * c->border, |
|
| 1604 | + | th - 2 * c->border); |
|
| 1605 | + | if(w != tw) |
|
| 1575 | 1606 | x = c->x + c->w + 2 * c->border; |
|
| 1576 | 1607 | } |
|
| 1577 | 1608 | } |
|
| 1586 | 1617 | if(n == 0) |
|
| 1587 | 1618 | return 0; |
|
| 1588 | 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 | 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 | 1623 | return n - 1; |
|
| 1593 | 1624 | } |
|
| 1594 | 1625 | ||
| 1605 | 1636 | if(n == 0) |
|
| 1606 | 1637 | return; |
|
| 1607 | 1638 | ||
| 1608 | - | y = TY; |
|
| 1609 | - | h = (TH) / n; |
|
| 1639 | + | y = ty; |
|
| 1640 | + | h = th / n; |
|
| 1610 | 1641 | if(h < bh) |
|
| 1611 | - | h = TH; |
|
| 1642 | + | h = th; |
|
| 1612 | 1643 | ||
| 1613 | 1644 | for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) |
|
| 1614 | 1645 | if(i > 0) { |
|
| 1615 | 1646 | if(i > 1 && i == n) /* remainder */ |
|
| 1616 | - | tileresize(c, TX, y, (TW) - 2 * c->border, |
|
| 1617 | - | ((TY) + (TH)) - y - 2 * c->border); |
|
| 1647 | + | tileresize(c, tx, y, tw - 2 * c->border, |
|
| 1648 | + | (ty + th) - y - 2 * c->border); |
|
| 1618 | 1649 | else |
|
| 1619 | - | tileresize(c, TX, y, (TW) - 2 * c->border, |
|
| 1650 | + | tileresize(c, tx, y, tw - 2 * c->border, |
|
| 1620 | 1651 | h - 2 * c->border); |
|
| 1621 | - | if(h != TH) |
|
| 1652 | + | if(h != th) |
|
| 1622 | 1653 | y = c->y + c->h + 2 * c->border; |
|
| 1623 | 1654 | } |
|
| 1624 | 1655 | } |
|