Adding bartabgroups patch

This commit is contained in:
bakkeby 2020-08-13 15:42:49 +02:00
parent 57e727b498
commit de47bd8839
12 changed files with 439 additions and 165 deletions

View File

@ -15,7 +15,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2020-08-11 - Added decoration hints patch
2020-08-13 - Added bartabgroups patch
2020-08-11 - Added decoration hints and focusmaster patches
2020-08-10 - Added cool autostart, insets and steam patches
@ -187,6 +189,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [barpadding](https://dwm.suckless.org/patches/barpadding/)
- adds vertical and horizontal space between the statusbar and the edge of the screen
- [bartabgroups](https://dwm.suckless.org/patches/bartabgroups/)
- turns the titlebar area into a mfact-respecting tab-bar showing each client's title
- [center](https://dwm.suckless.org/patches/center/)
- adds an iscentered rule to automatically center clients on the current monitor

View File

@ -58,6 +58,9 @@ static const int quit_empty_window_count = 2; /* only allow dwm to quit if no
#if BAR_EXTRASTATUS_PATCH
static const char statussep = ';'; /* separator between status bars */
#endif // BAR_EXTRASTATUS_PATCH
#if BAR_TABGROUPS_PATCH
static void (*bartabmonfns[])(Monitor *) = { monocle /* , customlayoutfn */ };
#endif // BAR_TABGROUPS_PATCH
#if BAR_PANGO_PATCH
static const char font[] = "monospace 10";
#else
@ -100,14 +103,14 @@ static char urgfloatcolor[] = "#000000";
#endif // FLOAT_BORDER_COLOR_PATCH
#endif // URGENTBORDER_PATCH // BAR_STATUSCOLORS_PATCH
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
static char hidfgcolor[] = "#005577";
static char hidbgcolor[] = "#222222";
static char hidbordercolor[] = "#005577";
#if FLOAT_BORDER_COLOR_PATCH
static char hidfloatcolor[] = "#f76e0c";
#endif // FLOAT_BORDER_COLOR_PATCH
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
#endif // BAR_VTCOLORS_PATCH
#if BAR_POWERLINE_STATUS_PATCH || (BAR_TITLECOLOR_PATCH && !BAR_VTCOLORS_PATCH)
@ -125,6 +128,19 @@ static char titleselfloatcolor[] = "#FF0000";
#endif // FLOAT_BORDER_COLOR_PATCH
#endif // BAR_POWERLINE_STATUS_PATCH | BAR_TITLECOLOR_PATCH
#if BAR_TABGROUPS_PATCH
static char tabgrpactivefgcolor[] = "#FFF7D4";
static char tabgrpactivebgcolor[] = "#444444";
static char tabgrpactivebordercolor[] = "#330000";
static char tabgrpinactivefgcolor[] = "#bbbbbb";
static char tabgrpinactivebgcolor[] = "#222222";
static char tabgrpinactivebordercolor[] = "#991100";
#if FLOAT_BORDER_COLOR_PATCH
static char tabgrpactivefloatcolor[] = "#000000";
static char tabgrpinactivefloatcolor[] = "#000000";
#endif // FLOAT_BORDER_COLOR_PATCH
#endif // BAR_TABGROUPS_PATCH
#if BAR_ALPHA_PATCH
static const unsigned int baralpha = 0xd0;
static const unsigned int borderalpha = OPAQUE;
@ -138,9 +154,9 @@ static const unsigned int alphas[][3] = {
#if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
[SchemeUrg] = { OPAQUE, baralpha, borderalpha },
#endif // URGENTBORDER_PATCH / BAR_STATUSCOLORS_PATCH
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
[SchemeHid] = { OPAQUE, baralpha, borderalpha },
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
#if BAR_VTCOLORS_PATCH
[SchemeTagsNorm] = { OPAQUE, baralpha, borderalpha },
[SchemeTagsSel] = { OPAQUE, baralpha, borderalpha },
@ -150,6 +166,10 @@ static const unsigned int alphas[][3] = {
#elif BAR_TITLECOLOR_PATCH
[SchemeTitle] = { OPAQUE, baralpha, borderalpha },
#endif // BAR_VTCOLORS_PATCH / BAR_TITLECOLOR_PATCH
#if BAR_TABGROUPS_PATCH
[SchemeTabActive] = { OPAQUE, baralpha, borderalpha },
[SchemeTabInactive] = { OPAQUE, baralpha, borderalpha },
#endif // BAR_TABGROUPS_PATCH
};
#endif // BAR_ALPHA_PATCH
#if BAR_VTCOLORS_PATCH && FLOAT_BORDER_COLOR_PATCH
@ -165,9 +185,13 @@ static const int color_ptrs[][ColCount] = {
#if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
[SchemeUrg] = { 7, 9, 9, 15 },
#endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
[SchemeHid] = { 5, 0, 0, -1 },
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
#if BAR_TABGROUPS_PATCH
[SchemeTabActive] = { 6, 5, 5, -1 },
[SchemeTabInactive] = { 2, 0, 0, -1 },
#endif // BAR_TABGROUPS_PATCH
[SchemeTagsNorm] = { 2, 0, 0, -1 },
[SchemeTagsSel] = { 6, 5, 5, -1 },
[SchemeTitleNorm] = { 6, -1, -1, -1 },
@ -184,9 +208,13 @@ static char colors[][ColCount][8] = {
#if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
[SchemeUrg] = { "#000000", "#000000", "#000000", "#000000" },
#endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
[SchemeHid] = { "#000000", "#000000", "#000000", "#000000" },
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
#if BAR_TABGROUPS_PATCH
[SchemeTabActive] = { "#000000", "#000000", "#000000", "#000000" },
[SchemeTabInactive] = { "#000000", "#000000", "#000000", "#000000" },
#endif // BAR_TABGROUPS_PATCH
[SchemeTagsNorm] = { "#000000", "#000000", "#000000", "#000000" },
[SchemeTagsSel] = { "#000000", "#000000", "#000000", "#000000" },
[SchemeTitleNorm] = { "#000000", "#000000", "#000000", "#000000" },
@ -206,9 +234,13 @@ static const int color_ptrs[][ColCount] = {
#if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
[SchemeUrg] = { 7, 9, 9 },
#endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
[SchemeHid] = { 5, 0, 0 },
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
#if BAR_TABGROUPS_PATCH
[SchemeTabActive] = { 6, 5, 5 },
[SchemeTabInactive] = { 2, 0, 0 },
#endif // BAR_TABGROUPS_PATCH
[SchemeTagsNorm] = { 2, 0, 0 },
[SchemeTagsSel] = { 6, 5, 5 },
[SchemeTitleNorm] = { 6, -1, -1 },
@ -225,9 +257,13 @@ static char colors[][ColCount][8] = {
#if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
[SchemeUrg] = { "#000000", "#000000", "#000000" },
#endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
[SchemeHid] = { "#000000", "#000000", "#000000" },
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
#if BAR_TABGROUPS_PATCH
[SchemeTabActive] = { "#000000", "#000000", "#000000" },
[SchemeTabInactive] = { "#000000", "#000000", "#000000" },
#endif // BAR_TABGROUPS_PATCH
[SchemeTagsNorm] = { "#000000", "#000000", "#000000" },
[SchemeTagsSel] = { "#000000", "#000000", "#000000" },
[SchemeTitleNorm] = { "#000000", "#000000", "#000000" },
@ -249,12 +285,16 @@ char *colors[][ColCount] = {
#if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
[SchemeUrg] = { urgfgcolor, urgbgcolor, urgbordercolor, urgfloatcolor },
#endif // URGENTBORDER_PATCH / BAR_STATUSCOLORS_PATCH
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
[SchemeHid] = { hidfgcolor, hidbgcolor, hidbordercolor, hidfloatcolor },
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
#if BAR_TITLECOLOR_PATCH
[SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor, titlefloatcolor },
#endif // BAR_TITLECOLOR_PATCH
#if BAR_TABGROUPS_PATCH
[SchemeTabActive] = { tabgrpactivefgcolor, tabgrpactivebgcolor, tabgrpactivebordercolor, tabgrpactivefloatcolor },
[SchemeTabInactive] = { tabgrpinactivefgcolor, tabgrpinactivebgcolor, tabgrpinactivebordercolor, tabgrpinactivefloatcolor },
#endif // BAR_TABGROUPS_PATCH
};
#else // !BAR_VTCOLORS_PATCH && !FLOAT_BORDER_COLOR_PATCH
static
@ -271,12 +311,16 @@ char *colors[][ColCount] = {
#if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
[SchemeUrg] = { urgfgcolor, urgbgcolor, urgbordercolor },
#endif // URGENTBORDER_PATCH / BAR_STATUSCOLORS_PATCH
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
[SchemeHid] = { hidfgcolor, hidbgcolor, hidbordercolor },
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
#if BAR_TITLECOLOR_PATCH
[SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor },
#endif // BAR_TITLECOLOR_PATCH
#if BAR_TABGROUPS_PATCH
[SchemeTabActive] = { tabgrpactivefgcolor, tabgrpactivebgcolor, tabgrpactivebordercolor },
[SchemeTabInactive] = { tabgrpinactivefgcolor, tabgrpinactivebgcolor, tabgrpinactivebordercolor },
#endif // BAR_TABGROUPS_PATCH
};
#endif // BAR_VTCOLORS_PATCH / FLOAT_BORDER_COLOR_PATCH
@ -453,13 +497,15 @@ static const BarRule barrules[] = {
#elif BAR_STATUS_PATCH
{ 'A', 0, BAR_ALIGN_RIGHT, width_status, draw_status, click_status, "status" },
#endif // BAR_STATUS2D_PATCH | BAR_STATUSCMD_PATCH
#if BAR_AWESOMEBAR_PATCH
#if BAR_TABGROUPS_PATCH
{ -1, 0, BAR_ALIGN_NONE, width_bartabgroups, draw_bartabgroups, click_bartabgroups, "bartabgroups" },
#elif BAR_AWESOMEBAR_PATCH
{ -1, 0, BAR_ALIGN_NONE, width_awesomebar, draw_awesomebar, click_awesomebar, "awesomebar" },
#elif BAR_FANCYBAR_PATCH
{ -1, 0, BAR_ALIGN_NONE, width_fancybar, draw_fancybar, click_fancybar, "fancybar" },
#elif BAR_WINTITLE_PATCH
{ -1, 0, BAR_ALIGN_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" },
#endif // BAR_AWESOMEBAR_PATCH | BAR_FANCYBAR_PATCH BAR_WINTITLE_PATCH
#endif // BAR_TABGROUPS_PATCH | BAR_AWESOMEBAR_PATCH | BAR_FANCYBAR_PATCH | BAR_WINTITLE_PATCH
#if BAR_EXTRASTATUS_PATCH
#if BAR_STATUS2D_PATCH && BAR_STATUSCMD_PATCH
{ 'A', 1, BAR_ALIGN_CENTER, width_status2d_es, draw_status2d_es, click_statuscmd_es, "status2d_es" },
@ -990,9 +1036,9 @@ static Key keys[] = {
{ MODKEY|Mod4Mask, XK_Tab, shiftviewclients, { .i = -1 } },
{ MODKEY|Mod4Mask, XK_backslash, shiftviewclients, { .i = +1 } },
#endif // SHIFTVIEW_CLIENTS_PATCH
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
{ MODKEY|ControlMask, XK_z, showhideclient, {0} },
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
#if KILLUNSEL_PATCH
{ MODKEY|ShiftMask, XK_x, killunsel, {0} },
@ -1269,10 +1315,10 @@ static Button buttons[] = {
#endif // BAR_STATUSBUTTON_PATCH
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
{ ClkWinTitle, 0, Button1, togglewin, {0} },
{ ClkWinTitle, 0, Button3, showhideclient, {0} },
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
{ ClkWinTitle, 0, Button2, zoom, {0} },
#if BAR_STATUSCMD_PATCH && BAR_DWMBLOCKS_PATCH
{ ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1 } },

59
dwm.c
View File

@ -73,9 +73,6 @@
#else
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
#endif // ATTACHASIDE_PATCH
#if BAR_AWESOMEBAR_PATCH
#define HIDDEN(C) ((getstate(C->win) == IconicState))
#endif // BAR_AWESOMEBAR_PATCH
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
@ -118,29 +115,33 @@ enum {
}; /* cursor */
enum {
SchemeNorm
,SchemeSel
SchemeNorm,
SchemeSel,
#if BAR_STATUSCOLORS_PATCH
,SchemeWarn
SchemeWarn,
#endif // BAR_STATUSCOLORS_PATCH
#if URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
,SchemeUrg
SchemeUrg,
#endif // URGENTBORDER_PATCH || BAR_STATUSCOLORS_PATCH
#if BAR_AWESOMEBAR_PATCH
,SchemeHid
#endif // BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
SchemeHid,
#endif // BAR_WINTITLEACTIONS_PATCH
#if BAR_VTCOLORS_PATCH
,SchemeTagsNorm
,SchemeTagsSel
,SchemeStatus
SchemeTagsNorm,
SchemeTagsSel,
SchemeStatus,
#endif
#if BAR_VTCOLORS_PATCH || BAR_POWERLINE_STATUS_PATCH
,SchemeTitleNorm
,SchemeTitleSel
SchemeTitleNorm,
SchemeTitleSel,
#endif // BAR_POWERLINE_STATUS_PATCH
#if BAR_TITLECOLOR_PATCH
,SchemeTitle
SchemeTitle,
#endif // BAR_VTCOLORS_PATCH
#if BAR_TABGROUPS_PATCH
SchemeTabActive,
SchemeTabInactive,
#endif // BAR_TABGROUPS_PATCH
}; /* color schemes */
enum {
@ -955,11 +956,11 @@ buttonpress(XEvent *e)
for (i = 0; i < LENGTH(buttons); i++) {
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) {
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
buttons[i].func((click == ClkTagBar || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
#else
buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
#endif
#endif // BAR_WINTITLEACTIONS_PATCH
}
}
}
@ -1708,7 +1709,7 @@ focusstack(const Arg *arg)
if (selmon->sel->isfullscreen)
return;
#endif // ALWAYSFULLSCREEN_PATCH
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
if (arg->i > 0) {
for (c = selmon->sel->next; c && (!ISVISIBLE(c) || (arg->i == 1 && HIDDEN(c))); c = c->next);
if (!c)
@ -1736,7 +1737,7 @@ focusstack(const Arg *arg)
if (ISVISIBLE(i))
c = i;
}
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
if (c) {
focus(c);
restack(selmon);
@ -2076,22 +2077,22 @@ manage(Window w, XWindowAttributes *wa)
(unsigned char *) &(c->win), 1);
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
if (!HIDDEN(c))
setclientstate(c, NormalState);
#else
setclientstate(c, NormalState);
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
if (c->mon == selmon)
unfocus(selmon->sel, 0);
c->mon->sel = c;
arrange(c->mon);
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
if (!HIDDEN(c))
XMapWindow(dpy, c->win);
#else
XMapWindow(dpy, c->win);
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
#if SWALLOW_PATCH
if (term)
swallow(term, c);
@ -2234,11 +2235,11 @@ movemouse(const Arg *arg)
Client *
nexttiled(Client *c)
{
#if BAR_AWESOMEBAR_PATCH
#if BAR_WINTITLEACTIONS_PATCH
for (; c && (c->isfloating || !ISVISIBLE(c) || HIDDEN(c)); c = c->next);
#else
for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
#endif // BAR_AWESOMEBAR_PATCH
#endif // BAR_WINTITLEACTIONS_PATCH
return c;
}
@ -3953,7 +3954,13 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
void
zoom(const Arg *arg)
{
#if BAR_WINTITLEACTIONS_PATCH
Client *c = (Client*)arg->v;
if (!c)
c = selmon->sel;
#else
Client *c = selmon->sel;
#endif // BAR_WINTITLEACTIONS_PATCH
#if ZOOMSWAP_PATCH
Client *at = NULL, *cold, *cprevious = NULL, *p;
#endif // ZOOMSWAP_PATCH

View File

@ -48,13 +48,12 @@ draw_awesomebar(Bar *bar, BarDrawArg *a)
#endif // BAR_VTCOLORS_PATCH
drw_setscheme(drw, scheme[scm]);
tabw += (i < remainder ? 1 : 0);
#if BAR_PANGO_PATCH
drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0, False);
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0, False);
#else
drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0);
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0);
#endif // BAR_PANGO_PATCH
x += tabw;
x += tabw + (i < remainder ? 1 : 0);
}
}
return a->x + a->w;
@ -85,93 +84,3 @@ click_awesomebar(Bar *bar, Arg *arg, BarClickArg *a)
}
return -1;
}
void
hide(Client *c) {
Client *n;
if (!c || HIDDEN(c))
return;
Window w = c->win;
static XWindowAttributes ra, ca;
// more or less taken directly from blackbox's hide() function
XGrabServer(dpy);
XGetWindowAttributes(dpy, root, &ra);
XGetWindowAttributes(dpy, w, &ca);
// prevent UnmapNotify events
XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask);
XUnmapWindow(dpy, w);
setclientstate(c, IconicState);
XSelectInput(dpy, root, ra.your_event_mask);
XSelectInput(dpy, w, ca.your_event_mask);
XUngrabServer(dpy);
if (c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) {
for (n = c->snext; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext);
if (!n)
for (n = c->mon->stack; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext);
} else {
n = nexttiled(c);
if (!n)
n = prevtiled(c);
}
focus(n);
arrange(c->mon);
}
void
show(Client *c)
{
if (!c || !HIDDEN(c))
return;
XMapWindow(dpy, c->win);
setclientstate(c, NormalState);
arrange(c->mon);
}
void
togglewin(const Arg *arg)
{
Client *c = (Client*)arg->v;
if (!c)
return;
if (c == selmon->sel)
hide(c);
else {
if (HIDDEN(c))
show(c);
focus(c);
restack(selmon);
}
}
Client *
prevtiled(Client *c)
{
Client *p, *i;
for (p = NULL, i = c->mon->clients; c && i != c; i = i->next)
if (ISVISIBLE(i) && !HIDDEN(i))
p = i;
return p;
}
void
showhideclient(const Arg *arg)
{
Client *c = (Client*)arg->v;
if (!c)
c = selmon->sel;
if (!c)
return;
if (HIDDEN(c)) {
show(c);
restack(selmon);
} else {
hide(c);
}
}

View File

@ -1,9 +1,3 @@
static int width_awesomebar(Bar *bar, BarWidthArg *a);
static int draw_awesomebar(Bar *bar, BarDrawArg *a);
static int click_awesomebar(Bar *bar, Arg *arg, BarClickArg *a);
static void hide(Client *c);
static void show(Client *c);
static void togglewin(const Arg *arg);
static Client *prevtiled(Client *c);
static void showhideclient(const Arg *arg);

170
patch/bar_tabgroups.c Normal file
View File

@ -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_WINTITLEACTIONS_PATCH
: HIDDEN(c)
? SchemeHid
#endif // BAR_WINTITLEACTIONS_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++;
}
}
}

21
patch/bar_tabgroups.h Normal file
View File

@ -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);

