Donald Chai wrote:
@pancake :
> I dont see any point for having a function called
> "dwmiinoinfiniteloop"
Well this function is necessary, I didn't know how to call it, though
its name is relevant... If you don't like its name feel free to change
it but I won't. The important thing is that it does its job.
I think what "pancake" meant is that code that needs a function called
"dwmiinoinfiniteloop" can usually be rewritten to not require it,
improving maintainability. From what I can tell, it unsets the second
dwmii bit it finds, merging the second column of windows into the first
column. Why?
--snip--
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; }
}
The code below contains lots of "if's" that seem to be always true (or
should be). Why check them? You don't call dwmiilayoutcol unless if
(lt[sellt]->arrange == dwmiilayoutcol). Also, the line
if (t->dwmii)
should always be true. Otherwise, you'll get an infinite loop. I think
it'd be better to remove this check (and not explicitly set
firstclients->dwmii=1). This might work better for the case of windows
having multiple tags...
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;
}
}
}
You are absolutely right about the "if ( t->dwmii )" which are always
true. I suppress them. About the dwmiinoinfiniteloop : I wrote this
function to avoid infinite loop in dwmiilayoutXXX caused by the "if (
t->dwmii )". But I also wrote this function for another purpose wich is
only a matter of how the windows are arranged. It's not a matter of
merging two columns. If I remove this function : if you have in tag 1
Client0 and in tag 2 : Client1 and Client2 on two columns then Client2
will have its dwmii <> 0. If I close Client1 and move Client0 into tag 2
then I will have two columns and that is not what I want.
I want, that when you add a window into a tag, the window automatically
goes into column 1 exept if the window marks a new column. That I will
know because it is the first window of a column. If I suppress this
function then the first window of a tag will not necessarily have its
dwmii set to non zero.
Well, this is only how the clients are added into a tag. If you don't
like this way then suppress the function. I will tell all this in the
header of the dwmii.c file to let the user choose. I have not much time
so I will do it later.
Thanks for your comments and your help.
Kind regards
QUINTIN Guillaume.
PS : for all : I am french so my name "in english language" is Guillaume
QUINTIN. QUINTIN is NOT my first name, it's Guillaume.