aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2020-12-22 15:56:55 -0800
committerMike Crute <mike@crute.us>2023-04-25 20:45:27 -0700
commit142f3fd3cfdeebe6105c462af8bb07930b49f23a (patch)
treef8cfb07f531d0b6095ee37e636b1b950c64ac9af
parent1c37db01681817c8f868251d355b6ce5792c3adf (diff)
downloadst-patched-142f3fd3cfdeebe6105c462af8bb07930b49f23a.tar.bz2
st-patched-142f3fd3cfdeebe6105c462af8bb07930b49f23a.tar.xz
st-patched-142f3fd3cfdeebe6105c462af8bb07930b49f23a.zip
Apply st-anysize-20201003-407a3d0
-rw-r--r--x.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/x.c b/x.c
index 1dfedbf..04fd748 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 mode; /* window state/mode flags */ 87 int mode; /* window state/mode flags */
@@ -331,7 +332,7 @@ ttysend(const Arg *arg)
331int 332int
332evcol(XEvent *e) 333evcol(XEvent *e)
333{ 334{
334 int x = e->xbutton.x - borderpx; 335 int x = e->xbutton.x - win.hborderpx;
335 LIMIT(x, 0, win.tw - 1); 336 LIMIT(x, 0, win.tw - 1);
336 return x / win.cw; 337 return x / win.cw;
337} 338}
@@ -339,7 +340,7 @@ evcol(XEvent *e)
339int 340int
340evrow(XEvent *e) 341evrow(XEvent *e)
341{ 342{
342 int y = e->xbutton.y - borderpx; 343 int y = e->xbutton.y - win.vborderpx;
343 LIMIT(y, 0, win.th - 1); 344 LIMIT(y, 0, win.th - 1);
344 return y / win.ch; 345 return y / win.ch;
345} 346}
@@ -740,6 +741,9 @@ cresize(int width, int height)
740 col = MAX(1, col); 741 col = MAX(1, col);
741 row = MAX(1, row); 742 row = MAX(1, row);
742 743
744 win.hborderpx = (win.w - col * win.cw) / 2;
745 win.vborderpx = (win.h - row * win.ch) / 2;
746
743 tresize(col, row); 747 tresize(col, row);
744 xresize(col, row); 748 xresize(col, row);
745 ttyresize(win.tw, win.th); 749 ttyresize(win.tw, win.th);
@@ -1153,8 +1157,8 @@ xinit(int cols, int rows)
1153 xloadcols(); 1157 xloadcols();
1154 1158
1155 /* adjust fixed window geometry */ 1159 /* adjust fixed window geometry */
1156 win.w = 2 * borderpx + cols * win.cw; 1160 win.w = 2 * win.hborderpx + cols * win.cw;
1157 win.h = 2 * borderpx + rows * win.ch; 1161 win.h = 2 * win.vborderpx + rows * win.ch;
1158 if (xw.gm & XNegative) 1162 if (xw.gm & XNegative)
1159 xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2; 1163 xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
1160 if (xw.gm & YNegative) 1164 if (xw.gm & YNegative)
@@ -1243,7 +1247,7 @@ xinit(int cols, int rows)
1243int 1247int
1244xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y) 1248xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y)
1245{ 1249{
1246 float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp; 1250 float winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch, xp, yp;
1247 ushort mode, prevmode = USHRT_MAX; 1251 ushort mode, prevmode = USHRT_MAX;
1248 Font *font = &dc.font; 1252 Font *font = &dc.font;
1249 int frcflags = FRC_NORMAL; 1253 int frcflags = FRC_NORMAL;
@@ -1376,7 +1380,7 @@ void
1376xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y) 1380xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
1377{ 1381{
1378 int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1); 1382 int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
1379 int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, 1383 int winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch,
1380 width = charlen * win.cw; 1384 width = charlen * win.cw;
1381 Color *fg, *bg, *temp, revfg, revbg, truefg, truebg; 1385 Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
1382 XRenderColor colfg, colbg; 1386 XRenderColor colfg, colbg;
@@ -1466,17 +1470,17 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
1466 1470
1467 /* Intelligent cleaning up of the borders. */ 1471 /* Intelligent cleaning up of the borders. */
1468 if (x == 0) { 1472 if (x == 0) {
1469 xclear(0, (y == 0)? 0 : winy, borderpx, 1473 xclear(0, (y == 0)? 0 : winy, win.vborderpx,
1470 winy + win.ch + 1474 winy + win.ch +
1471 ((winy + win.ch >= borderpx + win.th)? win.h : 0)); 1475 ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
1472 } 1476 }
1473 if (winx + width >= borderpx + win.tw) { 1477 if (winx + width >= win.hborderpx + win.tw) {
1474 xclear(winx + width, (y == 0)? 0 : winy, win.w, 1478 xclear(winx + width, (y == 0)? 0 : winy, win.w,
1475 ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch))); 1479 ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
1476 } 1480 }
1477 if (y == 0) 1481 if (y == 0)
1478 xclear(winx, 0, winx + width, borderpx); 1482 xclear(winx, 0, winx + width, win.hborderpx);
1479 if (winy + win.ch >= borderpx + win.th) 1483 if (winy + win.ch >= win.vborderpx + win.th)
1480 xclear(winx, winy + win.ch, winx + width, win.h); 1484 xclear(winx, winy + win.ch, winx + width, win.h);
1481 1485
1482 /* Clean up the region we want to draw to. */ 1486 /* Clean up the region we want to draw to. */
@@ -1570,35 +1574,35 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
1570 case 3: /* Blinking Underline */ 1574 case 3: /* Blinking Underline */
1571 case 4: /* Steady Underline */ 1575 case 4: /* Steady Underline */
1572 XftDrawRect(xw.draw, &drawcol, 1576 XftDrawRect(xw.draw, &drawcol,
1573 borderpx + cx * win.cw, 1577 win.hborderpx + cx * win.cw,
1574 borderpx + (cy + 1) * win.ch - \ 1578 win.vborderpx + (cy + 1) * win.ch - \
1575 cursorthickness, 1579 cursorthickness,
1576 win.cw, cursorthickness); 1580 win.cw, cursorthickness);
1577 break; 1581 break;
1578 case 5: /* Blinking bar */ 1582 case 5: /* Blinking bar */
1579 case 6: /* Steady bar */ 1583 case 6: /* Steady bar */
1580 XftDrawRect(xw.draw, &drawcol, 1584 XftDrawRect(xw.draw, &drawcol,
1581 borderpx + cx * win.cw, 1585 win.hborderpx + cx * win.cw,
1582 borderpx + cy * win.ch, 1586 win.vborderpx + cy * win.ch,
1583 cursorthickness, win.ch); 1587 cursorthickness, win.ch);
1584 break; 1588 break;
1585 } 1589 }
1586 } else { 1590 } else {
1587 XftDrawRect(xw.draw, &drawcol, 1591 XftDrawRect(xw.draw, &drawcol,
1588 borderpx + cx * win.cw, 1592 win.hborderpx + cx * win.cw,
1589 borderpx + cy * win.ch, 1593 win.vborderpx + cy * win.ch,
1590 win.cw - 1, 1); 1594 win.cw - 1, 1);
1591 XftDrawRect(xw.draw, &drawcol, 1595 XftDrawRect(xw.draw, &drawcol,
1592 borderpx + cx * win.cw, 1596 win.hborderpx + cx * win.cw,
1593 borderpx + cy * win.ch, 1597 win.vborderpx + cy * win.ch,
1594 1, win.ch - 1); 1598 1, win.ch - 1);
1595 XftDrawRect(xw.draw, &drawcol, 1599 XftDrawRect(xw.draw, &drawcol,
1596 borderpx + (cx + 1) * win.cw - 1, 1600 win.hborderpx + (cx + 1) * win.cw - 1,
1597 borderpx + cy * win.ch, 1601 win.vborderpx + cy * win.ch,
1598 1, win.ch - 1); 1602 1, win.ch - 1);
1599 XftDrawRect(xw.draw, &drawcol, 1603 XftDrawRect(xw.draw, &drawcol,
1600 borderpx + cx * win.cw, 1604 win.hborderpx + cx * win.cw,
1601 borderpx + (cy + 1) * win.ch - 1, 1605 win.vborderpx + (cy + 1) * win.ch - 1,
1602 win.cw, 1); 1606 win.cw, 1);
1603 } 1607 }
1604} 1608}