Adding bartabgroups patch

pull/19/head
bakkeby 4 years ago
parent 963542bd76
commit 35e89d9308

@ -0,0 +1,301 @@
From 5c53d3a639a32b2ab3f9be04c06e14a1c4e95da1 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Thu, 13 Aug 2020 13:37:23 +0200
Subject: [PATCH 2/2] Adding bartabgrups barmodules patch.
Note that this patch does not come with bound ClkWinTitle button click
actions for extra behaviour when clicking on the window name in the bar.
The original bartabgroups patch included hardcoded focus on click which
has been replaced with a generic click for barmodules.
The intention here is that this is combined with the "hidden" patch that
allows clients to be focused and hidden - functionality that has been
separated from the awesomebar patch.
---
config.def.h | 5 +-
dwm.c | 2 +-
patch/bar_tabgroups.c | 170 ++++++++++++++++++++++++++++++++++++++++++
patch/bar_tabgroups.h | 21 ++++++
patch/include.c | 3 +-
patch/include.h | 3 +-
6 files changed, 200 insertions(+), 4 deletions(-)
create mode 100644 patch/bar_tabgroups.c
create mode 100644 patch/bar_tabgroups.h
diff --git a/config.def.h b/config.def.h
index 2534eac..6d332be 100644
--- a/config.def.h
+++ b/config.def.h
@@ -7,6 +7,7 @@ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=10" };
static const char dmenufont[] = "monospace:size=10";
+static void (*bartabmonfns[])(Monitor *) = { monocle /* , customlayoutfn */ };
static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
@@ -16,6 +17,8 @@ static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
+ [SchemeTabActive] = { col_gray2, col_gray3, col_gray2 },
+ [SchemeTabInactive] = { col_gray1, col_gray3, col_gray1 },
};
/* tagging */
@@ -48,7 +51,7 @@ static const BarRule barrules[] = {
{ -1, 0, BAR_ALIGN_LEFT, width_tags, draw_tags, click_tags, "tags" },
{ -1, 0, BAR_ALIGN_LEFT, width_ltsymbol, draw_ltsymbol, click_ltsymbol, "layout" },
{ 'A', 0, BAR_ALIGN_RIGHT, width_status, draw_status, click_status, "status" },
- { -1, 0, BAR_ALIGN_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" },
+ { -1, 0, BAR_ALIGN_NONE, width_bartabgroups, draw_bartabgroups, click_bartabgroups, "bartabgroups" },
};
/* layout(s) */
diff --git a/dwm.c b/dwm.c
index 9173ba9..98ea0c2 100644
--- a/dwm.c
+++ b/dwm.c
@@ -60,7 +60,7 @@
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
-enum { SchemeNorm, SchemeSel }; /* color schemes */
+enum { SchemeNorm, SchemeSel, SchemeTabActive, SchemeTabInactive }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
diff --git a/patch/bar_tabgroups.c b/patch/bar_tabgroups.c
new file mode 100644
index 0000000..151f8e4
--- /dev/null
+++ b/patch/bar_tabgroups.c
@@ -0,0 +1,170 @@
+int
+width_bartabgroups(Bar *bar, BarWidthArg *a)
+{
+ return a->max_width;
+}
+
+int
+draw_bartabgroups(Bar *bar, BarDrawArg *a)
+{
+ drw_rect(drw, a->x, 0, a->w, bh, 1, 1);
+ bartabcalculate(bar->mon, a->x, a->w, -1, bartabdraw, NULL);
+ return a->x + a->w;
+}
+
+int
+click_bartabgroups(Bar *bar, Arg *arg, BarClickArg *a)
+{
+ bartabcalculate(bar->mon, 0, a->rel_w, a->rel_x, bartabclick, arg);
+ return ClkWinTitle;
+}
+
+void
+bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg *arg)
+{
+ if (!c)
+ return;
+ int i, nclienttags = 0, nviewtags = 0;
+ drw_setscheme(drw, scheme[
+ m->sel == c
+ ? SchemeSel
+ #if BAR_HIDDEN_PATCH
+ : HIDDEN(c)
+ ? SchemeHid
+ #endif // BAR_HIDDEN_PATCH
+ : groupactive
+ ? SchemeTabActive
+ : SchemeTabInactive
+ ]);
+ drw_text(drw, x, 0, w, bh, lrpad / 2, c->name, 0);
+ if (c->isfloating)
+ drw_rect(drw, x + 2, 2, 5, 5, 0, 0);
+
+ if (BARTAB_BORDERS) {
+ XSetForeground(drw->dpy, drw->gc, scheme[SchemeSel][ColBorder].pixel);
+ XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, 0, 1, bh);
+ XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w, 0, 1, bh);
+ }
+ /* Optional tags icons */
+ for (i = 0; i < LENGTH(tags); i++) {
+ if ((m->tagset[m->seltags] >> i) & 1)
+ nviewtags++;
+ if ((c->tags >> i) & 1)
+ nclienttags++;
+ }
+
+ if (BARTAB_TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1) {
+ for (i = 0; i < LENGTH(tags); i++) {
+ drw_rect(drw,
+ ( x + w - 2 - ((LENGTH(tags) / BARTAB_TAGSROWS) * BARTAB_TAGSPX)
+ - (i % (LENGTH(tags)/BARTAB_TAGSROWS)) + ((i % (LENGTH(tags) / BARTAB_TAGSROWS)) * BARTAB_TAGSPX)
+ ),
+ ( 2 + ((i / (LENGTH(tags)/BARTAB_TAGSROWS)) * BARTAB_TAGSPX)
+ - ((i / (LENGTH(tags)/BARTAB_TAGSROWS)))
+ ),
+ BARTAB_TAGSPX, BARTAB_TAGSPX, (c->tags >> i) & 1, 0
+ );
+ }
+ }
+}
+
+void
+bartabclick(Monitor *m, Client *c, int passx, int x, int w, int unused, Arg *arg)
+{
+ if (passx >= x && passx <= x + w)
+ arg->v = c;
+}
+
+void
+bartabcalculate(
+ Monitor *m, int offx, int tabw, int passx,
+ void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg
+) {
+ Client *c;
+ int
+ i, clientsnmaster = 0, clientsnstack = 0, clientsnfloating = 0,
+ masteractive = 0, fulllayout = 0,
+ x = offx, w, r, num = 0, den, tgactive;
+
+ for (i = 0; i < LENGTH(bartabmonfns); i++)
+ if (m ->lt[m->sellt]->arrange == bartabmonfns[i]) {
+ fulllayout = 1;
+ break;
+ }
+
+ for (i = 0, c = m->clients; c; c = c->next) {
+ if (!ISVISIBLE(c))
+ continue;
+ if (c->isfloating) {
+ clientsnfloating++;
+ continue;
+ }
+ if (m->sel == c)
+ masteractive = i < m->nmaster;
+ if (i < m->nmaster)
+ clientsnmaster++;
+ else
+ clientsnstack++;
+ i++;
+ }
+
+ if (!i)
+ return;
+
+ /* floating mode */
+ if (clientsnmaster + clientsnstack == 0 || !m->lt[m->sellt]->arrange) {
+ tgactive = 1;
+ num = tabw;
+ den = clientsnmaster + clientsnstack + clientsnfloating;
+ r = num % den;
+ w = num / den;
+ for (c = m->clients, i = 0; c; c = c->next) {
+ if (!ISVISIBLE(c))
+ continue;
+ tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg);
+ x += w + (i < r ? 1 : 0);
+ i++;
+ }
+ /* monocle mode */
+ } else if (fulllayout || ((clientsnmaster == 0) ^ (clientsnstack == 0))) {
+ tgactive = 1;
+ num = tabw;
+ den = clientsnmaster + clientsnstack;
+ r = num % den;
+ w = num / den;
+ for (c = m->clients, i = 0; c; c = c->next) {
+ if (!ISVISIBLE(c) || c->isfloating)
+ continue;
+ tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg);
+ x += w + (i < r ? 1 : 0);
+ i++;
+ }
+ /* tiled mode */
+ } else {
+ tgactive = masteractive;
+ num = clientsnstack ? tabw * m->mfact : tabw;
+ den = clientsnmaster;
+ r = num % den;
+ w = num / den;
+ for (c = m->clients, i = 0; c && i < m->nmaster; c = c->next) {
+ if (!ISVISIBLE(c) || c->isfloating)
+ continue;
+ tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg);
+ x += w + (i < r ? 1 : 0);
+ i++;
+ }
+
+ tgactive = !tgactive;
+ num = tabw - num;
+ den = clientsnstack;
+ r = num % den;
+ w = num / den;
+ for (; c; c = c->next) {
+ if (!ISVISIBLE(c) || c->isfloating)
+ continue;
+ tabfn(m, c, passx, x, w + (i - m->nmaster < r ? 1 : 0), tgactive, arg);
+ x += w + (i - m->nmaster < r ? 1 : 0);
+ i++;
+ }
+ }
+}
\ No newline at end of file
diff --git a/patch/bar_tabgroups.h b/patch/bar_tabgroups.h
new file mode 100644
index 0000000..7cf1254
--- /dev/null
+++ b/patch/bar_tabgroups.h
@@ -0,0 +1,21 @@
+/* Bartabgroups properties, you can override these in your config.h if you want. */
+#ifndef BARTAB_BORDERS
+#define BARTAB_BORDERS 1 // 0 = off, 1 = on
+#endif
+#ifndef BARTAB_TAGSINDICATOR
+#define BARTAB_TAGSINDICATOR 1 // 0 = off, 1 = on if >1 client/view tag, 2 = always on
+#endif
+#ifndef BARTAB_TAGSPX
+#define BARTAB_TAGSPX 5 // # pixels for tag grid boxes
+#endif
+#ifndef BARTAB_TAGSROWS
+#define BARTAB_TAGSROWS 3 // # rows in tag grid (9 tags, e.g. 3x3)
+#endif
+
+static int width_bartabgroups(Bar *bar, BarWidthArg *a);
+static int draw_bartabgroups(Bar *bar, BarDrawArg *a);
+static int click_bartabgroups(Bar *bar, Arg *arg, BarClickArg *a);
+
+static void bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg *arg);
+static void bartabclick(Monitor *m, Client *c, int passx, int x, int w, int unused, Arg *arg);
+static void bartabcalculate(Monitor *m, int offx, int w, int passx, void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg);
\ No newline at end of file
diff --git a/patch/include.c b/patch/include.c
index d422f56..a1885ed 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -2,4 +2,5 @@
#include "bar_ltsymbol.c"
#include "bar_status.c"
#include "bar_tags.c"
-#include "bar_wintitle.c"
\ No newline at end of file
+// #include "bar_wintitle.c"
+#include "bar_tabgroups.c"
\ No newline at end of file
diff --git a/patch/include.h b/patch/include.h
index 5f9a3fe..a024a16 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -2,4 +2,5 @@
#include "bar_ltsymbol.h"
#include "bar_status.h"
#include "bar_tags.h"
-#include "bar_wintitle.h"
\ No newline at end of file
+// #include "bar_wintitle.h"
+#include "bar_tabgroups.h"
\ No newline at end of file
--
2.19.1
Loading…
Cancel
Save