sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 74c54948322f403ed7c38230280444ee0d46f1de
parent f4218d68f4c9e328639c3a4cf634cf73104b30d9
Author: Miles Alan <m@milesalan.com>
Date:   Tue, 14 Jan 2020 23:33:03 -0600

[dwm][patch] inplacerotate: Add dwm inplacerotate patch

Diffstat:
Adwm.suckless.org/patches/inplacerotate/dwm-inplacerotate-6.2.diff | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/inplacerotate/index.md | 25+++++++++++++++++++++++++
2 files changed, 125 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/inplacerotate/dwm-inplacerotate-6.2.diff b/dwm.suckless.org/patches/inplacerotate/dwm-inplacerotate-6.2.diff @@ -0,0 +1,100 @@ +From 78ae9e1513e5c9c91f7ca89f421e7aa71f88202f Mon Sep 17 00:00:00 2001 +From: Miles Alan <m@milesalan.com> +Date: Tue, 14 Jan 2020 23:14:18 -0600 +Subject: [PATCH] Add inplacerotate fn to rotate master/stack clients inplace + +Rotates all client xor stack windows (depending on focus) CW (+1) or CCW (-1). +Focus position stays 'in-place' so the area of the screen you are focused +on remains unchanged. + +Mod + Shift + {J,K} to rotate {CW,CCW} +--- + config.def.h | 2 ++ + dwm.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 56 insertions(+) + +diff --git a/config.def.h b/config.def.h +index 1c0b587..0f846ab 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -66,6 +66,8 @@ static Key keys[] = { + { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, ++ { MODKEY|ShiftMask, XK_j, inplacerotate, {.i = +1} }, ++ { MODKEY|ShiftMask, XK_k, inplacerotate, {.i = -1} }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, + { MODKEY, XK_d, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, +diff --git a/dwm.c b/dwm.c +index 4465af1..73c699b 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -175,6 +175,7 @@ static int gettextprop(Window w, Atom atom, char *text, unsigned int size); + static void grabbuttons(Client *c, int focused); + static void grabkeys(void); + static void incnmaster(const Arg *arg); ++static void inplacerotate(const Arg *arg); + static void keypress(XEvent *e); + static void killclient(const Arg *arg); + static void manage(Window w, XWindowAttributes *wa); +@@ -2147,3 +2148,56 @@ main(int argc, char *argv[]) + XCloseDisplay(dpy); + return EXIT_SUCCESS; + } ++ ++void ++insertclient(Client *item, Client *insertItem, int after) { ++ Client *c; ++ if (item == NULL || insertItem == NULL || item == insertItem) return; ++ detach(insertItem); ++ if (!after && selmon->clients == item) { ++ attach(insertItem); ++ return; ++ } ++ if (after) { ++ c = item; ++ } else { ++ for (c = selmon->clients; c; c = c->next) { if (c->next == item) break; } ++ } ++ insertItem->next = c->next; ++ c->next = insertItem; ++} ++ ++void ++inplacerotate(const Arg *arg) ++{ ++ if(!selmon->sel || (selmon->sel->isfloating && !arg->f)) return; ++ ++ unsigned int selidx = 0, i = 0; ++ Client *c = NULL, *stail = NULL, *mhead = NULL, *mtail = NULL, *shead = NULL; ++ ++ // Shift client ++ for (c = selmon->clients; c; c = c->next) { ++ if (ISVISIBLE(c) && !(c->isfloating)) { ++ if (selmon->sel == c) { selidx = i; } ++ if (i == selmon->nmaster - 1) { mtail = c; } ++ if (i == selmon->nmaster) { shead = c; } ++ if (mhead == NULL) { mhead = c; } ++ stail = c; ++ i++; ++ } ++ } ++ if (arg->i < 0 && selidx >= selmon->nmaster) insertclient(stail, shead, 1); ++ if (arg->i > 0 && selidx >= selmon->nmaster) insertclient(shead, stail, 0); ++ if (arg->i < 0 && selidx < selmon->nmaster) insertclient(mtail, mhead, 1); ++ if (arg->i > 0 && selidx < selmon->nmaster) insertclient(mhead, mtail, 0); ++ ++ // Restore focus position ++ i = 0; ++ for (c = selmon->clients; c; c = c->next) { ++ if (!ISVISIBLE(c) || (c->isfloating)) continue; ++ if (i == selidx) { focus(c); break; } ++ i++; ++ } ++ arrange(selmon); ++ focus(c); ++} +-- +2.23.1 + diff --git a/dwm.suckless.org/patches/inplacerotate/index.md b/dwm.suckless.org/patches/inplacerotate/index.md @@ -0,0 +1,25 @@ +inplacerotate +============= + +Description +----------- +This patch provides a keybinding to rotate all clients in the currently +selected area (master or stack) without affecting the other area. + +This allows you to shift the ordering of clients in the master / stack area +without worrying clients will transfer between the master / stack (nmaster) +boundry. If your current focus is in the master area, clients in the master +rotate and stack clients are left alone. And inversely, if you're focused on +a client in the stack, stack clients are rotated but master clients are left +alone. Also in addition to not affecting the nmaster boundry, the focused +client is always kept fixed on the current position (e.g. the screen focus +area doesn't change) making this a fully 'in-place' rotation. + + +Download +-------- +* [dwm-inplacerotate-6.2.diff](dwm-inplacerotate-6.2.diff) + +Authors +------- +* Miles Alan - <m@milesalan.com>