View File

@ -0,0 +1,89 @@
void
hide(Client *c) {
Client *n;
if (!c || HIDDEN(c))
return;
Window w = c->win;
static XWindowAttributes ra, ca;
// more or less taken directly from blackbox's hide() function
XGrabServer(dpy);
XGetWindowAttributes(dpy, root, &ra);
XGetWindowAttributes(dpy, w, &ca);
// prevent UnmapNotify events
XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask);
XUnmapWindow(dpy, w);
setclientstate(c, IconicState);
XSelectInput(dpy, root, ra.your_event_mask);
XSelectInput(dpy, w, ca.your_event_mask);
XUngrabServer(dpy);
if (c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) {
for (n = c->snext; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext);
if (!n)
for (n = c->mon->stack; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext);
} else {
n = nexttiled(c);
if (!n)
n = prevtiled(c);
}
focus(n);
arrange(c->mon);
}
void
show(Client *c)
{
if (!c || !HIDDEN(c))
return;
XMapWindow(dpy, c->win);
setclientstate(c, NormalState);
arrange(c->mon);
}
void
togglewin(const Arg *arg)
{
Client *c = (Client*)arg->v;
if (!c)
return;
if (c == selmon->sel)
hide(c);
else {
if (HIDDEN(c))
show(c);
focus(c);
restack(selmon);
}
}
Client *
prevtiled(Client *c)
{
Client *p, *i;
for (p = NULL, i = c->mon->clients; c && i != c; i = i->next)
if (ISVISIBLE(i) && !HIDDEN(i))
p = i;
return p;
}
void
showhideclient(const Arg *arg)
{
Client *c = (Client*)arg->v;
if (!c)
c = selmon->sel;
if (!c)
return;
if (HIDDEN(c)) {
show(c);
restack(selmon);
} else {
hide(c);
}
}

