Compare commits

..

No commits in common. "master" and "underline" have entirely different histories.

8 changed files with 250 additions and 187 deletions

View File

@ -107,7 +107,6 @@ static const Layout layouts[] = {
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
{ "[D]", deck },
};
/* key definitions */
@ -152,7 +151,6 @@ static const Key keys[] = {
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_r, setlayout, {.v = &layouts[3]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY|ShiftMask, XK_t, togglealwaysontop, {0} },

144
dwm.c
View File

@ -187,7 +187,6 @@ static void configure(Client *c);
static void configurenotify(XEvent *e);
static void configurerequest(XEvent *e);
static Monitor *createmon(void);
static void deck(Monitor *m);
static void destroynotify(XEvent *e);
static void detach(Client *c);
static void detachstack(Client *c);
@ -282,6 +281,9 @@ static void updatetitle(Client *c);
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
static void window_set_state(Display *dpy, Window win, long state);
static void window_map(Display *dpy, Client *c, int deiconify);
static void window_unmap(Display *dpy, Window win, Window root, int iconify);
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
static int xerror(Display *dpy, XErrorEvent *ee);
@ -607,9 +609,15 @@ buttonpress(XEvent *e)
}
if (ev->window == selmon->barwin) {
i = x = 0;
do
unsigned int occ = 0;
for(c = m->clients; c; c=c->next)
occ |= c->tags == TAGMASK ? 0 : c->tags;
do {
/* Do not reserve space for vacant tags */
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
x += TEXTW(tags[i]);
while (ev->x >= x && ++i < LENGTH(tags));
} while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
@ -886,33 +894,6 @@ destroynotify(XEvent *e)
unmanage(c->swallowing, 1);
}
void
deck(Monitor *m) {
unsigned int i, n, h, mw, my, ns;
Client *c;
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if(n == 0)
return;
if(n > m->nmaster) {
mw = m->nmaster ? m->ww * m->mfact : 0;
ns = m->nmaster > 0 ? 2 : 1;
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
} else {
mw = m->ww;
ns = 1;
}
for(i = 0, my = gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if(i < m->nmaster) {
h = (m->wh - my) / (MIN(n, m->nmaster) - i) - gappx;
resize(c, m->wx + gappx, m->wy + my, mw - (2*c->bw) - gappx*(5-ns)/2, h - (2*c->bw), False);
my += HEIGHT(c) + gappx;
}
else
resize(c, m->wx + mw + gappx/ns, m->wy + gappx, m->ww - mw - (2*c->bw) - gappx*(5-ns)/2, m->wh - (2*c->bw) - 2*gappx, False);
}
void
detach(Client *c)
{
@ -972,19 +953,30 @@ drawbar(Monitor *m)
for (c = m->clients; c; c = c->next) {
if (ISVISIBLE(c))
n++;
occ |= c->tags;
occ |= c->tags == TAGMASK ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
/* Do not draw vacant tags */
if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
w = TEXTW(tags[i]);
drw_setscheme(drw, (m->tagset[m->seltags] & 1 << i ? tagscheme[i] : scheme[SchemeNorm]));
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
if (occ & 1 << i)
drw_rect(drw, x + boxs, boxs, boxw, boxw,
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
urg & 1 << i);
if (ulineall || m->tagset[m->seltags] & 1 << i) { /* if there are conflicts, just move these lines directly underneath both 'drw_setscheme' and 'drw_text' :) */
if (m == selmon)
drw_setscheme(drw, scheme[SchemeHid]);
drw_rect(drw, x + w * 0.0675, bh - ulinestroke - ulinevoffset, w * 0.875, ulinestroke, 1, 0);
} else if (occ & 1 << i) {
drw_setscheme(drw, scheme[SchemeNorm]);
if (urg)
drw_rect(drw, x + boxs, boxs, boxw, boxw, m == selmon && selmon->sel && selmon->sel->tags & 1 << i, 1);
else
drw_rect(drw, x + w * 0.375, bh - ulinestroke - ulinevoffset, w * 0.25, ulinestroke, 1, 0);
}
x += w;
}
w = TEXTW(m->ltsymbol);
@ -1002,13 +994,11 @@ drawbar(Monitor *m)
for (c = m->clients; c; c = c->next) {
if (!ISVISIBLE(c))
continue;
if (m->sel == c && m == selmon)
drw_setscheme(drw, scheme[SchemeSel]);
else if (HIDDEN(c))
drw_setscheme(drw, scheme[SchemeHid]);
if (HIDDEN(c))
scm = SchemeHid;
else
drw_setscheme(drw, scheme[SchemeNorm]);
scm = SchemeNorm;
drw_setscheme(drw, scheme[scm]);
if (remainder >= 0) {
if (remainder == 0) {
@ -1024,11 +1014,20 @@ drawbar(Monitor *m)
else
snprintf(name, sizeof name, c->name);
mid = ((tabw - (int)TEXTW(name)) / 2) + lrpad / 2;
if ( tabw < (int)TEXTW(name) + lrpad )
mid = lrpad / 2;
mid = (tabw - (int)TEXTW(name)) / 2;
mid = mid >= lrpad / 2 ? mid : lrpad / 2;
drw_text(drw, x, 0, tabw - 2 * sp, bh, mid, name, 0);
if (!HIDDEN(c)) {
if (m->sel == c) {
if (m == selmon)
drw_setscheme(drw, scheme[SchemeHid]);
drw_rect(drw, x + tabw * 0.0675, bh - ulinestroke - ulinevoffset, tabw * 0.875 - ulinepad * 2, ulinestroke, 1, 0);
} else {
drw_rect(drw, x + tabw * 0.375, bh - ulinestroke - ulinevoffset, tabw * 0.25 - ulinepad * 2, ulinestroke, 1, 0);
}
}
drw_text(drw, x, 0, tabw, bh, mid, name, 0);
x += tabw;
}
} else {
@ -1861,8 +1860,6 @@ nexttiled(Client *c)
void
movestack(const Arg *arg) {
Client *c = NULL, *p = NULL, *pc = NULL, *i;
if (!selmon->sel)
return;
if(arg->i > 0) {
/* find the client after selmon->sel */
@ -2602,14 +2599,12 @@ showhide(Client *c)
return;
if (ISVISIBLE(c)) {
/* show clients top down */
XMoveWindow(dpy, c->win, c->x, c->y);
if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
resize(c, c->x, c->y, c->w, c->h, 0);
window_map(dpy, c, 1);
showhide(c->snext);
} else {
/* hide clients bottom up */
showhide(c->snext);
XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
window_unmap(dpy, c->win, root, 1);
}
}
@ -2869,7 +2864,7 @@ togglewin(const Arg *arg)
showwin(c);
focus(c);
restack(selmon);
/* XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2); */
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
}
}
@ -3210,6 +3205,51 @@ updatewmhints(Client *c)
}
}
void
window_set_state(Display *dpy, Window win, long state)
{
long data[] = { state, None };
XChangeProperty(dpy, win, wmatom[WMState], wmatom[WMState], 32,
PropModeReplace, (unsigned char*)data, 2);
}
void
window_map(Display *dpy, Client *c, int deiconify)
{
Window win = c->win;
if (deiconify)
window_set_state(dpy, win, NormalState);
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
XMapWindow(dpy, win);
}
void
window_unmap(Display *dpy, Window win, Window root, int iconify)
{
static XWindowAttributes ca, ra;
XGrabServer(dpy);
XGetWindowAttributes(dpy, root, &ra);
XGetWindowAttributes(dpy, win, &ca);
/* Prevent UnmapNotify events */
XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
XSelectInput(dpy, win, ca.your_event_mask & ~StructureNotifyMask);
XUnmapWindow(dpy, win);
if (iconify)
window_set_state(dpy, win, IconicState);
XSelectInput(dpy, root, ra.your_event_mask);
XSelectInput(dpy, win, ca.your_event_mask);
XUngrabServer(dpy);
}
void
view(const Arg *arg)
{

View File

@ -0,0 +1,48 @@
:100644 100644 f1d86b2 0000000 M dwm.c
diff --git a/dwm.c b/dwm.c
index f1d86b2..d41cc14 100644
--- a/dwm.c
+++ b/dwm.c
@@ -433,9 +433,15 @@ buttonpress(XEvent *e)
}
if (ev->window == selmon->barwin) {
i = x = 0;
- do
+ unsigned int occ = 0;
+ for(c = m->clients; c; c=c->next)
+ occ |= c->tags == TAGMASK ? 0 : c->tags;
+ do {
+ /* Do not reserve space for vacant tags */
+ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
x += TEXTW(tags[i]);
- while (ev->x >= x && ++i < LENGTH(tags));
+ } while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
@@ -715,19 +721,18 @@ drawbar(Monitor *m)
}
for (c = m->clients; c; c = c->next) {
- occ |= c->tags;
+ occ |= c->tags == TAGMASK ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
+ /* Do not draw vacant tags */
+ if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
w = TEXTW(tags[i]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
- if (occ & 1 << i)
- drw_rect(drw, x + boxs, boxs, boxw, boxw,
- m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
- urg & 1 << i);
x += w;
}
w = TEXTW(m->ltsymbol);

View File

@ -0,0 +1,27 @@
diff -pu dwm.git/config.def.h dwm.underlinetags/config.def.h
--- dwm.git/config.def.h 2021-02-27 20:04:32.030570909 -0600
+++ dwm.underlinetags/config.def.h 2021-03-16 16:42:26.278703624 -0500
@@ -21,6 +21,11 @@ static const char *colors[][3] = {
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+static const unsigned int ulinepad = 5; /* horizontal padding between the underline and tag */
+static const unsigned int ulinestroke = 2; /* thickness / height of the underline */
+static const unsigned int ulinevoffset = 0; /* how far above the bottom of the bar the line should appear */
+static const int ulineall = 0; /* 1 to show underline on all tags, 0 for just the active ones */
+
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
diff -pu dwm.git/dwm.c dwm.underlinetags/dwm.c
--- dwm.git/dwm.c 2021-02-27 20:04:32.030570909 -0600
+++ dwm.underlinetags/dwm.c 2021-03-16 16:41:21.468077151 -0500
@@ -719,6 +719,8 @@ drawbar(Monitor *m)
w = TEXTW(tags[i]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
+ if (ulineall || m->tagset[m->seltags] & 1 << i) /* if there are conflicts, just move these lines directly underneath both 'drw_setscheme' and 'drw_text' :) */
+ drw_rect(drw, x + ulinepad, bh - ulinestroke - ulinevoffset, w - (ulinepad * 2), ulinestroke, 1, 0);
if (occ & 1 << i)
drw_rect(drw, x + boxs, boxs, boxw, boxw,
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,

View File

@ -0,0 +1,83 @@
diff --git a/dwm.c b/dwm.c
index e5efb6a..eaf0333 100644
--- a/dwm.c
+++ b/dwm.c
@@ -228,6 +228,9 @@ static void updatetitle(Client *c);
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
+static void window_set_state(Display *dpy, Window win, long state);
+static void window_map(Display *dpy, Client *c, int deiconify);
+static void window_unmap(Display *dpy, Window win, Window root, int iconify);
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
static int xerror(Display *dpy, XErrorEvent *ee);
@@ -1617,14 +1620,12 @@ showhide(Client *c)
return;
if (ISVISIBLE(c)) {
/* show clients top down */
- XMoveWindow(dpy, c->win, c->x, c->y);
- if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
- resize(c, c->x, c->y, c->w, c->h, 0);
+ window_map(dpy, c, 1);
showhide(c->snext);
} else {
/* hide clients bottom up */
showhide(c->snext);
- XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
+ window_unmap(dpy, c->win, root, 1);
}
}
@@ -2032,6 +2033,51 @@ updatewmhints(Client *c)
}
}
+void
+window_set_state(Display *dpy, Window win, long state)
+{
+ long data[] = { state, None };
+
+ XChangeProperty(dpy, win, wmatom[WMState], wmatom[WMState], 32,
+ PropModeReplace, (unsigned char*)data, 2);
+}
+
+void
+window_map(Display *dpy, Client *c, int deiconify)
+{
+ Window win = c->win;
+
+ if (deiconify)
+ window_set_state(dpy, win, NormalState);
+
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
+ XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
+ XMapWindow(dpy, win);
+}
+
+void
+window_unmap(Display *dpy, Window win, Window root, int iconify)
+{
+ static XWindowAttributes ca, ra;
+
+ XGrabServer(dpy);
+ XGetWindowAttributes(dpy, root, &ra);
+ XGetWindowAttributes(dpy, win, &ca);
+
+ /* Prevent UnmapNotify events */
+ XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
+ XSelectInput(dpy, win, ca.your_event_mask & ~StructureNotifyMask);
+
+ XUnmapWindow(dpy, win);
+
+ if (iconify)
+ window_set_state(dpy, win, IconicState);
+
+ XSelectInput(dpy, root, ra.your_event_mask);
+ XSelectInput(dpy, win, ca.your_event_mask);
+ XUngrabServer(dpy);
+}
+
void
view(const Arg *arg)
{

View File

@ -1,77 +0,0 @@
From a071b060a1b9b94bcb167b988cf7774ceb870aad Mon Sep 17 00:00:00 2001
From: Jack Bird <jack.bird@durham.ac.uk>
Date: Mon, 2 Aug 2021 18:44:05 +0100
Subject: [PATCH] deck patch works with 6.2
---
config.def.h | 2 ++
dwm.c | 26 ++++++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/config.def.h b/config.def.h
index a2ac963..d865e18 100644
--- a/config.def.h
+++ b/config.def.h
@@ -42,6 +42,7 @@ static const Layout layouts[] = {
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "[D]", deck },
};
/* key definitions */
@@ -77,6 +78,7 @@ static Key keys[] = {
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_r, setlayout, {.v = &layouts[3]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
diff --git a/dwm.c b/dwm.c
index 5e4d494..c67ff91 100644
--- a/dwm.c
+++ b/dwm.c
@@ -157,6 +157,7 @@ static void configure(Client *c);
static void configurenotify(XEvent *e);
static void configurerequest(XEvent *e);
static Monitor *createmon(void);
+static void deck(Monitor *m);
static void destroynotify(XEvent *e);
static void detach(Client *c);
static void detachstack(Client *c);
@@ -655,6 +656,31 @@ destroynotify(XEvent *e)
unmanage(c, 1);
}
+void
+deck(Monitor *m) {
+ unsigned int i, n, h, mw, my;
+ Client *c;
+
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if(n == 0)
+ return;
+
+ if(n > m->nmaster) {
+ mw = m->nmaster ? m->ww * m->mfact : 0;
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
+ }
+ else
+ mw = m->ww;
+ for(i = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if(i < m->nmaster) {
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
+ resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
+ my += HEIGHT(c);
+ }
+ else
+ resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False);
+}
+
void
detach(Client *c)
{
--
2.32.0

View File

@ -1,55 +0,0 @@
From a9e442ec18683e2255ffef74404c283bbb0b6381 Mon Sep 17 00:00:00 2001
From: aleks <aleks.stier@icloud.com>
Date: Thu, 23 May 2019 23:27:59 +0200
Subject: [PATCH] Make deck-patch work with the tilegap-patch
Apply this patch on top of the deck-patch to make it work with the
tilegap-patch.
---
dwm.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/dwm.c b/dwm.c
index 5b68242..1c17891 100644
--- a/dwm.c
+++ b/dwm.c
@@ -656,7 +656,7 @@ createmon(void)
void
deck(Monitor *m) {
- unsigned int i, n, h, mw, my;
+ unsigned int i, n, h, mw, my, ns;
Client *c;
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
@@ -665,18 +665,20 @@ deck(Monitor *m) {
if(n > m->nmaster) {
mw = m->nmaster ? m->ww * m->mfact : 0;
+ ns = m->nmaster > 0 ? 2 : 1;
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
- }
- else
+ } else {
mw = m->ww;
- for(i = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ ns = 1;
+ }
+ for(i = 0, my = gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if(i < m->nmaster) {
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
- my += HEIGHT(c);
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - gappx;
+ resize(c, m->wx + gappx, m->wy + my, mw - (2*c->bw) - gappx*(5-ns)/2, h - (2*c->bw), False);
+ my += HEIGHT(c) + gappx;
}
else
- resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False);
+ resize(c, m->wx + mw + gappx/ns, m->wy + gappx, m->ww - mw - (2*c->bw) - gappx*(5-ns)/2, m->wh - (2*c->bw) - 2*gappx, False);
}
void
--
2.21.0

View File

@ -4,5 +4,4 @@ cat <<EOF | xmenu
[]= Tiled Layout 0
><> Floating Layout 1
[M] Monocle Layout 2
[D] Deck Layout 3
EOF