Hi,
I am using a eeepc 701 for some time now with dwm. As you know the
screen is very small and, when dealing with windows that have
resizehints in tile layout I get some problems. For example, suppose
that I have several (let's say 4 or 5) windows in a tag, and that the
first window of the stack has a resizehints that does not allow dwm to
set its height less than a certain limit. Then if this limit is more
than half of the screen height, I will be unable to see the others
windows on the stack. So I suggest that the lines 1441 to 1452 should be
replaced by
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) / n;
resize(c,x,y,NOBORDER(w),NOBORDER(h),resizehints);
y += c->h + 2 * c->bw; n--;
}
and the i variable is unused so it can be safely removed.
I apllied this little patch to dwm 5.1 and it is better now. I had the
same problem with my dwmii layout so i fixed it and it is a
little better now too.
Of course it does not change the situation when the resizehints window
is placed in the middle of the stack. To avoid this situation it will
take some LOCs. Will you accept ?
I have made some light changes to the dwmii layout. Tell me what is
missing to put it in the tutorial.
Kind regards,
QUINTIN Guillaume.
/*
* 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.1
* - 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) / nx;
*h = (wh - y) / ny;
resize(c,x,y,*w - 2 * c->bw,*h - 2 * c->bw,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--;
}
printf("\n");
x += dw; nx--;
}
}
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--;
}
}