dwm-cfacts_centeredmaster-6.2.diff - sites - public wiki contents of suckless.o… | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-cfacts_centeredmaster-6.2.diff (5432B) | |
--- | |
1 diff -up a/config.def.h b/config.def.h | |
2 --- a/config.def.h 2019-06-05 02:24:05.503321320 +0200 | |
3 +++ b/config.def.h 2019-06-05 10:46:48.099997829 +0200 | |
4 @@ -41,6 +41,8 @@ static const Layout layouts[] = { | |
5 { "[]=", tile }, /* first entry is default */ | |
6 { "><>", NULL }, /* no layout function means floating b… | |
7 { "[M]", monocle }, | |
8 + { "|M|", centeredmaster }, | |
9 + { ">M>", centeredfloatingmaster }, | |
10 }; | |
11 | |
12 /* key definitions */ | |
13 @@ -79,6 +81,8 @@ static Key keys[] = { | |
14 { MODKEY, XK_t, setlayout, {.v … | |
15 { MODKEY, XK_f, setlayout, {.v … | |
16 { MODKEY, XK_m, setlayout, {.v … | |
17 + { MODKEY, XK_u, setlayout, {.v … | |
18 + { MODKEY, XK_o, setlayout, {.v … | |
19 { MODKEY, XK_space, setlayout, {0} … | |
20 { MODKEY|ShiftMask, XK_space, togglefloating, {0} … | |
21 { MODKEY, XK_0, view, {.ui… | |
22 Only in a: config.def.h.orig | |
23 Only in b: dwm-bottomstack-20160719-56a31dc.diff | |
24 diff -up a/dwm.c b/dwm.c | |
25 --- a/dwm.c 2019-06-05 02:25:40.169986187 +0200 | |
26 +++ b/dwm.c 2019-06-05 10:48:42.443328992 +0200 | |
27 @@ -235,6 +235,8 @@ static int xerror(Display *dpy, XErrorEv | |
28 static int xerrordummy(Display *dpy, XErrorEvent *ee); | |
29 static int xerrorstart(Display *dpy, XErrorEvent *ee); | |
30 static void zoom(const Arg *arg); | |
31 +static void centeredmaster(Monitor *m); | |
32 +static void centeredfloatingmaster(Monitor *m); | |
33 | |
34 /* variables */ | |
35 static const char broken[] = "broken"; | |
36 @@ -2175,3 +2177,144 @@ main(int argc, char *argv[]) | |
37 XCloseDisplay(dpy); | |
38 return EXIT_SUCCESS; | |
39 } | |
40 + | |
41 +void | |
42 +centeredmaster(Monitor *m) | |
43 +{ | |
44 + unsigned int i, n, h, mw, mx, my, oty, ety, tw; | |
45 + float mfacts = 0, lfacts = 0, rfacts = 0; | |
46 + Client *c; | |
47 + | |
48 + /* count number of clients in the selected monitor */ | |
49 + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next… | |
50 + if (n < m->nmaster) | |
51 + mfacts += c->cfact; | |
52 + else if ((n - m->nmaster) % 2) | |
53 + lfacts += c->cfact; | |
54 + else | |
55 + rfacts += c->cfact; | |
56 + } | |
57 + if (n == 0) | |
58 + return; | |
59 + if(n == 1){ | |
60 + c = nexttiled(m->clients); | |
61 + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * … | |
62 + return; | |
63 + } | |
64 + | |
65 + /* initialize areas */ | |
66 + mw = m->ww; | |
67 + mx = 0; | |
68 + my = 0; | |
69 + tw = mw; | |
70 + | |
71 + if (n > m->nmaster) { | |
72 + /* go mfact box in the center if more than nmaster clie… | |
73 + mw = m->nmaster ? m->ww * m->mfact : 0; | |
74 + tw = m->ww - mw; | |
75 + | |
76 + if (n - m->nmaster > 1) { | |
77 + /* only one client */ | |
78 + mx = (m->ww - mw) / 2; | |
79 + tw = (m->ww - mw) / 2; | |
80 + } | |
81 + } | |
82 + | |
83 + oty = 0; | |
84 + ety = 0; | |
85 + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next… | |
86 + if (i < m->nmaster) { | |
87 + /* nmaster clients are stacked vertically, in the center | |
88 + * of the screen */ | |
89 + h = (m->wh - my) * (c->cfact / mfacts); | |
90 + resize(c, m->wx + mx, m->wy + my, mw - 2*c->bw, | |
91 + h - 2*c->bw, 0); | |
92 + if(my + HEIGHT(c) < m->mh) | |
93 + my += HEIGHT(c); | |
94 + mfacts -= c->cfact; | |
95 + } else { | |
96 + /* stack clients are stacked vertically */ | |
97 + if ((i - m->nmaster) % 2) { | |
98 + h = (m->wh - ety) * (c->cfact / lfacts); | |
99 + if(m->nmaster == 0) | |
100 + resize(c, m->wx, m->wy + ety, tw - 2*c-… | |
101 + h - 2*c->bw, 0); | |
102 + else | |
103 + resize(c, m->wx, m->wy + ety, tw - 2*c-… | |
104 + h - 2*c->bw, 0); | |
105 + if(ety + HEIGHT(c) < m->mh) | |
106 + ety += HEIGHT(c); | |
107 + lfacts -= c->cfact; | |
108 + } else { | |
109 + h = (m->wh - oty) * (c->cfact / rfacts); | |
110 + resize(c, m->wx + mx + mw, m->wy + oty, | |
111 + tw - 2*c->bw, h - 2*c->bw, 0); | |
112 + if(oty + HEIGHT(c) < m->mh) | |
113 + oty += HEIGHT(c); | |
114 + rfacts -= c->cfact; | |
115 + } | |
116 + } | |
117 +} | |
118 + | |
119 +void | |
120 +centeredfloatingmaster(Monitor *m) | |
121 +{ | |
122 + unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx; | |
123 + float mfacts = 0, sfacts = 0; | |
124 + Client *c; | |
125 + | |
126 + /* count number of clients in the selected monitor */ | |
127 + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next… | |
128 + if (n < m->nmaster) | |
129 + mfacts += c->cfact; | |
130 + else | |
131 + sfacts += c->cfact; | |
132 + } | |
133 + if (n == 0) | |
134 + return; | |
135 + if(n == 1){ | |
136 + c = nexttiled(m->clients); | |
137 + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * … | |
138 + return; | |
139 + } | |
140 + | |
141 + /* initialize nmaster area */ | |
142 + if (n > m->nmaster) { | |
143 + /* go mfact box in the center if more than nmaster clie… | |
144 + if (m->ww > m->wh) { | |
145 + mw = m->nmaster ? m->ww * m->mfact : 0; | |
146 + mh = m->nmaster ? m->wh * 0.9 : 0; | |
147 + } else { | |
148 + mh = m->nmaster ? m->wh * m->mfact : 0; | |
149 + mw = m->nmaster ? m->ww * 0.9 : 0; | |
150 + } | |
151 + mx = mxo = (m->ww - mw) / 2; | |
152 + my = myo = (m->wh - mh) / 2; | |
153 + } else { | |
154 + /* go fullscreen if all clients are in the master area … | |
155 + mh = m->wh; | |
156 + mw = m->ww; | |
157 + mx = mxo = 0; | |
158 + my = myo = 0; | |
159 + } | |
160 + | |
161 + for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->… | |
162 + if (i < m->nmaster) { | |
163 + /* nmaster clients are stacked horizontally, in the cen… | |
164 + * of the screen */ | |
165 + w = (mw + mxo - mx) * (c->cfact / mfacts); | |
166 + resize(c, m->wx + mx, m->wy + my, w - 2*c->bw, | |
167 + mh - 2*c->bw, 0); | |
168 + if(mx + WIDTH(c) < m->mw) | |
169 + mx += WIDTH(c); | |
170 + mfacts -= c->cfact; | |
171 + } else { | |
172 + /* stack clients are stacked horizontally */ | |
173 + w = (m->ww - tx) * (c->cfact / sfacts); | |
174 + resize(c, m->wx + tx, m->wy, w - 2*c->bw, | |
175 + m->wh - 2*c->bw, 0); | |
176 + if(tx + WIDTH(c) < m->mw) | |
177 + tx += WIDTH(c); | |
178 + sfacts -= c->cfact; | |
179 + } | |
180 +} |