aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2020-05-13 15:45:54 -0700
committerMike Crute <mike@crute.us>2020-05-13 15:45:54 -0700
commiteb5a16c95f804334543281a426229cc6e415139b (patch)
tree99eca1e3eacadb228e6d21b39faf12952819ab52
parent50790f6a751f5012a9683711b3dd3a7647775a99 (diff)
downloadst-patched-eb5a16c95f804334543281a426229cc6e415139b.tar.bz2
st-patched-eb5a16c95f804334543281a426229cc6e415139b.tar.xz
st-patched-eb5a16c95f804334543281a426229cc6e415139b.zip
apply anysize patch
-rw-r--r--x.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/x.c b/x.c
index 01b3ea7..52b1988 100644
--- a/x.c
+++ b/x.c
@@ -81,6 +81,7 @@ typedef XftGlyphFontSpec GlyphFontSpec;
81typedef struct { 81typedef struct {
82 int tw, th; /* tty width and height */ 82 int tw, th; /* tty width and height */
83 int w, h; /* window width and height */ 83 int w, h; /* window width and height */
84 int hborderpx, vborderpx;
84 int ch; /* char height */ 85 int ch; /* char height */
85 int cw; /* char width */ 86 int cw; /* char width */
86 int cyo; /* char y offset */ 87 int cyo; /* char y offset */
@@ -332,7 +333,7 @@ ttysend(const Arg *arg)
332int 333int
333evcol(XEvent *e) 334evcol(XEvent *e)
334{ 335{
335 int x = e->xbutton.x - borderpx; 336 int x = e->xbutton.x - win.hborderpx;
336 LIMIT(x, 0, win.tw - 1); 337 LIMIT(x, 0, win.tw - 1);
337 return x / win.cw; 338 return x / win.cw;
338} 339}
@@ -340,7 +341,7 @@ evcol(XEvent *e)
340int 341int
341evrow(XEvent *e) 342evrow(XEvent *e)
342{ 343{
343 int y = e->xbutton.y - borderpx; 344 int y = e->xbutton.y - win.vborderpx;
344 LIMIT(y, 0, win.th - 1); 345 LIMIT(y, 0, win.th - 1);
345 return y / win.ch; 346 return y / win.ch;
346} 347}
@@ -723,6 +724,9 @@ cresize(int width, int height)
723 col = MAX(1, col); 724 col = MAX(1, col);
724 row = MAX(1, row); 725 row = MAX(1, row);
725 726
727 win.hborderpx = (win.w - col * win.cw) / 2;
728 win.vborderpx = (win.h - row * win.ch) / 2;
729
726 tresize(col, row); 730 tresize(col, row);
727 xresize(col, row); 731 xresize(col, row);
728 ttyresize(win.tw, win.th); 732 ttyresize(win.tw, win.th);
@@ -840,8 +844,8 @@ xhints(void)
840 sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize; 844 sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
841 sizeh->height = win.h; 845 sizeh->height = win.h;
842 sizeh->width = win.w; 846 sizeh->width = win.w;
843 sizeh->height_inc = win.ch; 847 sizeh->height_inc = 1;
844 sizeh->width_inc = win.cw; 848 sizeh->width_inc = 1;
845 sizeh->base_height = 2 * borderpx; 849 sizeh->base_height = 2 * borderpx;
846 sizeh->base_width = 2 * borderpx; 850 sizeh->base_width = 2 * borderpx;
847 sizeh->min_height = win.ch + 2 * borderpx; 851 sizeh->min_height = win.ch + 2 * borderpx;
@@ -1124,8 +1128,8 @@ xinit(int cols, int rows)
1124 xloadcols(); 1128 xloadcols();
1125 1129
1126 /* adjust fixed window geometry */ 1130 /* adjust fixed window geometry */
1127 win.w = 2 * borderpx + cols * win.cw; 1131 win.w = 2 * win.hborderpx + cols * win.cw;
1128 win.h = 2 * borderpx + rows * win.ch; 1132 win.h = 2 * win.vborderpx + rows * win.ch;
1129 if (xw.gm & XNegative) 1133 if (xw.gm & XNegative)
1130 xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2; 1134 xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
1131 if (xw.gm & YNegative) 1135 if (xw.gm & YNegative)
@@ -1213,7 +1217,7 @@ xinit(int cols, int rows)
1213int 1217int
1214xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y) 1218xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y)
1215{ 1219{
1216 float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp; 1220 float winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch, xp, yp;
1217 ushort mode, prevmode = USHRT_MAX; 1221 ushort mode, prevmode = USHRT_MAX;
1218 Font *font = &dc.font; 1222 Font *font = &dc.font;
1219 int frcflags = FRC_NORMAL; 1223 int frcflags = FRC_NORMAL;
@@ -1346,7 +1350,7 @@ void
1346xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y) 1350xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
1347{ 1351{
1348 int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1); 1352 int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
1349 int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, 1353 int winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch,
1350 width = charlen * win.cw; 1354 width = charlen * win.cw;
1351 Color *fg, *bg, *temp, revfg, revbg, truefg, truebg; 1355 Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
1352 XRenderColor colfg, colbg; 1356 XRenderColor colfg, colbg;
@@ -1436,17 +1440,17 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
1436 1440
1437 /* Intelligent cleaning up of the borders. */ 1441 /* Intelligent cleaning up of the borders. */
1438 if (x == 0) { 1442 if (x == 0) {
1439 xclear(0, (y == 0)? 0 : winy, borderpx, 1443 xclear(0, (y == 0)? 0 : winy, win.vborderpx,
1440 winy + win.ch + 1444 winy + win.ch +
1441 ((winy + win.ch >= borderpx + win.th)? win.h : 0)); 1445 ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
1442 } 1446 }
1443 if (winx + width >= borderpx + win.tw) { 1447 if (winx + width >= win.hborderpx + win.tw) {
1444 xclear(winx + width, (y == 0)? 0 : winy, win.w, 1448 xclear(winx + width, (y == 0)? 0 : winy, win.w,
1445 ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch))); 1449 ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
1446 } 1450 }
1447 if (y == 0) 1451 if (y == 0)
1448 xclear(winx, 0, winx + width, borderpx); 1452 xclear(winx, 0, winx + width, win.hborderpx);
1449 if (winy + win.ch >= borderpx + win.th) 1453 if (winy + win.ch >= win.vborderpx + win.th)
1450 xclear(winx, winy + win.ch, winx + width, win.h); 1454 xclear(winx, winy + win.ch, winx + width, win.h);
1451 1455
1452 /* Clean up the region we want to draw to. */ 1456 /* Clean up the region we want to draw to. */
@@ -1540,35 +1544,35 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
1540 case 3: /* Blinking Underline */ 1544 case 3: /* Blinking Underline */
1541 case 4: /* Steady Underline */ 1545 case 4: /* Steady Underline */
1542 XftDrawRect(xw.draw, &drawcol, 1546 XftDrawRect(xw.draw, &drawcol,
1543 borderpx + cx * win.cw, 1547 win.hborderpx + cx * win.cw,
1544 borderpx + (cy + 1) * win.ch - \ 1548 win.vborderpx + (cy + 1) * win.ch - \
1545 cursorthickness, 1549 cursorthickness,
1546 win.cw, cursorthickness); 1550 win.cw, cursorthickness);
1547 break; 1551 break;
1548 case 5: /* Blinking bar */ 1552 case 5: /* Blinking bar */
1549 case 6: /* Steady bar */ 1553 case 6: /* Steady bar */
1550 XftDrawRect(xw.draw, &drawcol, 1554 XftDrawRect(xw.draw, &drawcol,
1551 borderpx + cx * win.cw, 1555 win.hborderpx + cx * win.cw,
1552 borderpx + cy * win.ch, 1556 win.vborderpx + cy * win.ch,
1553 cursorthickness, win.ch); 1557 cursorthickness, win.ch);
1554 break; 1558 break;
1555 } 1559 }
1556 } else { 1560 } else {
1557 XftDrawRect(xw.draw, &drawcol, 1561 XftDrawRect(xw.draw, &drawcol,
1558 borderpx + cx * win.cw, 1562 win.hborderpx + cx * win.cw,
1559 borderpx + cy * win.ch, 1563 win.vborderpx + cy * win.ch,
1560 win.cw - 1, 1); 1564 win.cw - 1, 1);
1561 XftDrawRect(xw.draw, &drawcol, 1565 XftDrawRect(xw.draw, &drawcol,
1562 borderpx + cx * win.cw, 1566 win.hborderpx + cx * win.cw,
1563 borderpx + cy * win.ch, 1567 win.vborderpx + cy * win.ch,
1564 1, win.ch - 1); 1568 1, win.ch - 1);
1565 XftDrawRect(xw.draw, &drawcol, 1569 XftDrawRect(xw.draw, &drawcol,
1566 borderpx + (cx + 1) * win.cw - 1, 1570 win.hborderpx + (cx + 1) * win.cw - 1,
1567 borderpx + cy * win.ch, 1571 win.vborderpx + cy * win.ch,
1568 1, win.ch - 1); 1572 1, win.ch - 1);
1569 XftDrawRect(xw.draw, &drawcol, 1573 XftDrawRect(xw.draw, &drawcol,
1570 borderpx + cx * win.cw, 1574 win.hborderpx + cx * win.cw,
1571 borderpx + (cy + 1) * win.ch - 1, 1575 win.vborderpx + (cy + 1) * win.ch - 1,
1572 win.cw, 1); 1576 win.cw, 1);
1573 } 1577 }
1574} 1578}