Improve movestack patch code
This commit is contained in:
parent
cb834ddbfe
commit
583a91998d
|
@ -65,7 +65,6 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
|
||||||
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
static const char *termcmd[] = { "gnome-terminal", "--wait", NULL };
|
static const char *termcmd[] = { "gnome-terminal", "--wait", NULL };
|
||||||
|
|
||||||
#include "movestack.c"
|
|
||||||
static Key keys[] = {
|
static Key keys[] = {
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||||
|
|
50
dwm.c
50
dwm.c
|
@ -207,6 +207,7 @@ static void maprequest(XEvent *e);
|
||||||
static void monocle(Monitor *m);
|
static void monocle(Monitor *m);
|
||||||
static void motionnotify(XEvent *e);
|
static void motionnotify(XEvent *e);
|
||||||
static void movemouse(const Arg *arg);
|
static void movemouse(const Arg *arg);
|
||||||
|
static void movestack(const Arg *arg);
|
||||||
static Client *nexttiled(Client *c);
|
static Client *nexttiled(Client *c);
|
||||||
static void pop(Client *);
|
static void pop(Client *);
|
||||||
static void propertynotify(XEvent *e);
|
static void propertynotify(XEvent *e);
|
||||||
|
@ -1341,6 +1342,55 @@ movemouse(const Arg *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
movestack(const Arg *arg) {
|
||||||
|
Client *c = NULL, *p = NULL, *pc = NULL, *i;
|
||||||
|
|
||||||
|
if(arg->i > 0) {
|
||||||
|
/* find the client after selmon->sel */
|
||||||
|
for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||||
|
if(!c)
|
||||||
|
for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* find the client before selmon->sel */
|
||||||
|
for(i = selmon->clients; i != selmon->sel; i = i->next)
|
||||||
|
if(ISVISIBLE(i) && !i->isfloating)
|
||||||
|
c = i;
|
||||||
|
if(!c)
|
||||||
|
for(; i; i = i->next)
|
||||||
|
if(ISVISIBLE(i) && !i->isfloating)
|
||||||
|
c = i;
|
||||||
|
}
|
||||||
|
/* find the client before selmon->sel and c */
|
||||||
|
for(i = selmon->clients; i && (!p || !pc); i = i->next) {
|
||||||
|
if(i->next == selmon->sel)
|
||||||
|
p = i;
|
||||||
|
if(i->next == c)
|
||||||
|
pc = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* swap c and selmon->sel selmon->clients in the selmon->clients list */
|
||||||
|
if(c && c != selmon->sel) {
|
||||||
|
Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
|
||||||
|
selmon->sel->next = c->next==selmon->sel?c:c->next;
|
||||||
|
c->next = temp;
|
||||||
|
|
||||||
|
if(p && p != c)
|
||||||
|
p->next = c;
|
||||||
|
if(pc && pc != selmon->sel)
|
||||||
|
pc->next = selmon->sel;
|
||||||
|
|
||||||
|
if(selmon->sel == selmon->clients)
|
||||||
|
selmon->clients = c;
|
||||||
|
else if(c == selmon->clients)
|
||||||
|
selmon->clients = selmon->sel;
|
||||||
|
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
nexttiled(Client *c)
|
nexttiled(Client *c)
|
||||||
{
|
{
|
||||||
|
|
49
movestack.c
49
movestack.c
|
@ -1,49 +0,0 @@
|
||||||
void
|
|
||||||
movestack(const Arg *arg) {
|
|
||||||
Client *c = NULL, *p = NULL, *pc = NULL, *i;
|
|
||||||
|
|
||||||
if(arg->i > 0) {
|
|
||||||
/* find the client after selmon->sel */
|
|
||||||
for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
|
||||||
if(!c)
|
|
||||||
for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* find the client before selmon->sel */
|
|
||||||
for(i = selmon->clients; i != selmon->sel; i = i->next)
|
|
||||||
if(ISVISIBLE(i) && !i->isfloating)
|
|
||||||
c = i;
|
|
||||||
if(!c)
|
|
||||||
for(; i; i = i->next)
|
|
||||||
if(ISVISIBLE(i) && !i->isfloating)
|
|
||||||
c = i;
|
|
||||||
}
|
|
||||||
/* find the client before selmon->sel and c */
|
|
||||||
for(i = selmon->clients; i && (!p || !pc); i = i->next) {
|
|
||||||
if(i->next == selmon->sel)
|
|
||||||
p = i;
|
|
||||||
if(i->next == c)
|
|
||||||
pc = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* swap c and selmon->sel selmon->clients in the selmon->clients list */
|
|
||||||
if(c && c != selmon->sel) {
|
|
||||||
Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
|
|
||||||
selmon->sel->next = c->next==selmon->sel?c:c->next;
|
|
||||||
c->next = temp;
|
|
||||||
|
|
||||||
if(p && p != c)
|
|
||||||
p->next = c;
|
|
||||||
if(pc && pc != selmon->sel)
|
|
||||||
pc->next = selmon->sel;
|
|
||||||
|
|
||||||
if(selmon->sel == selmon->clients)
|
|
||||||
selmon->clients = c;
|
|
||||||
else if(c == selmon->clients)
|
|
||||||
selmon->clients = selmon->sel;
|
|
||||||
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue