new feature: add swap{next,prev} for reordering visible windows
This commit is contained in:
parent
5d06303f48
commit
a22b4c1008
|
@ -70,6 +70,8 @@ awesome:
|
||||||
(("Mod4"), "b", "togglebar"),
|
(("Mod4"), "b", "togglebar"),
|
||||||
(("Mod4"), "j", "focusnext"),
|
(("Mod4"), "j", "focusnext"),
|
||||||
(("Mod4"), "k", "focusprev"),
|
(("Mod4"), "k", "focusprev"),
|
||||||
|
(("Mod4", "Shift"), "j", "swapnext"),
|
||||||
|
(("Mod4", "Shift"), "k", "swapprev"),
|
||||||
(("Mod4", "Control"), "j", "focusnextscreen"),
|
(("Mod4", "Control"), "j", "focusnextscreen"),
|
||||||
(("Mod4", "Control"), "k", "focusprevscreen"),
|
(("Mod4", "Control"), "k", "focusprevscreen"),
|
||||||
(("Mod4"), "h", "setmwfact", "-0.05"),
|
(("Mod4"), "h", "setmwfact", "-0.05"),
|
||||||
|
|
70
client.c
70
client.c
|
@ -182,6 +182,39 @@ setclienttrans(Client *c, double opacity)
|
||||||
XSync(c->display, False);
|
XSync(c->display, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Swap two client in the linked list clients
|
||||||
|
* \param c1 first client
|
||||||
|
* \param c2 second client
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
client_swap(Client *c1, Client *c2)
|
||||||
|
{
|
||||||
|
Client *tmp;
|
||||||
|
|
||||||
|
tmp = c1->next;
|
||||||
|
c1->next = c2->next;
|
||||||
|
c2->next = (tmp == c2 ? c1 : tmp);
|
||||||
|
|
||||||
|
tmp = c2->prev;
|
||||||
|
c2->prev = c1->prev;
|
||||||
|
c1->prev = (tmp == c1 ? c2 : tmp );
|
||||||
|
|
||||||
|
if(c1->next)
|
||||||
|
c1->next->prev = c1;
|
||||||
|
|
||||||
|
if(c1->prev)
|
||||||
|
c1->prev->next = c1;
|
||||||
|
|
||||||
|
if(c2->next)
|
||||||
|
c2->next->prev = c2;
|
||||||
|
|
||||||
|
if(c2->prev)
|
||||||
|
c2->prev->next = c2;
|
||||||
|
|
||||||
|
if(clients == c1)
|
||||||
|
clients = c2;
|
||||||
|
}
|
||||||
|
|
||||||
/** Attach client to the beginning of the clients stack
|
/** Attach client to the beginning of the clients stack
|
||||||
* \param c the client
|
* \param c the client
|
||||||
*/
|
*/
|
||||||
|
@ -742,3 +775,40 @@ uicb_setborder(Display *disp __attribute__ ((unused)),
|
||||||
awesomeconf->borderpx = 0;
|
awesomeconf->borderpx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
uicb_swapnext(Display *disp,
|
||||||
|
DC *drawcontext,
|
||||||
|
awesome_config *awesomeconf,
|
||||||
|
const char *arg __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
Client *next;
|
||||||
|
|
||||||
|
if(!sel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(next = sel->next; next && !isvisible(next, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); next = next->next);
|
||||||
|
if(next)
|
||||||
|
{
|
||||||
|
client_swap(sel, next);
|
||||||
|
arrange(disp, drawcontext, awesomeconf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
uicb_swapprev(Display *disp,
|
||||||
|
DC *drawcontext,
|
||||||
|
awesome_config *awesomeconf,
|
||||||
|
const char *arg __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
Client *prev;
|
||||||
|
|
||||||
|
if(!sel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(prev = sel->prev; prev && !isvisible(prev, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); prev = prev->prev);
|
||||||
|
if(prev)
|
||||||
|
{
|
||||||
|
client_swap(prev, sel);
|
||||||
|
arrange(disp, drawcontext, awesomeconf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
2
client.h
2
client.h
|
@ -72,5 +72,7 @@ UICB_PROTO(uicb_killclient);
|
||||||
UICB_PROTO(uicb_moveresize);
|
UICB_PROTO(uicb_moveresize);
|
||||||
UICB_PROTO(uicb_settrans);
|
UICB_PROTO(uicb_settrans);
|
||||||
UICB_PROTO(uicb_setborder);
|
UICB_PROTO(uicb_setborder);
|
||||||
|
UICB_PROTO(uicb_swapnext);
|
||||||
|
UICB_PROTO(uicb_swapprev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
2
config.c
2
config.c
|
@ -89,6 +89,8 @@ static const NameFuncLink KeyfuncList[] = {
|
||||||
{"moveresize", uicb_moveresize},
|
{"moveresize", uicb_moveresize},
|
||||||
{"settrans", uicb_settrans},
|
{"settrans", uicb_settrans},
|
||||||
{"setborder", uicb_setborder},
|
{"setborder", uicb_setborder},
|
||||||
|
{"swapnext", uicb_swapnext},
|
||||||
|
{"swapprev", uicb_swapprev},
|
||||||
/* tag.c */
|
/* tag.c */
|
||||||
{"tag", uicb_tag},
|
{"tag", uicb_tag},
|
||||||
{"togglefloating", uicb_togglefloating},
|
{"togglefloating", uicb_togglefloating},
|
||||||
|
|
Loading…
Reference in New Issue