Here is the dwmii layout.
And the replacement of the lines 1443-1455 in the tile function to
respect resizehints :
x = c->x + c->w + 2 * c->bw;
w = ww - x;
y = wy;
for( c = nexttiled(c->next) ; c ; c = nexttiled(c->next) )
{
h = (wh - y + wy) / n;
resize(c,x,y,NOBORDER(w),NOBORDER(h),resizehints);
y += c->h + 2 * c->bw; n--;
}
Kind regards,
Quintin Guillaume.
Anselm R Garbe wrote:
Hi there,
I'm glad to announce dwm-5.2 and dmenu-3.9. You can download the new
releases from:
http://code.suckless.org/dl/dwm/dwm-5.2.tar.gz
http://code.suckless.org/dl/tools/dmenu-3.9.tar.gz
Both releases contain various bug fixes and code polishings.
Many thanks go to all geeks who have been involved in the development
during the last weeks.
Kind regards,
--Anselm
/*
* I used WMII and found it too "heavy". So I switched to dwm but I
* quickly missed the possibilities of having several columns,
* several windows in each column and moving the windows from a
* column into another or change the windows' order within a column.
* As there were no patch (or layout) providing that, I wrote one.
* I also added a layout that does the same thing but arrange the
* windows by rows.
*
* The col dwmii layout :
*
* +--+--+--+
* | | | |
* +--+ | |
* | +--+ |
* +--+ | |
* | | | |
* +--+--+--+
*
* The row dwmii layout :
*
* +--+---+--+
* | | | |
* +--+-+-+--+
* | | |
* +----+----+
* | |
* +---------+
*
* You can move a window to the next/previous columnn, after the next
* window or before the previous window within a column by simple
* combination of keys (the same as in WMII).
*
* To get the dwmii layouts working you have to :
* - have DWM version 5.2
* - add these lines in the config.h file :
* - just before the layouts array :
*
* #include "dwmii.c"
*
* - in the layouts array :
*
* { "COL", dwmiilayoutcol },
* { "ROW", dwmiilayoutrow },
*
* - in the keys array :
*
* { MODKEY, XK_c, setlayout, {.v = &layouts[1]} },
* { MODKEY, XK_r, setlayout, {.v = &layouts[2]} },
* { MODKEY|ShiftMask, XK_Up, dwmiikeypressed, {.i = XK_Up} },
* { MODKEY|ShiftMask, XK_Left, dwmiikeypressed, {.i = XK_Left} },
* { MODKEY|ShiftMask, XK_Down, dwmiikeypressed, {.i = XK_Down} },
* { MODKEY|ShiftMask, XK_Right, dwmiikeypressed, {.i = XK_Right} },
* { MODKEY|ShiftMask, XK_n, dwmiitoggle, {0} },
*
* - add this line in the Client struct definition in the dwm.c file :
*
* int dwmii;
*
* - compile and it should work !
*
* The dwmiitoggle sets the dwmii variable of a window, when
* the dwmii is non zero then the window marks the start of a
* new column/row depending on the layout used.
*
* Enjoy it and feel free to send me all your comments !
*
* QUINTIN Guillaume
*/
static void dwmiitoggle(const Arg *);
static void dwmiiinsertafter(Client *,Client *,int);
static void dwmiikeypressed(const Arg *);
static void dwmiiresize(Client *,int,int,int *,int *,int,int);
static void dwmiilayoutcol(void);
static void dwmiilayoutrow(void);
void dwmiitoggle(const Arg *arg)
{
if ( !lt[sellt]->arrange || (sel && sel->isfloating) ) { return; }
Client *firstclients = nexttiled(clients);
if ( sel == firstclients ) { return ; }
if ( sel->dwmii ) { sel->dwmii = 0; return; }
sel->dwmii = 1;
arrange();
}
void dwmiiinsertafter(Client *c,Client *after,int dwmii)
{
if ( !c || !after ) { return; }
detach(c);
c->dwmii = dwmii;
c->next = after->next;
after->next = c;
}
void dwmiikeypressed(const Arg *arg)
{
if ( !lt[sellt]->arrange || (sel && sel->isfloating) ) { return; }
Client* firstclients = nexttiled(clients);
if ( ( (arg->i == XK_Up) && (lt[sellt]->arrange == dwmiilayoutcol) ) ||
( (arg->i == XK_Left) && (lt[sellt]->arrange == dwmiilayoutrow) ) )
{
if ( sel->dwmii ) { return; }
Client *t = firstclients,*s = 0;
for( ; t != sel ; s = t,t = nexttiled(t->next) );
sel->dwmii = s->dwmii;
dwmiiinsertafter(s,sel,0);
}
if ( ( (arg->i == XK_Right) && (lt[sellt]->arrange == dwmiilayoutcol) ) ||
( (arg->i == XK_Down) && (lt[sellt]->arrange == dwmiilayoutrow) ) )
{
Client *t = nexttiled(sel->next),*s = 0;
if ( !t ) { sel->dwmii = 1; arrange(); return; }
int i = 2;
for( ; t && ((i -= ( t->dwmii ? 1 : 0 )) > 0) ; s = t,t = nexttiled(t->next) );
if ( sel->dwmii ) { t = nexttiled(sel->next); if ( t ) { t->dwmii = 1; } }
dwmiiinsertafter(sel,s,( i == 2 ? 1 : 0 ));
}
if ( ( (arg->i == XK_Down) && (lt[sellt]->arrange == dwmiilayoutcol) ) ||
( (arg->i == XK_Right) && (lt[sellt]->arrange == dwmiilayoutrow) ) )
{
Client *t = nexttiled(sel->next);
if ( !t || t->dwmii ) { return; }
t->dwmii = sel->dwmii;
dwmiiinsertafter(sel,t,0);
}
if ( ( (arg->i == XK_Left) && (lt[sellt]->arrange == dwmiilayoutcol) ) ||
( (arg->i == XK_Up) && (lt[sellt]->arrange == dwmiilayoutrow) ) )
{
if ( sel == firstclients ) { return; }
Client *t = firstclients,*s = 0,*u = 0;
for( ; t != sel ; s = t,t = nexttiled(t->next),u = ( t->dwmii ? s : u) );
if ( !u ) { return; }
if ( sel->dwmii ) { t = nexttiled(sel->next); if ( t ) { t->dwmii = 1; } }
dwmiiinsertafter(sel,u,0);
}
arrange();
}
void dwmiiresize(Client *c,int x,int y,int *w,int *h,int nx,int ny)
{
*w = (ww - x + wx) / nx;
*h = (wh - y + wy) / ny;
resize(c,x,y,NOBORDER(*w),NOBORDER(*h),resizehints);
*w = c->w + 2 * c->bw;
*h = c->h + 2 * c->bw;
}
void dwmiilayoutcol(void)
{
Client *firstclients = nexttiled(clients);
if ( !firstclients || (lt[sellt]->arrange != dwmiilayoutcol) ) { return; }
firstclients->dwmii = 1;
Client *t = nexttiled(firstclients->next);
int nx = 1;
for( ; t ; nx += ( t->dwmii ? 1 : 0 ),t = nexttiled(t->next) );
int x = wx,dw = 0,w = 0;
for ( t = firstclients ; t ; )
{
int ny = 1;
Client *s = nexttiled(t->next);
for( ; s && !s->dwmii ; ny++,s = nexttiled(s->next) );
int dh = 0,y = wy;
dwmiiresize(t,x,y,&w,&dh,nx,ny);
dw = ( w > dw ? w : dw );
y += dh; ny--;
for( t = nexttiled(t->next) ; t && !t->dwmii ; t = nexttiled(t->next) )
{
dwmiiresize(t,x,y,&w,&dh,nx,ny);
dw = ( w > dw ? w : dw );
y += dh; ny--;
}
x += dw; nx--; dw = 0;
}
}
void dwmiilayoutrow(void)
{
Client *firstclients = nexttiled(clients);
if ( !firstclients || (lt[sellt]->arrange != dwmiilayoutrow) ) { return; }
firstclients->dwmii = 1;
Client *t = nexttiled(firstclients->next);
int ny = 1;
for( ; t ; ny += ( t->dwmii ? 1 : 0 ),t = nexttiled(t->next) );
int y = wy,dh = 0,h = 0;
for ( t = firstclients ; t ; )
{
int nx = 1;
Client *s = nexttiled(t->next);
for( ; s && !s->dwmii ; nx++,s = nexttiled(s->next) );
int dw = 0,x = wx;
dwmiiresize(t,x,y,&dw,&h,nx,ny);
dh = ( h > dh ? h : dh );
x += dw; nx--;
for( t = nexttiled(t->next) ; t && !t->dwmii ; t = nexttiled(t->next) )
{
dwmiiresize(t,x,y,&dw,&h,nx,ny);
dh = ( h > dh ? h : dh);
x += dw; nx--;
}
y += dh; ny--; dh = 0;
}
}