dwm-inplacerotate-6.2.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-inplacerotate-6.2.diff (3768B) | |
--- | |
1 From 75012a6ab9cc1b6c319af7f4ae7d682b16a66ce3 Mon Sep 17 00:00:00 2001 | |
2 From: Miles Alan <[email protected]> | |
3 Date: Sun, 26 Apr 2020 16:05:43 -0500 | |
4 Subject: [PATCH] Add inplacerotate fn to rotate all, master, or stacks c… | |
5 inplace | |
6 | |
7 CW (+2) or CCW (-2) Rotates all windows. | |
8 CW (+1) or CCW (-1) Rotates master xor stack windows (depending on focus… | |
9 | |
10 Focus position stays 'in-place' so the area of the screen you are focused | |
11 on remains unchanged. | |
12 --- | |
13 config.def.h | 4 ++++ | |
14 dwm.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
15 2 files changed, 63 insertions(+) | |
16 | |
17 diff --git a/config.def.h b/config.def.h | |
18 index 1c0b587..9bcb792 100644 | |
19 --- a/config.def.h | |
20 +++ b/config.def.h | |
21 @@ -66,6 +66,10 @@ static Key keys[] = { | |
22 { MODKEY, XK_b, togglebar, {0} … | |
23 { MODKEY, XK_j, focusstack, {.i … | |
24 { MODKEY, XK_k, focusstack, {.i … | |
25 + { MODKEY|ShiftMask, XK_j, inplacerotate, {.i … | |
26 + { MODKEY|ShiftMask, XK_k, inplacerotate, {.i … | |
27 + { MODKEY|ShiftMask, XK_h, inplacerotate, {.i … | |
28 + { MODKEY|ShiftMask, XK_l, inplacerotate, {.i … | |
29 { MODKEY, XK_i, incnmaster, {.i … | |
30 { MODKEY, XK_d, incnmaster, {.i … | |
31 { MODKEY, XK_h, setmfact, {.f … | |
32 diff --git a/dwm.c b/dwm.c | |
33 index 4465af1..3930680 100644 | |
34 --- a/dwm.c | |
35 +++ b/dwm.c | |
36 @@ -175,6 +175,7 @@ static int gettextprop(Window w, Atom atom, char *te… | |
37 static void grabbuttons(Client *c, int focused); | |
38 static void grabkeys(void); | |
39 static void incnmaster(const Arg *arg); | |
40 +static void inplacerotate(const Arg *arg); | |
41 static void keypress(XEvent *e); | |
42 static void killclient(const Arg *arg); | |
43 static void manage(Window w, XWindowAttributes *wa); | |
44 @@ -2147,3 +2148,61 @@ main(int argc, char *argv[]) | |
45 XCloseDisplay(dpy); | |
46 return EXIT_SUCCESS; | |
47 } | |
48 + | |
49 +void | |
50 +insertclient(Client *item, Client *insertItem, int after) { | |
51 + Client *c; | |
52 + if (item == NULL || insertItem == NULL || item == insertItem) r… | |
53 + detach(insertItem); | |
54 + if (!after && selmon->clients == item) { | |
55 + attach(insertItem); | |
56 + return; | |
57 + } | |
58 + if (after) { | |
59 + c = item; | |
60 + } else { | |
61 + for (c = selmon->clients; c; c = c->next) { if (c->next… | |
62 + } | |
63 + insertItem->next = c->next; | |
64 + c->next = insertItem; | |
65 +} | |
66 + | |
67 +void | |
68 +inplacerotate(const Arg *arg) | |
69 +{ | |
70 + if(!selmon->sel || (selmon->sel->isfloating && !arg->f)) return; | |
71 + | |
72 + unsigned int selidx = 0, i = 0; | |
73 + Client *c = NULL, *stail = NULL, *mhead = NULL, *mtail = NULL, … | |
74 + | |
75 + // Determine positionings for insertclient | |
76 + for (c = selmon->clients; c; c = c->next) { | |
77 + if (ISVISIBLE(c) && !(c->isfloating)) { | |
78 + if (selmon->sel == c) { selidx = i; } | |
79 + if (i == selmon->nmaster - 1) { mtail = c; } | |
80 + if (i == selmon->nmaster) { shead = c; } | |
81 + if (mhead == NULL) { mhead = c; } | |
82 + stail = c; | |
83 + i++; | |
84 + } | |
85 + } | |
86 + | |
87 + // All clients rotate | |
88 + if (arg->i == 2) insertclient(selmon->clients, stail, 0); | |
89 + if (arg->i == -2) insertclient(stail, selmon->clients, 1); | |
90 + // Stack xor master rotate | |
91 + if (arg->i == -1 && selidx >= selmon->nmaster) insertclient(sta… | |
92 + if (arg->i == 1 && selidx >= selmon->nmaster) insertclient(shea… | |
93 + if (arg->i == -1 && selidx < selmon->nmaster) insertclient(mta… | |
94 + if (arg->i == 1 && selidx < selmon->nmaster) insertclient(mhea… | |
95 + | |
96 + // Restore focus position | |
97 + i = 0; | |
98 + for (c = selmon->clients; c; c = c->next) { | |
99 + if (!ISVISIBLE(c) || (c->isfloating)) continue; | |
100 + if (i == selidx) { focus(c); break; } | |
101 + i++; | |
102 + } | |
103 + arrange(selmon); | |
104 + focus(c); | |
105 +} | |
106 -- | |
107 2.23.1 | |
108 |