dotfiles

personal dotfiles
git clone anongit@rnpnr.xyz:dotfiles.git
Log | Files | Refs | Feed | Submodules

0004-split-borderpx-into-x-and-y-components.patch (6474B)


      1 From 486578ac5eaa7650e7c2157c3d9f10195a083b32 Mon Sep 17 00:00:00 2001
      2 From: Randy Palamar <palamar@ualberta.ca>
      3 Date: Tue, 24 Oct 2023 05:57:20 -0600
      4 Subject: [PATCH] split borderpx into x and y components
      5 
      6 ---
      7  config.def.h |  2 +-
      8  x.c          | 82 ++++++++++++++++++++++++++++++++--------------------
      9  2 files changed, 51 insertions(+), 33 deletions(-)
     10 
     11 diff --git a/config.def.h b/config.def.h
     12 index 897e12a..90d9712 100644
     13 --- a/config.def.h
     14 +++ b/config.def.h
     15 @@ -6,7 +6,7 @@
     16   * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
     17   */
     18  static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
     19 -static int borderpx = 2;
     20 +static struct { int x, y; } pad = { 12, 12 };
     21  
     22  /*
     23   * What program is execed by st depends of these precedence rules:
     24 diff --git a/x.c b/x.c
     25 index 0f0d28c..d7dd85e 100644
     26 --- a/x.c
     27 +++ b/x.c
     28 @@ -62,6 +62,8 @@ static void zoomabs(const Arg *);
     29  static void zoomreset(const Arg *);
     30  static void ttysend(const Arg *);
     31  static void recolor(const Arg *);
     32 +static void xpadinc(const Arg *);
     33 +static void ypadinc(const Arg *);
     34  
     35  /* config.h for applying patches and the configuration. */
     36  #include "config.h"
     37 @@ -334,7 +336,7 @@ ttysend(const Arg *arg)
     38  int
     39  evcol(XEvent *e)
     40  {
     41 -	int x = e->xbutton.x - borderpx;
     42 +	int x = e->xbutton.x - pad.x;
     43  	LIMIT(x, 0, win.tw - 1);
     44  	return x / win.cw;
     45  }
     46 @@ -342,7 +344,7 @@ evcol(XEvent *e)
     47  int
     48  evrow(XEvent *e)
     49  {
     50 -	int y = e->xbutton.y - borderpx;
     51 +	int y = e->xbutton.y - pad.y;
     52  	LIMIT(y, 0, win.th - 1);
     53  	return y / win.ch;
     54  }
     55 @@ -737,8 +739,8 @@ cresize(int width, int height)
     56  	if (height != 0)
     57  		win.h = height;
     58  
     59 -	col = (win.w - 2 * borderpx) / win.cw;
     60 -	row = (win.h - 2 * borderpx) / win.ch;
     61 +	col = (win.w - 2 * pad.x) / win.cw;
     62 +	row = (win.h - 2 * pad.y) / win.ch;
     63  	col = MAX(1, col);
     64  	row = MAX(1, row);
     65  
     66 @@ -874,10 +876,10 @@ xhints(void)
     67  	sizeh->width = win.w;
     68  	sizeh->height_inc = win.ch;
     69  	sizeh->width_inc = win.cw;
     70 -	sizeh->base_height = 2 * borderpx;
     71 -	sizeh->base_width = 2 * borderpx;
     72 -	sizeh->min_height = win.ch + 2 * borderpx;
     73 -	sizeh->min_width = win.cw + 2 * borderpx;
     74 +	sizeh->base_height = 2 * pad.y;
     75 +	sizeh->base_width = 2 * pad.x;
     76 +	sizeh->min_height = win.ch + 2 * pad.y;
     77 +	sizeh->min_width = win.cw + 2 * pad.x;
     78  	if (xw.isfixed) {
     79  		sizeh->flags |= PMaxSize;
     80  		sizeh->min_width = sizeh->max_width = win.w;
     81 @@ -1155,8 +1157,8 @@ xinit(int cols, int rows)
     82  	xloadcols();
     83  
     84  	/* adjust fixed window geometry */
     85 -	win.w = 2 * borderpx + cols * win.cw;
     86 -	win.h = 2 * borderpx + rows * win.ch;
     87 +	win.w = 2 * pad.x + cols * win.cw;
     88 +	win.h = 2 * pad.y + rows * win.ch;
     89  	if (xw.gm & XNegative)
     90  		xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
     91  	if (xw.gm & YNegative)
     92 @@ -1245,7 +1247,7 @@ xinit(int cols, int rows)
     93  int
     94  xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y)
     95  {
     96 -	float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp;
     97 +	float winx = pad.x + x * win.cw, winy = pad.y + y * win.ch, xp, yp;
     98  	ushort mode, prevmode = USHRT_MAX;
     99  	Font *font = &dc.font;
    100  	int frcflags = FRC_NORMAL;
    101 @@ -1378,7 +1380,7 @@ void
    102  xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
    103  {
    104  	int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
    105 -	int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
    106 +	int winx = pad.x + x * win.cw, winy = pad.y + y * win.ch,
    107  	    width = charlen * win.cw;
    108  	Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
    109  	XRenderColor colfg, colbg;
    110 @@ -1468,17 +1470,17 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
    111  
    112  	/* Intelligent cleaning up of the borders. */
    113  	if (x == 0) {
    114 -		xclear(0, (y == 0)? 0 : winy, borderpx,
    115 +		xclear(0, (y == 0)? 0 : winy, pad.y,
    116  			winy + win.ch +
    117 -			((winy + win.ch >= borderpx + win.th)? win.h : 0));
    118 +			((winy + win.ch >= pad.y + win.th)? win.h : 0));
    119  	}
    120 -	if (winx + width >= borderpx + win.tw) {
    121 +	if (winx + width >= pad.x + win.tw) {
    122  		xclear(winx + width, (y == 0)? 0 : winy, win.w,
    123 -			((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch)));
    124 +			((winy + win.ch >= pad.y + win.th)? win.h : (winy + win.ch)));
    125  	}
    126  	if (y == 0)
    127 -		xclear(winx, 0, winx + width, borderpx);
    128 -	if (winy + win.ch >= borderpx + win.th)
    129 +		xclear(winx, 0, winx + width, pad.x);
    130 +	if (winy + win.ch >= pad.y + win.th)
    131  		xclear(winx, winy + win.ch, winx + width, win.h);
    132  
    133  	/* Clean up the region we want to draw to. */
    134 @@ -1572,35 +1574,35 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
    135  		case 3: /* Blinking Underline */
    136  		case 4: /* Steady Underline */
    137  			XftDrawRect(xw.draw, &drawcol,
    138 -					borderpx + cx * win.cw,
    139 -					borderpx + (cy + 1) * win.ch - \
    140 +					pad.x + cx * win.cw,
    141 +					pad.y + (cy + 1) * win.ch - \
    142  						cursorthickness,
    143  					win.cw, cursorthickness);
    144  			break;
    145  		case 5: /* Blinking bar */
    146  		case 6: /* Steady bar */
    147  			XftDrawRect(xw.draw, &drawcol,
    148 -					borderpx + cx * win.cw,
    149 -					borderpx + cy * win.ch,
    150 +					pad.x + cx * win.cw,
    151 +					pad.y + cy * win.ch,
    152  					cursorthickness, win.ch);
    153  			break;
    154  		}
    155  	} else {
    156  		XftDrawRect(xw.draw, &drawcol,
    157 -				borderpx + cx * win.cw,
    158 -				borderpx + cy * win.ch,
    159 +				pad.x + cx * win.cw,
    160 +				pad.y + cy * win.ch,
    161  				win.cw - 1, 1);
    162  		XftDrawRect(xw.draw, &drawcol,
    163 -				borderpx + cx * win.cw,
    164 -				borderpx + cy * win.ch,
    165 +				pad.x + cx * win.cw,
    166 +				pad.y + cy * win.ch,
    167  				1, win.ch - 1);
    168  		XftDrawRect(xw.draw, &drawcol,
    169 -				borderpx + (cx + 1) * win.cw - 1,
    170 -				borderpx + cy * win.ch,
    171 +				pad.x + (cx + 1) * win.cw - 1,
    172 +				pad.y + cy * win.ch,
    173  				1, win.ch - 1);
    174  		XftDrawRect(xw.draw, &drawcol,
    175 -				borderpx + cx * win.cw,
    176 -				borderpx + (cy + 1) * win.ch - 1,
    177 +				pad.x + cx * win.cw,
    178 +				pad.y + (cy + 1) * win.ch - 1,
    179  				win.cw, 1);
    180  	}
    181  }
    182 @@ -1701,8 +1703,8 @@ xximspot(int x, int y)
    183  	if (xw.ime.xic == NULL)
    184  		return;
    185  
    186 -	xw.ime.spot.x = borderpx + x * win.cw;
    187 -	xw.ime.spot.y = borderpx + (y + 1) * win.ch;
    188 +	xw.ime.spot.x = pad.x + x * win.cw;
    189 +	xw.ime.spot.y = pad.y + (y + 1) * win.ch;
    190  
    191  	XSetICValues(xw.ime.xic, XNPreeditAttributes, xw.ime.spotlist, NULL);
    192  }
    193 @@ -1920,6 +1922,22 @@ resize(XEvent *e)
    194  	cresize(e->xconfigure.width, e->xconfigure.height);
    195  }
    196  
    197 +void
    198 +xpadinc(const Arg *A)
    199 +{
    200 +	pad.x += A->i;
    201 +	cresize(0, 0);
    202 +	redraw();
    203 +}
    204 +
    205 +void
    206 +ypadinc(const Arg *A)
    207 +{
    208 +	pad.y += A->i;
    209 +	cresize(0, 0);
    210 +	redraw();
    211 +}
    212 +
    213  void
    214  recolor(const Arg *A)
    215  {
    216 -- 
    217 2.44.0
    218