On Sun, Aug 01, 2021 at 10:39:27PM -0300, Natanael Rabello wrote:
> The following is a new diff revision for the dwm patch floatrules.
> It contains bug fixes and adds support for allowing float x,y,w,h to
> be unspecified (-1); that is for floating windows that already set the
> geometry hints to not be overridden.
> BTW, the last published diff revision was corrupt. So this one should
> fix that too.
> The number of actually modified lines from the previous diff revision
> to this one is about only 5.
> 
> dwm-floatrules-20210801-138b405.diff
> ===========================================================================
> diff --git a/config.def.h b/config.def.h
> index a2ac963..e8c0978 100644
> --- a/config.def.h
> +++ b/config.def.h
> _AT_@ -26,9 +26,9 @@ static const Rule rules[] = {
>   * WM_CLASS(STRING) = instance, class
>   * WM_NAME(STRING) = title
>   */
> - /* class      instance    title       tags mask     isfloating   monitor */
> - { "Gimp",     NULL,       NULL,       0,            1,           -1 },
> - { "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
> + /* class      instance    title       tags mask     isfloating
> monitor    float x,y,w,h         floatborderpx*/
> + { "Gimp",     NULL,       NULL,       0,            1,           -1,
>        50,50,500,500,        5 },
> + { "Firefox",  NULL,       NULL,       1 << 8,       0,           -1,
>        50,50,500,500,        5 },
>  };
> 
>  /* layout(s) */
> diff --git a/dwm.c b/dwm.c
> index 5e4d494..a03ca15 100644
> --- a/dwm.c
> +++ b/dwm.c
> _AT_@ -93,6 +93,8 @@ struct Client {
>   int bw, oldbw;
>   unsigned int tags;
>   int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
> + int floatborderpx;
> + int hasfloatbw;
>   Client *next;
>   Client *snext;
>   Monitor *mon;
> _AT_@ -139,6 +141,8 @@ typedef struct {
>   unsigned int tags;
>   int isfloating;
>   int monitor;
> + int floatx, floaty, floatw, floath;
> + int floatborderpx;
>  } Rule;
> 
>  /* function declarations */
> _AT_@ -300,6 +304,16 @@ applyrules(Client *c)
>   {
>   c->isfloating = r->isfloating;
>   c->tags |= r->tags;
> + if (r->floatborderpx >= 0) {
> + c->floatborderpx = r->floatborderpx;
> + c->hasfloatbw = 1;
> + }
> + if (r->isfloating) {
> + if (r->floatx >= 0) c->x = c->mon->mx + r->floatx;
> + if (r->floaty >= 0) c->y = c->mon->my + r->floaty;
> + if (r->floatw >= 0) c->w = r->floatw;
> + if (r->floath >= 0) c->h = r->floath;
> + }
>   for (m = mons; m && m->num != r->monitor; m = m->next);
>   if (m)
>   c->mon = m;
> _AT_@ -1282,7 +1296,10 @@ resizeclient(Client *c, int x, int y, int w, int h)
>   c->oldy = c->y; c->y = wc.y = y;
>   c->oldw = c->w; c->w = wc.width = w;
>   c->oldh = c->h; c->h = wc.height = h;
> - wc.border_width = c->bw;
> + if (c->isfloating && c->hasfloatbw && !c->isfullscreen)
> + wc.border_width = c->floatborderpx;
> + else
> + wc.border_width = c->bw;
>   XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
>   configure(c);
>   XSync(dpy, False);
> --
> 2.32.0
> ===========================================================================
> 
> 
> Natanael J Rabello
> diff --git a/config.def.h b/config.def.h
> index a2ac963..e8c0978 100644
> --- a/config.def.h
> +++ b/config.def.h
> _AT_@ -26,9 +26,9 @@ static const Rule rules[] = {
>  	 *	WM_CLASS(STRING) = instance, class
>  	 *	WM_NAME(STRING) = title
>  	 */
> -	/* class      instance    title       tags mask     isfloating   monitor */
> -	{ "Gimp",     NULL,       NULL,       0,            1,           -1 },
> -	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
> +	/* class      instance    title       tags mask     isfloating   monitor    float x,y,w,h         floatborderpx*/
> +	{ "Gimp",     NULL,       NULL,       0,            1,           -1,        50,50,500,500,        5 },
> +	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           -1,        50,50,500,500,        5 },
>  };
>  
>  /* layout(s) */
> diff --git a/dwm.c b/dwm.c
> index 5e4d494..a03ca15 100644
> --- a/dwm.c
> +++ b/dwm.c
> _AT_@ -93,6 +93,8 @@ struct Client {
>  	int bw, oldbw;
>  	unsigned int tags;
>  	int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
> +	int floatborderpx;
> +	int hasfloatbw;
>  	Client *next;
>  	Client *snext;
>  	Monitor *mon;
> _AT_@ -139,6 +141,8 @@ typedef struct {
>  	unsigned int tags;
>  	int isfloating;
>  	int monitor;
> +	int floatx, floaty, floatw, floath;
> +	int floatborderpx;
>  } Rule;
>  
>  /* function declarations */
> _AT_@ -300,6 +304,16 @@ applyrules(Client *c)
>  		{
>  			c->isfloating = r->isfloating;
>  			c->tags |= r->tags;
> +			if (r->floatborderpx >= 0) {
> +				c->floatborderpx = r->floatborderpx;
> +				c->hasfloatbw = 1;
> +			}
> +			if (r->isfloating) {
> +				if (r->floatx >= 0) c->x = c->mon->mx + r->floatx;
> +				if (r->floaty >= 0) c->y = c->mon->my + r->floaty;
> +				if (r->floatw >= 0) c->w = r->floatw;
> +				if (r->floath >= 0) c->h = r->floath;
> +			}
>  			for (m = mons; m && m->num != r->monitor; m = m->next);
>  			if (m)
>  				c->mon = m;
> _AT_@ -1282,7 +1296,10 @@ resizeclient(Client *c, int x, int y, int w, int h)
>  	c->oldy = c->y; c->y = wc.y = y;
>  	c->oldw = c->w; c->w = wc.width = w;
>  	c->oldh = c->h; c->h = wc.height = h;
> -	wc.border_width = c->bw;
> +	if (c->isfloating && c->hasfloatbw && !c->isfullscreen)
> +		wc.border_width = c->floatborderpx;
> +	else
> +		wc.border_width = c->bw;
>  	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
>  	configure(c);
>  	XSync(dpy, False);
> -- 
> 2.32.0
> 
This is not the correct mailinglist to send the patch to.
Anyone can push to the wiki, see also:
https://suckless.org/community/
-- 
Kind regards,
Hiltjo
Received on Mon Aug 02 2021 - 10:58:32 CEST