Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-bartabgroups-20210802-138b405.diff - sites - public wiki contents of suckle…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-bartabgroups-20210802-138b405.diff (7095B)
---
1 From 653c99b94cc780a2def9c7e50a87703156535f8b Mon Sep 17 00:00:00 2001
2 From: Jack Bird <[email protected]>
3 Date: Mon, 2 Aug 2021 18:50:02 +0100
4 Subject: [PATCH] bartabgroups updated to work with 138b405
5
6 ---
7 config.def.h | 11 +++++
8 dwm.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++-----
9 2 files changed, 112 insertions(+), 11 deletions(-)
10
11 diff --git a/config.def.h b/config.def.h
12 index a2ac963..82accf1 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -16,6 +16,8 @@ static const char *colors[][3] = {
16 /* fg bg border */
17 [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
18 [SchemeSel] = { col_gray4, col_cyan, col_cyan },
19 + [SchemeTabActive] = { col_gray2, col_gray3, col_gray2 },
20 + [SchemeTabInactive] = { col_gray1, col_gray3, col_gray1 }
21 };
22
23 /* tagging */
24 @@ -37,6 +39,15 @@ static const int nmaster = 1; /* number of cli…
25 static const int resizehints = 1; /* 1 means respect size hints in t…
26 static const int lockfullscreen = 1; /* 1 will force focus on the fulls…
27
28 +/* Bartabgroups properties */
29 +#define BARTAB_BORDERS 1 // 0 = off, 1 = on
30 +#define BARTAB_BOTTOMBORDER 1 // 0 = off, 1 = on
31 +#define BARTAB_TAGSINDICATOR 1 // 0 = off, 1 = on if >1 client/view tag…
32 +#define BARTAB_TAGSPX 5 // # pixels for tag grid boxes
33 +#define BARTAB_TAGSROWS 3 // # rows in tag grid (9 tags, e.g. 3x3)
34 +static void (*bartabmonfns[])(Monitor *) = { monocle /* , customlayoutf…
35 +static void (*bartabfloatfns[])(Monitor *) = { NULL /* , customlayoutfn…
36 +
37 static const Layout layouts[] = {
38 /* symbol arrange function */
39 { "[]=", tile }, /* first entry is default */
40 diff --git a/dwm.c b/dwm.c
41 index 5e4d494..1839a56 100644
42 --- a/dwm.c
43 +++ b/dwm.c
44 @@ -59,7 +59,7 @@
45
46 /* enums */
47 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
48 -enum { SchemeNorm, SchemeSel }; /* color schemes */
49 +enum { SchemeNorm, SchemeSel, SchemeTabActive, SchemeTabInactive }; /* …
50 enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
51 NetWMFullscreen, NetActiveWindow, NetWMWindowType,
52 NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
53 @@ -378,6 +378,98 @@ applysizehints(Client *c, int *x, int *y, int *w, i…
54 return *x != c->x || *y != c->y || *w != c->w || *h != c->h;
55 }
56
57 +void
58 +bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupac…
59 + if (!c) return;
60 + int i, nclienttags = 0, nviewtags = 0;
61 +
62 + drw_setscheme(drw, scheme[
63 + m->sel == c ? SchemeSel : (groupactive ? SchemeTabActiv…
64 + ]);
65 + drw_text(drw, x, 0, w, bh, lrpad / 2, c->name, 0);
66 +
67 + // Floating win indicator
68 + if (c->isfloating) drw_rect(drw, x + 2, 2, 5, 5, 0, 0);
69 +
70 + // Optional borders between tabs
71 + if (BARTAB_BORDERS) {
72 + XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBorder…
73 + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, 0, …
74 + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w,…
75 + }
76 +
77 + // Optional tags icons
78 + for (i = 0; i < LENGTH(tags); i++) {
79 + if ((m->tagset[m->seltags] >> i) & 1) { nviewtags++; }
80 + if ((c->tags >> i) & 1) { nclienttags++; }
81 + }
82 + if (BARTAB_TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags >…
83 + for (i = 0; i < LENGTH(tags); i++) {
84 + drw_rect(drw,
85 + ( x + w - 2 - ((LENGTH(tags) / BARTAB_T…
86 + - (i % (LENGTH(tags)/BARTAB_TAG…
87 + ),
88 + ( 2 + ((i / (LENGTH(tags)/BARTAB_TAGSRO…
89 + - ((i / (LENGTH(tags)/BARTAB_TA…
90 + ),
91 + BARTAB_TAGSPX, BARTAB_TAGSPX, (c->tags …
92 + );
93 + }
94 + }
95 +}
96 +
97 +void
98 +battabclick(Monitor *m, Client *c, int passx, int x, int w, int unused)…
99 + if (passx >= x && passx <= x + w) {
100 + focus(c);
101 + restack(selmon);
102 + }
103 +}
104 +
105 +void
106 +bartabcalculate(
107 + Monitor *m, int offx, int sw, int passx,
108 + void(*tabfn)(Monitor *, Client *, int, int, int, int)
109 +) {
110 + Client *c;
111 + int
112 + i, clientsnmaster = 0, clientsnstack = 0, clientsnfloat…
113 + masteractive = 0, fulllayout = 0, floatlayout = 0,
114 + x, w, tgactive;
115 +
116 + for (i = 0, c = m->clients; c; c = c->next) {
117 + if (!ISVISIBLE(c)) continue;
118 + if (c->isfloating) { clientsnfloating++; continue; }
119 + if (m->sel == c) { masteractive = i < m->nmaster; }
120 + if (i < m->nmaster) { clientsnmaster++; } else { client…
121 + i++;
122 + }
123 + for (i = 0; i < LENGTH(bartabfloatfns); i++) if (m ->lt[m->sell…
124 + for (i = 0; i < LENGTH(bartabmonfns); i++) if (m ->lt[m->sellt]…
125 + for (c = m->clients, i = 0; c; c = c->next) {
126 + if (!ISVISIBLE(c)) continue;
127 + if (clientsnmaster + clientsnstack == 0 || floatlayout)…
128 + x = offx + (((m->mw - offx - sw) / (clientsnma…
129 + w = (m->mw - offx - sw) / (clientsnmaster + cl…
130 + tgactive = 1;
131 + } else if (!c->isfloating && (fulllayout || ((clientsnm…
132 + x = offx + (((m->mw - offx - sw) / (clientsnma…
133 + w = (m->mw - offx - sw) / (clientsnmaster + cl…
134 + tgactive = 1;
135 + } else if (i < m->nmaster && !c->isfloating) {
136 + x = offx + ((((m->mw * m->mfact) - offx) /clie…
137 + w = ((m->mw * m->mfact) - offx) / clientsnmast…
138 + tgactive = masteractive;
139 + } else if (!c->isfloating) {
140 + x = (m->mw * m->mfact) + ((((m->mw * (1 - m->m…
141 + w = ((m->mw * (1 - m->mfact)) - sw) / clientsn…
142 + tgactive = !masteractive;
143 + } else continue;
144 + tabfn(m, c, passx, x, w, tgactive);
145 + i++;
146 + }
147 +}
148 +
149 void
150 arrange(Monitor *m)
151 {
152 @@ -442,8 +534,8 @@ buttonpress(XEvent *e)
153 click = ClkLtSymbol;
154 else if (ev->x > selmon->ww - (int)TEXTW(stext))
155 click = ClkStatusText;
156 - else
157 - click = ClkWinTitle;
158 + else // Focus clicked tab bar item
159 + bartabcalculate(selmon, x, TEXTW(stext) - lrpad…
160 } else if ((c = wintoclient(ev->window))) {
161 focus(c);
162 restack(selmon);
163 @@ -729,15 +821,13 @@ drawbar(Monitor *m)
164 drw_setscheme(drw, scheme[SchemeNorm]);
165 x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
166
167 + // Draw bartabgroups
168 + drw_rect(drw, x, 0, m->ww - tw - x, bh, 1, 1);
169 if ((w = m->ww - tw - x) > bh) {
170 - if (m->sel) {
171 - drw_setscheme(drw, scheme[m == selmon ? SchemeS…
172 - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->n…
173 - if (m->sel->isfloating)
174 - drw_rect(drw, x + boxs, boxs, boxw, box…
175 - } else {
176 - drw_setscheme(drw, scheme[SchemeNorm]);
177 - drw_rect(drw, x, 0, w, bh, 1, 1);
178 + bartabcalculate(m, x, tw, -1, bartabdraw);
179 + if (BARTAB_BOTTOMBORDER) {
180 + drw_setscheme(drw, scheme[SchemeTabActive]);
181 + drw_rect(drw, 0, bh - 1, m->ww, 1, 1, 0);
182 }
183 }
184 drw_map(drw, m->barwin, 0, 0, m->ww, bh);
185 --
186 2.32.0
187
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.