sites

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

dwm-floatrules-20210801-138b405.diff (2313B)


      1 diff --git a/config.def.h b/config.def.h
      2 index a2ac963..e8c0978 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -26,9 +26,9 @@ static const Rule rules[] = {
      6  	 *	WM_CLASS(STRING) = instance, class
      7  	 *	WM_NAME(STRING) = title
      8  	 */
      9 -	/* class      instance    title       tags mask     isfloating   monitor */
     10 -	{ "Gimp",     NULL,       NULL,       0,            1,           -1 },
     11 -	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
     12 +	/* class      instance    title       tags mask     isfloating   monitor    float x,y,w,h         floatborderpx*/
     13 +	{ "Gimp",     NULL,       NULL,       0,            1,           -1,        50,50,500,500,        5 },
     14 +	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           -1,        50,50,500,500,        5 },
     15  };
     16  
     17  /* layout(s) */
     18 diff --git a/dwm.c b/dwm.c
     19 index 5e4d494..a03ca15 100644
     20 --- a/dwm.c
     21 +++ b/dwm.c
     22 @@ -93,6 +93,8 @@ struct Client {
     23  	int bw, oldbw;
     24  	unsigned int tags;
     25  	int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
     26 +	int floatborderpx;
     27 +	int hasfloatbw;
     28  	Client *next;
     29  	Client *snext;
     30  	Monitor *mon;
     31 @@ -139,6 +141,8 @@ typedef struct {
     32  	unsigned int tags;
     33  	int isfloating;
     34  	int monitor;
     35 +	int floatx, floaty, floatw, floath;
     36 +	int floatborderpx;
     37  } Rule;
     38  
     39  /* function declarations */
     40 @@ -300,6 +304,16 @@ applyrules(Client *c)
     41  		{
     42  			c->isfloating = r->isfloating;
     43  			c->tags |= r->tags;
     44 +			if (r->floatborderpx >= 0) {
     45 +				c->floatborderpx = r->floatborderpx;
     46 +				c->hasfloatbw = 1;
     47 +			}
     48 +			if (r->isfloating) {
     49 +				if (r->floatx >= 0) c->x = c->mon->mx + r->floatx;
     50 +				if (r->floaty >= 0) c->y = c->mon->my + r->floaty;
     51 +				if (r->floatw >= 0) c->w = r->floatw;
     52 +				if (r->floath >= 0) c->h = r->floath;
     53 +			}
     54  			for (m = mons; m && m->num != r->monitor; m = m->next);
     55  			if (m)
     56  				c->mon = m;
     57 @@ -1282,7 +1296,10 @@ resizeclient(Client *c, int x, int y, int w, int h)
     58  	c->oldy = c->y; c->y = wc.y = y;
     59  	c->oldw = c->w; c->w = wc.width = w;
     60  	c->oldh = c->h; c->h = wc.height = h;
     61 -	wc.border_width = c->bw;
     62 +	if (c->isfloating && c->hasfloatbw && !c->isfullscreen)
     63 +		wc.border_width = c->floatborderpx;
     64 +	else
     65 +		wc.border_width = c->bw;
     66  	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
     67  	configure(c);
     68  	XSync(dpy, False);
     69 -- 
     70 2.32.0
     71