sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-borderrule-20231226-e7f651b.diff (2066B)


      1 From e7f651b1321747fb92521522f0aa07a01160d4af Mon Sep 17 00:00:00 2001
      2 From: Jasper Shovelton <Beanie.github@proton.me>
      3 Date: Tue, 26 Dec 2023 12:57:35 +0000
      4 Subject: [PATCH] Add a `borderpx` value to `rules` in `config.def.h`.
      5 
      6 ---
      7  config.def.h | 6 +++---
      8  dwm.c        | 5 ++++-
      9  2 files changed, 7 insertions(+), 4 deletions(-)
     10 
     11 diff --git a/config.def.h b/config.def.h
     12 index 9efa774..bdddfa5 100644
     13 --- a/config.def.h
     14 +++ b/config.def.h
     15 @@ -26,9 +26,9 @@ static const Rule rules[] = {
     16  	 *	WM_CLASS(STRING) = instance, class
     17  	 *	WM_NAME(STRING) = title
     18  	 */
     19 -	/* class      instance    title       tags mask     isfloating   monitor */
     20 -	{ "Gimp",     NULL,       NULL,       0,            1,           -1 },
     21 -	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
     22 +	/* class      instance    title       tags mask     isfloating   monitor   border width */
     23 +	{ "Gimp",     NULL,       NULL,       0,            1,           -1,       -1 },
     24 +	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           -1,       0 },
     25  };
     26  
     27  /* layout(s) */
     28 diff --git a/dwm.c b/dwm.c
     29 index f1d86b2..48403c2 100644
     30 --- a/dwm.c
     31 +++ b/dwm.c
     32 @@ -139,6 +139,7 @@ typedef struct {
     33  	unsigned int tags;
     34  	int isfloating;
     35  	int monitor;
     36 +	int bw;
     37  } Rule;
     38  
     39  /* function declarations */
     40 @@ -287,6 +288,7 @@ applyrules(Client *c)
     41  	/* rule matching */
     42  	c->isfloating = 0;
     43  	c->tags = 0;
     44 +	c->bw = borderpx;
     45  	XGetClassHint(dpy, c->win, &ch);
     46  	class    = ch.res_class ? ch.res_class : broken;
     47  	instance = ch.res_name  ? ch.res_name  : broken;
     48 @@ -299,6 +301,8 @@ applyrules(Client *c)
     49  		{
     50  			c->isfloating = r->isfloating;
     51  			c->tags |= r->tags;
     52 +			if (r->bw != -1)
     53 +				c->bw = r->bw;
     54  			for (m = mons; m && m->num != r->monitor; m = m->next);
     55  			if (m)
     56  				c->mon = m;
     57 @@ -1059,7 +1063,6 @@ manage(Window w, XWindowAttributes *wa)
     58  		c->y = c->mon->wy + c->mon->wh - HEIGHT(c);
     59  	c->x = MAX(c->x, c->mon->wx);
     60  	c->y = MAX(c->y, c->mon->wy);
     61 -	c->bw = borderpx;
     62  
     63  	wc.border_width = c->bw;
     64  	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
     65 -- 
     66 2.43.0
     67