st-anysize-0.8.1.diff (5028B)
1 diff --git a/x.c b/x.c 2 index 00cb6b1..8f87c0f 100644 3 --- a/x.c 4 +++ b/x.c 5 @@ -78,6 +78,7 @@ typedef XftGlyphFontSpec GlyphFontSpec; 6 typedef struct { 7 int tw, th; /* tty width and height */ 8 int w, h; /* window width and height */ 9 + int hborderpx, vborderpx; 10 int ch; /* char height */ 11 int cw; /* char width */ 12 int mode; /* window state/mode flags */ 13 @@ -311,7 +312,7 @@ zoomreset(const Arg *arg) 14 int 15 evcol(XEvent *e) 16 { 17 - int x = e->xbutton.x - borderpx; 18 + int x = e->xbutton.x - win.hborderpx; 19 LIMIT(x, 0, win.tw - 1); 20 return x / win.cw; 21 } 22 @@ -319,7 +320,7 @@ evcol(XEvent *e) 23 int 24 evrow(XEvent *e) 25 { 26 - int y = e->xbutton.y - borderpx; 27 + int y = e->xbutton.y - win.vborderpx; 28 LIMIT(y, 0, win.th - 1); 29 return y / win.ch; 30 } 31 @@ -675,6 +676,9 @@ cresize(int width, int height) 32 col = MAX(1, col); 33 row = MAX(1, row); 34 35 + win.hborderpx = (win.w - col * win.cw) / 2; 36 + win.vborderpx = (win.h - row * win.ch) / 2; 37 + 38 tresize(col, row); 39 xresize(col, row); 40 ttyresize(win.tw, win.th); 41 @@ -793,8 +797,8 @@ xhints(void) 42 sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize; 43 sizeh->height = win.h; 44 sizeh->width = win.w; 45 - sizeh->height_inc = win.ch; 46 - sizeh->width_inc = win.cw; 47 + sizeh->height_inc = 1; 48 + sizeh->width_inc = 1; 49 sizeh->base_height = 2 * borderpx; 50 sizeh->base_width = 2 * borderpx; 51 sizeh->min_height = win.ch + 2 * borderpx; 52 @@ -1022,8 +1026,8 @@ xinit(int cols, int rows) 53 xloadcols(); 54 55 /* adjust fixed window geometry */ 56 - win.w = 2 * borderpx + cols * win.cw; 57 - win.h = 2 * borderpx + rows * win.ch; 58 + win.w = 2 * win.hborderpx + cols * win.cw; 59 + win.h = 2 * win.vborderpx + rows * win.ch; 60 if (xw.gm & XNegative) 61 xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2; 62 if (xw.gm & YNegative) 63 @@ -1123,7 +1127,7 @@ xinit(int cols, int rows) 64 int 65 xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y) 66 { 67 - float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp; 68 + float winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch, xp, yp; 69 ushort mode, prevmode = USHRT_MAX; 70 Font *font = &dc.font; 71 int frcflags = FRC_NORMAL; 72 @@ -1259,7 +1263,7 @@ void 73 xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y) 74 { 75 int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1); 76 - int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, 77 + int winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch, 78 width = charlen * win.cw; 79 Color *fg, *bg, *temp, revfg, revbg, truefg, truebg; 80 XRenderColor colfg, colbg; 81 @@ -1349,17 +1353,17 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i 82 83 /* Intelligent cleaning up of the borders. */ 84 if (x == 0) { 85 - xclear(0, (y == 0)? 0 : winy, borderpx, 86 + xclear(0, (y == 0)? 0 : winy, win.vborderpx, 87 winy + win.ch + 88 - ((winy + win.ch >= borderpx + win.th)? win.h : 0)); 89 + ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0)); 90 } 91 - if (winx + width >= borderpx + win.tw) { 92 + if (winx + width >= win.hborderpx + win.tw) { 93 xclear(winx + width, (y == 0)? 0 : winy, win.w, 94 - ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch))); 95 + ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch))); 96 } 97 if (y == 0) 98 - xclear(winx, 0, winx + width, borderpx); 99 - if (winy + win.ch >= borderpx + win.th) 100 + xclear(winx, 0, winx + width, win.hborderpx); 101 + if (winy + win.ch >= win.vborderpx + win.th) 102 xclear(winx, winy + win.ch, winx + width, win.h); 103 104 /* Clean up the region we want to draw to. */ 105 @@ -1452,35 +1456,35 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) 106 case 3: /* Blinking Underline */ 107 case 4: /* Steady Underline */ 108 XftDrawRect(xw.draw, &drawcol, 109 - borderpx + cx * win.cw, 110 - borderpx + (cy + 1) * win.ch - \ 111 + win.hborderpx + cx * win.cw, 112 + win.vborderpx + (cy + 1) * win.ch - \ 113 cursorthickness, 114 win.cw, cursorthickness); 115 break; 116 case 5: /* Blinking bar */ 117 case 6: /* Steady bar */ 118 XftDrawRect(xw.draw, &drawcol, 119 - borderpx + cx * win.cw, 120 - borderpx + cy * win.ch, 121 + win.hborderpx + cx * win.cw, 122 + win.vborderpx + cy * win.ch, 123 cursorthickness, win.ch); 124 break; 125 } 126 } else { 127 XftDrawRect(xw.draw, &drawcol, 128 - borderpx + cx * win.cw, 129 - borderpx + cy * win.ch, 130 + win.hborderpx + cx * win.cw, 131 + win.vborderpx + cy * win.ch, 132 win.cw - 1, 1); 133 XftDrawRect(xw.draw, &drawcol, 134 - borderpx + cx * win.cw, 135 - borderpx + cy * win.ch, 136 + win.hborderpx + cx * win.cw, 137 + win.vborderpx + cy * win.ch, 138 1, win.ch - 1); 139 XftDrawRect(xw.draw, &drawcol, 140 - borderpx + (cx + 1) * win.cw - 1, 141 - borderpx + cy * win.ch, 142 + win.hborderpx + (cx + 1) * win.cw - 1, 143 + win.vborderpx + cy * win.ch, 144 1, win.ch - 1); 145 XftDrawRect(xw.draw, &drawcol, 146 - borderpx + cx * win.cw, 147 - borderpx + (cy + 1) * win.ch - 1, 148 + win.hborderpx + cx * win.cw, 149 + win.vborderpx + (cy + 1) * win.ch - 1, 150 win.cw, 1); 151 } 152 }