st-anysize-20201003-407a3d0.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       st-anysize-20201003-407a3d0.diff (4978B)
       ---
            1 From 407a3d065645ee814e04a6c62a2d2dea04a1c18c Mon Sep 17 00:00:00 2001
            2 From: Finn Rayment <finn@rayment.fr>
            3 Date: Sat, 3 Oct 2020 14:47:04 +0200
            4 Subject: [PATCH] Applied anysize patch fix
            5 
            6 ---
            7  x.c | 52 ++++++++++++++++++++++++++++------------------------
            8  1 file changed, 28 insertions(+), 24 deletions(-)
            9 
           10 diff --git a/x.c b/x.c
           11 index 210f184..a11a992 100644
           12 --- a/x.c
           13 +++ b/x.c
           14 @@ -81,6 +81,7 @@ typedef XftGlyphFontSpec GlyphFontSpec;
           15  typedef struct {
           16          int tw, th; /* tty width and height */
           17          int w, h; /* window width and height */
           18 +        int hborderpx, vborderpx;
           19          int ch; /* char height */
           20          int cw; /* char width  */
           21          int mode; /* window state/mode flags */
           22 @@ -331,7 +332,7 @@ ttysend(const Arg *arg)
           23  int
           24  evcol(XEvent *e)
           25  {
           26 -        int x = e->xbutton.x - borderpx;
           27 +        int x = e->xbutton.x - win.hborderpx;
           28          LIMIT(x, 0, win.tw - 1);
           29          return x / win.cw;
           30  }
           31 @@ -339,7 +340,7 @@ evcol(XEvent *e)
           32  int
           33  evrow(XEvent *e)
           34  {
           35 -        int y = e->xbutton.y - borderpx;
           36 +        int y = e->xbutton.y - win.vborderpx;
           37          LIMIT(y, 0, win.th - 1);
           38          return y / win.ch;
           39  }
           40 @@ -721,6 +722,9 @@ cresize(int width, int height)
           41          col = MAX(1, col);
           42          row = MAX(1, row);
           43  
           44 +        win.hborderpx = (win.w - col * win.cw) / 2;
           45 +        win.vborderpx = (win.h - row * win.ch) / 2;
           46 +
           47          tresize(col, row);
           48          xresize(col, row);
           49          ttyresize(win.tw, win.th);
           50 @@ -1121,8 +1125,8 @@ xinit(int cols, int rows)
           51          xloadcols();
           52  
           53          /* adjust fixed window geometry */
           54 -        win.w = 2 * borderpx + cols * win.cw;
           55 -        win.h = 2 * borderpx + rows * win.ch;
           56 +        win.w = 2 * win.hborderpx + cols * win.cw;
           57 +        win.h = 2 * win.vborderpx + rows * win.ch;
           58          if (xw.gm & XNegative)
           59                  xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
           60          if (xw.gm & YNegative)
           61 @@ -1210,7 +1214,7 @@ xinit(int cols, int rows)
           62  int
           63  xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y)
           64  {
           65 -        float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp;
           66 +        float winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch, xp, yp;
           67          ushort mode, prevmode = USHRT_MAX;
           68          Font *font = &dc.font;
           69          int frcflags = FRC_NORMAL;
           70 @@ -1343,7 +1347,7 @@ void
           71  xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
           72  {
           73          int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
           74 -        int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
           75 +        int winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch,
           76              width = charlen * win.cw;
           77          Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
           78          XRenderColor colfg, colbg;
           79 @@ -1433,17 +1437,17 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
           80  
           81          /* Intelligent cleaning up of the borders. */
           82          if (x == 0) {
           83 -                xclear(0, (y == 0)? 0 : winy, borderpx,
           84 +                xclear(0, (y == 0)? 0 : winy, win.vborderpx,
           85                          winy + win.ch +
           86 -                        ((winy + win.ch >= borderpx + win.th)? win.h : 0));
           87 +                        ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
           88          }
           89 -        if (winx + width >= borderpx + win.tw) {
           90 +        if (winx + width >= win.hborderpx + win.tw) {
           91                  xclear(winx + width, (y == 0)? 0 : winy, win.w,
           92 -                        ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch)));
           93 +                        ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
           94          }
           95          if (y == 0)
           96 -                xclear(winx, 0, winx + width, borderpx);
           97 -        if (winy + win.ch >= borderpx + win.th)
           98 +                xclear(winx, 0, winx + width, win.hborderpx);
           99 +        if (winy + win.ch >= win.vborderpx + win.th)
          100                  xclear(winx, winy + win.ch, winx + width, win.h);
          101  
          102          /* Clean up the region we want to draw to. */
          103 @@ -1537,35 +1541,35 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
          104                  case 3: /* Blinking Underline */
          105                  case 4: /* Steady Underline */
          106                          XftDrawRect(xw.draw, &drawcol,
          107 -                                        borderpx + cx * win.cw,
          108 -                                        borderpx + (cy + 1) * win.ch - \
          109 +                                        win.hborderpx + cx * win.cw,
          110 +                                        win.vborderpx + (cy + 1) * win.ch - \
          111                                                  cursorthickness,
          112                                          win.cw, cursorthickness);
          113                          break;
          114                  case 5: /* Blinking bar */
          115                  case 6: /* Steady bar */
          116                          XftDrawRect(xw.draw, &drawcol,
          117 -                                        borderpx + cx * win.cw,
          118 -                                        borderpx + cy * win.ch,
          119 +                                        win.hborderpx + cx * win.cw,
          120 +                                        win.vborderpx + cy * win.ch,
          121                                          cursorthickness, win.ch);
          122                          break;
          123                  }
          124          } else {
          125                  XftDrawRect(xw.draw, &drawcol,
          126 -                                borderpx + cx * win.cw,
          127 -                                borderpx + cy * win.ch,
          128 +                                win.hborderpx + cx * win.cw,
          129 +                                win.vborderpx + cy * win.ch,
          130                                  win.cw - 1, 1);
          131                  XftDrawRect(xw.draw, &drawcol,
          132 -                                borderpx + cx * win.cw,
          133 -                                borderpx + cy * win.ch,
          134 +                                win.hborderpx + cx * win.cw,
          135 +                                win.vborderpx + cy * win.ch,
          136                                  1, win.ch - 1);
          137                  XftDrawRect(xw.draw, &drawcol,
          138 -                                borderpx + (cx + 1) * win.cw - 1,
          139 -                                borderpx + cy * win.ch,
          140 +                                win.hborderpx + (cx + 1) * win.cw - 1,
          141 +                                win.vborderpx + cy * win.ch,
          142                                  1, win.ch - 1);
          143                  XftDrawRect(xw.draw, &drawcol,
          144 -                                borderpx + cx * win.cw,
          145 -                                borderpx + (cy + 1) * win.ch - 1,
          146 +                                win.hborderpx + cx * win.cw,
          147 +                                win.vborderpx + (cy + 1) * win.ch - 1,
          148                                  win.cw, 1);
          149          }
          150  }
          151 -- 
          152 2.28.0
          153