Hi,
I propose these two functions to switch among clients. These functions are
similar to zoom function but they eliminate the dead loop between first
and second clients in the case of repetitive zoom calls. next_client
cycles the clients in the counterclockwise direction and prev_client vice
versa. Code blocks with the corresponding code files are given below. I
would like to thank Engin Tola for his suggestions.
Regards,
Zafer ARICAN
layout.c
***************************
void
next_client(const char *arg){
Client *c;
Client *cm;
cm = clients;
if(!sel || lt->arrange == floating || sel->isfloating)
return;
if((c = sel) == nexttiled(clients))
if(!(c = nexttiled(c->next)))
return;
detach(cm);
detach(c);
attach(c);
push_to_bottom(cm);
focus(c);
lt->arrange();
}
void
prev_client(const char *arg){
Client *c;
Client **cl;
if(!sel || lt->arrange == floating || sel->isfloating)
return;
if((c = sel) == nexttiled(clients))
if(!(c = nexttiled(c->next)))
return;
else {
pull_from_bottom(cl);
attach(*cl);
focus(*cl);
lt->arrange();
return;
}
detach(c);
attach(c);
focus(c);
lt->arrange();
}
client.c
***************************
void
push_to_bottom(Client *c){
Client *dum;
for(dum = clients; dum->next; dum = dum->next);
dum->next = c;
c->prev = dum;
c->next = NULL;
}
void
pull_from_bottom(Client **c){
Client *dum;
for(dum = clients; dum->next; dum = dum->next);
*c = dum;
detach(*c);
}
dwm.h
*************************
void push_to_bottom(Client *c); /* attaches c to beginning of
the global client list */
void pull_from_bottom(Client **c); /* detaches the bottom client and
points to c
void next_client(const char *arg); /* cyclic zoom - counter
clockwise*/
void prev_client(const char *arg); /* cyclic zoom - clockwise
config.h
**************************
{ MODKEY, XK_Tab, next_client, NULL },
\
{ MODKEY|ShiftMask, XK_Tab, prev_client, NULL },
\
--
Zafer ARICAN
http://lts4www.epfl.ch/~arican