awesomebar: removing wintitleactions functionality

pull/19/head
bakkeby 4 years ago
parent b6fa55ffdb
commit 8182bf8b04

@ -1,38 +1,35 @@
From 334739dbc87c1da12a00712adbd0528a64800d82 Mon Sep 17 00:00:00 2001
From 3fed487c5acb6494e224be916d59974de1edcf95 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Mon, 20 Jul 2020 09:50:33 +0200
Subject: [PATCH 2/2] Adding awesomebar
Subject: [PATCH 2/2] Adding awesomebar 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 wintitleactions
patch that allow clients to be focused, zoomed and hidden - functionality
that has been separated from the original awesomebar patch.
In other words, all this patch does is showing all window titles in the
title bar with an even split between them.
---
config.def.h | 7 +-
dwm.c | 21 ++---
patch/bar_awesomebar.c | 177 +++++++++++++++++++++++++++++++++++++++++
patch/bar_awesomebar.h | 9 +++
patch/include.c | 3 +-
patch/include.h | 3 +-
6 files changed, 208 insertions(+), 12 deletions(-)
config.def.h | 2 +-
patch/bar_awesomebar.c | 89 ++++++++++++++++++++++++++++++++++++++++++
patch/bar_awesomebar.h | 3 ++
patch/include.c | 3 +-
patch/include.h | 3 +-
5 files changed, 97 insertions(+), 3 deletions(-)
create mode 100644 patch/bar_awesomebar.c
create mode 100644 patch/bar_awesomebar.h
diff --git a/config.def.h b/config.def.h
index 2534eac..52d1030 100644
index 2534eac..1a64163 100644
--- a/config.def.h
+++ b/config.def.h
@@ -12,10 +12,13 @@ static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577";
+static const char col_hidfg[] = "#c278b6";
+static const char col_hidbg[] = "#222222";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
+ [SchemeHid] = { col_hidfg, col_hidbg, col_cyan },
};
/* tagging */
@@ -48,7 +51,7 @@ static const BarRule barrules[] = {
@@ -48,7 +48,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" },
@ -41,99 +38,12 @@ index 2534eac..52d1030 100644
};
/* layout(s) */
@@ -122,7 +125,9 @@ static Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
+ { ClkWinTitle, 0, Button1, togglewin, {0} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
+ { ClkWinTitle, 0, Button3, showhideclient, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
diff --git a/dwm.c b/dwm.c
index 03dccfb..6243f6f 100644
--- a/dwm.c
+++ b/dwm.c
@@ -51,6 +51,7 @@
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+#define HIDDEN(C) ((getstate(C->win) == IconicState))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
@@ -60,7 +61,7 @@
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
-enum { SchemeNorm, SchemeSel }; /* color schemes */
+enum { SchemeNorm, SchemeSel, SchemeHid }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@@ -523,7 +524,7 @@ 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)) {
- buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
+ buttons[i].func((click == ClkTagBar || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
}
}
}
@@ -995,16 +996,16 @@ focusstack(const Arg *arg)
if (!selmon->sel)
return;
if (arg->i > 0) {
- for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
+ for (c = selmon->sel->next; c && (!ISVISIBLE(c) || (arg->i == 1 && HIDDEN(c))); c = c->next);
if (!c)
- for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
+ for (c = selmon->clients; c && (!ISVISIBLE(c) || (arg->i == 1 && HIDDEN(c))); c = c->next);
} else {
for (i = selmon->clients; i != selmon->sel; i = i->next)
- if (ISVISIBLE(i))
+ if (ISVISIBLE(i) && !(arg->i == -1 && HIDDEN(i)))
c = i;
if (!c)
for (; i; i = i->next)
- if (ISVISIBLE(i))
+ if (ISVISIBLE(i) && !(arg->i == -1 && HIDDEN(i)))
c = i;
}
if (c) {
@@ -1225,12 +1226,14 @@ manage(Window w, XWindowAttributes *wa)
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
(unsigned char *) &(c->win), 1);
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
- setclientstate(c, NormalState);
+ if (!HIDDEN(c))
+ setclientstate(c, NormalState);
if (c->mon == selmon)
unfocus(selmon->sel, 0);
c->mon->sel = c;
arrange(c->mon);
- XMapWindow(dpy, c->win);
+ if (!HIDDEN(c))
+ XMapWindow(dpy, c->win);
focus(NULL);
}
@@ -1353,7 +1356,7 @@ movemouse(const Arg *arg)
Client *
nexttiled(Client *c)
{
- for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
+ for (; c && (c->isfloating || !ISVISIBLE(c) || HIDDEN(c)); c = c->next);
return c;
}
diff --git a/patch/bar_awesomebar.c b/patch/bar_awesomebar.c
new file mode 100644
index 0000000..75155fb
index 0000000..c5129e8
--- /dev/null
+++ b/patch/bar_awesomebar.c
@@ -0,0 +1,177 @@
@@ -0,0 +1,89 @@
+int
+width_awesomebar(Bar *bar, BarWidthArg *a)
+{
@ -174,8 +84,10 @@ index 0000000..75155fb
+ #else
+ scm = SchemeSel;
+ #endif // BAR_VTCOLORS_PATCH / BAR_TITLECOLOR_PATCH
+ #if BAR_WINTITLEACTIONS_PATCH
+ else if (HIDDEN(c))
+ scm = SchemeHid;
+ #endif // BAR_WINTITLEACTIONS_PATCH
+ else
+ #if BAR_VTCOLORS_PATCH
+ scm = SchemeTitleNorm;
@ -221,112 +133,16 @@ index 0000000..75155fb
+ }
+ 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);
+ }
+}
\ No newline at end of file
diff --git a/patch/bar_awesomebar.h b/patch/bar_awesomebar.h
new file mode 100644
index 0000000..83572f6
index 0000000..3269954
--- /dev/null
+++ b/patch/bar_awesomebar.h
@@ -0,0 +1,9 @@
@@ -0,0 +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);
\ No newline at end of file
diff --git a/patch/include.c b/patch/include.c
index d422f56..6ae83ed 100644

Loading…
Cancel
Save