View File

@ -0,0 +1,7 @@
#define HIDDEN(C) ((getstate(C->win) == IconicState))
static void hide(Client *c);
static void show(Client *c);
static void togglewin(const Arg *arg);
static Client * prevtiled(Client *c);
static void showhideclient(const Arg *arg);

View File

@ -41,6 +41,9 @@
#if BAR_STATUSCOLORS_PATCH
#include "bar_statuscolors.c"
#endif
#if BAR_TABGROUPS_PATCH
#include "bar_tabgroups.c"
#endif
#if BAR_TAGS_PATCH
#include "bar_tags.c"
#endif
@ -62,6 +65,9 @@
#if BAR_VTCOLORS_PATCH
#include "bar_vtcolors.c"
#endif
#if BAR_WINTITLEACTIONS_PATCH
#include "bar_wintitleactions.c"
#endif
/* Other patches */
#if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH

View File

@ -38,6 +38,9 @@
#if BAR_STATUSCMD_PATCH
#include "bar_statuscmd.h"
#endif
#if BAR_TABGROUPS_PATCH
#include "bar_tabgroups.h"
#endif
#if BAR_TAGS_PATCH
#include "bar_tags.h"
#endif
@ -59,6 +62,9 @@
#if BAR_VTCOLORS_PATCH
#include "bar_vtcolors.h"
#endif
#if BAR_WINTITLEACTIONS_PATCH
#include "bar_wintitleactions.h"
#endif
/* Other patches */
#if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH

View File

@ -64,6 +64,11 @@
/* Alters the tags powerline to use forward slash instead of arrows */
#define BAR_POWERLINE_TAGS_SLASH_PATCH 0
/* This patch turns the titlebar area into a mfact-respecting tabbar showing each client's title.
* https://dwm.suckless.org/patches/bartabgroups/
*/
#define BAR_TABGROUPS_PATCH 0
/* This patch adds an option to place tags in rows like in many other window managers.
* https://dwm.suckless.org/patches/taggrid/
*/
@ -248,6 +253,15 @@
*/
#define BAR_VTCOLORS_PATCH 0
/* This patch allows client windows to be hidden. This code was originally part of awesomebar,
* but has been separated out so that other bar modules can take advantage of it.
* Both awesomebar and bartabgroups patches depend on this patch and it will be auto-enabled
* during compile time if it is needed. Note that if using flexipatch-finalizer this must be
* explicitly enabled.
* https://github.com/bakkeby/patches/blob/master/dwm/dwm-barmodules-wintitleactions-6.2.diff
*/
#define BAR_WINTITLEACTIONS_PATCH BAR_AWESOMEBAR_PATCH || BAR_TABGROUPS_PATCH
/***
* Other patches
*/