patch: push

This commit is contained in:
frosty 2024-09-04 00:04:26 -04:00
parent 91787c75b3
commit c1cb54a0e0
2 changed files with 58 additions and 0 deletions

View file

@ -69,6 +69,8 @@ static const Key keys[] = {
{ MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY|ControlMask, XK_j, pushdown, {0} },
{ MODKEY|ControlMask, XK_k, pushup, {0} },
{ MODKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_h, setmfact, {.f = -0.05} },

56
dwm.c
View file

@ -189,7 +189,10 @@ static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg); static void movemouse(const Arg *arg);
static Client *nexttiled(Client *c); static Client *nexttiled(Client *c);
static void pop(Client *c); static void pop(Client *c);
static Client *prevtiled(Client *c);
static void propertynotify(XEvent *e); static void propertynotify(XEvent *e);
static void pushdown(const Arg *arg);
static void pushup(const Arg *arg);
static void quit(const Arg *arg); static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h); static Monitor *recttomon(int x, int y, int w, int h);
static void resize(Client *c, int x, int y, int w, int h, int interact); static void resize(Client *c, int x, int y, int w, int h, int interact);
@ -1262,6 +1265,16 @@ pop(Client *c)
arrange(c->mon); arrange(c->mon);
} }
Client *
prevtiled(Client *c) {
Client *p, *r;
for(p = selmon->clients, r = NULL; p && p != c; p = p->next)
if(!p->isfloating && ISVISIBLE(p))
r = p;
return r;
}
void void
propertynotify(XEvent *e) propertynotify(XEvent *e)
{ {
@ -1299,6 +1312,49 @@ propertynotify(XEvent *e)
} }
} }
void
pushdown(const Arg *arg) {
Client *sel = selmon->sel, *c;
if(!sel || sel->isfloating)
return;
if((c = nexttiled(sel->next))) {
detach(sel);
sel->next = c->next;
c->next = sel;
} else {
detach(sel);
attach(sel);
}
focus(sel);
arrange(selmon);
}
void
pushup(const Arg *arg) {
Client *sel = selmon->sel, *c;
if(!sel || sel->isfloating)
return;
if((c = prevtiled(sel))) {
detach(sel);
sel->next = c;
if(selmon->clients == c)
selmon->clients = sel;
else {
for(c = selmon->clients; c->next != sel->next; c = c->next);
c->next = sel;
}
} else {
for(c = sel; c->next; c = c->next);
detach(sel);
sel->next = NULL;
c->next = sel;
}
focus(sel);
arrange(selmon);
}
void void
quit(const Arg *arg) quit(const Arg *arg)
{ {