On Wed, 2008-07-30 at 13:14 +0200, QUINTIN Guillaume wrote: > Hi all, > > This is the DWMII layout for DWM 5.1. It is a layout in the dwm way this > time ! The only modification is within the Client struct and holds in 11 > chars : "int dwmii;\n". This modification prevents from having a more > complex algorithm and more lines of code. The last release of my layout > for dwm 5.0.1 contained bugs that I found later. Now, I think it's bug > free and I review the code for cleaning ! I also added the row layout > because I missed it. Feel free to try it and send me all your comments. > > Kind regards, > QUINTIN Guillaume.
Hi Quintin! Looks you're working hard to make dwmii fit more in the dwm concepts. I am currenty a dwm addict, and see no points for using the wmii approach, but it is an interesting area to play and maybe is somebody interested on it. I'll try it :) Just some comments: - If its just a layout. distribute it in a separate file and include it from config.h. - Write the instructions in the header of your .c file to add the "int dwmii" in dwm.c manually. - I dont see any point for having a function called "dwmiinoinfiniteloop" - conditional and loop brackets should be in the same line (for () {...) and if () { instead of for()\n{. - upload it, give an url and update the wiki :) Fix those minor tips and I'll play with it this night at home! --pancake > plain text document attachment (dwmii.patch) > --- dwm.org.c 2008-07-30 12:48:52.000000000 +0200 > +++ dwm.c 2008-07-30 12:56:10.000000000 +0200 > @@ -91,6 +91,7 @@ > Client *next; > Client *snext; > Window win; > + int dwmii; > }; > > typedef struct { > @@ -201,6 +202,12 @@ > static int xerrordummy(Display *dpy, XErrorEvent *ee); > static int xerrorstart(Display *dpy, XErrorEvent *ee); > static void zoom(const Arg *arg); > +static void dwmiitoggle(const Arg *); > +static void dwmiiinsertafter(Client *,Client *,int); > +static void dwmiikeypressed(const Arg *); > +static void dwmiinoinfiniteloop(void); > +static void dwmiilayoutcol(void); > +static void dwmiilayoutrow(void); > > /* variables */ > static char stext[256]; > @@ -1742,3 +1749,127 @@ > XCloseDisplay(dpy); > return 0; > } > + > +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 dwmiinoinfiniteloop(void) > +{ > + Client* firstclients = nexttiled(clients),*t = firstclients; > + for( ; t && !t->dwmii ; t = nexttiled(t->next) ); > + firstclients->dwmii = 1; > + if ( t && (t != firstclients) ) { t->dwmii = 0; } > +} > + > +void dwmiilayoutcol(void) > +{ > + Client *firstclients = nexttiled(clients); > + if ( !firstclients || (lt[sellt]->arrange != dwmiilayoutcol) ) { > return; } > + dwmiinoinfiniteloop(); > + Client *t = nexttiled(firstclients->next); > + int n = 1; > + for( ; t ; n += ( t->dwmii ? 1 : 0 ),t = nexttiled(t->next) ); > + int x = wx,dw = ww / n; > + for ( t = firstclients ; t ; ) > + { > + if ( t->dwmii ) > + { > + n = 1; > + Client *s = nexttiled(t->next); > + for( ; s && !s->dwmii ; n++,s = nexttiled(s->next) ); > + int dh = wh / n,y = wy + dh; > + resize(t,x,wy,dw - 2 * t->bw,dh - 2 * > t->bw,resizehints); > + for( t = nexttiled(t->next) ; t && !t->dwmii ; t = > nexttiled(t->next) ) > + { > + resize(t,x,y,dw - 2 * t->bw,dh - 2 * > t->bw,resizehints); > + y += dh; > + } > + x += dw; > + } > + } > +} > + > +void dwmiilayoutrow(void) > +{ > + Client *firstclients = nexttiled(clients); > + if ( !firstclients || (lt[sellt]->arrange != dwmiilayoutrow) ) { > return; } > + dwmiinoinfiniteloop(); > + Client *t = nexttiled(firstclients->next); > + int n = 1; > + for( ; t ; n += ( t->dwmii ? 1 : 0 ),t = nexttiled(t->next) ); > + int y = wy,dh = wh / n; > + for ( t = firstclients ; t ; ) > + { > + if ( t->dwmii ) > + { > + n = 1; > + Client *s = nexttiled(t->next); > + for( ; s && !s->dwmii ; n++,s = nexttiled(s->next) ); > + int dw = ww / n,x = wx + dw; > + resize(t,wx,y,dw - 2 * t->bw,dh - 2 * > t->bw,resizehints); > + for( t = nexttiled(t->next) ; t && !t->dwmii ; t = > nexttiled(t->next) ) > + { > + resize(t,x,y,dw - 2 * t->bw,dh - 2 * > t->bw,resizehints); > + x += dw; > + } > + y += dh; > + } > + } > +} > +