On Tue, Sep 6, 2011 at 11:29, Bastien Dejean <esch...@gmail.com> wrote:

> Bogdan Ionuț a écrit :
> > On Mon, Sep 5, 2011 at 17:10, Bastien Dejean <esch...@gmail.com> wrote:
> > >  don't know if it's a known bug, but I stumble upon this crazy window
> > > behavior happening in floating layout.
> > >
> > > In the following video, I try to move and resize the window, then I hit
> > > MODKEY+space which is bound, in my config.h, to togglefloating, at this
> > >
> > I can bet that it's uselessgap patch related.
>
> Indeed.
> Is there a rock solid version of that patch floating around?
>
> --
> Bastien
>
>
Try the patch attached.
--- a/config.def.h	2011-07-10 23:24:25.000000000 +0300
+++ b/config.def.h	2011-09-06 11:52:50.092771712 +0300
@@ -9,6 +9,7 @@ static const char selbordercolor[]  = "#
 static const char selbgcolor[]      = "#0066ff";
 static const char selfgcolor[]      = "#ffffff";
 static const unsigned int borderpx  = 1;        /* border pixel of windows */
+static const unsigned int gappx     = 6;        /* gap pixel between windows */
 static const unsigned int snap      = 32;       /* snap pixel */
 static const Bool showbar           = True;     /* False means no bar */
 static const Bool topbar            = True;     /* False means bottom bar */
@@ -27,10 +28,10 @@ static const float mfact      = 0.55; /*
 static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
 
 static const Layout layouts[] = {
-	/* symbol     arrange function */
-	{ "[]=",      tile },    /* first entry is default */
-	{ "><>",      NULL },    /* no layout function means floating behavior */
-	{ "[M]",      monocle },
+	/* symbol     gaps       arrange function */
+	{ "[]=",      True,      tile },    /* first entry is default */
+	{ "><>",      False,     NULL },    /* no layout function means floating behavior */
+	{ "[M]",      False,     monocle },
 };
 
 /* key definitions */
--- a/dwm.c	2011-07-10 23:24:25.000000000 +0300
+++ b/dwm.c	2011-09-06 11:52:12.212769335 +0300
@@ -119,6 +119,7 @@ typedef struct {
 
 typedef struct {
 	const char *symbol;
+	Bool addgaps;
 	void (*arrange)(Monitor *);
 } Layout;
 
@@ -470,7 +471,7 @@ checkotherwm(void) {
 void
 cleanup(void) {
 	Arg a = {.ui = ~0};
-	Layout foo = { "", NULL };
+	Layout foo = { "", False, NULL };
 	Monitor *m;
 
 	view(&a);
@@ -1317,11 +1318,12 @@ resize(Client *c, int x, int y, int w, i
 void
 resizeclient(Client *c, int x, int y, int w, int h) {
 	XWindowChanges wc;
+	unsigned int gap = c->isfloating ? 0 : c->mon->lt[c->mon->sellt]->addgaps ? gappx : 0;
 
-	c->oldx = c->x; c->x = wc.x = x;
-	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;
+	c->oldx = c->x; c->x = wc.x = x + gap;
+	c->oldy = c->y; c->y = wc.y = y + gap;
+	c->oldw = c->w; c->w = wc.width = w - (gap ? (x + w + (c->bw * 2) == c->mon->mx + c->mon->mw ? 2 : 1) * gap : 0);
+	c->oldh = c->h; c->h = wc.height = h - (gap ? (y + h + (c->bw * 2) == c->mon->my + c->mon->mh ? 2 : 1) * gap : 0);
 	wc.border_width = c->bw;
 	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
 	configure(c);

Reply via email to