Addressing various memory leak issues ref. #30

pull/74/head
bakkeby 3 years ago
parent a617d30e42
commit c6cb13555a

@ -1,4 +1,4 @@
From 7044085f4c3fed7ef1fb43289a17f63e0d402947 Mon Sep 17 00:00:00 2001
From 2ac70783ffc856e62fe8878fc48f5417319eae93 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 7 Apr 2020 10:53:35 +0200
Subject: [PATCH 2/2] Adding systray patch
@ -6,8 +6,8 @@ Subject: [PATCH 2/2] Adding systray patch
Refer to https://dwm.suckless.org/patches/systray/
---
config.def.h | 4 +
dwm.c | 425 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 403 insertions(+), 26 deletions(-)
dwm.c | 427 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 405 insertions(+), 26 deletions(-)
diff --git a/config.def.h b/config.def.h
index 4f68fe8..1952613 100644
@ -25,7 +25,7 @@ index 4f68fe8..1952613 100644
static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222";
diff --git a/dwm.c b/dwm.c
index 20f8309..f0c6638 100644
index 20f8309..12dfa04 100644
--- a/dwm.c
+++ b/dwm.c
@@ -59,12 +59,30 @@
@ -157,11 +157,13 @@ index 20f8309..f0c6638 100644
click = ClkStatusText;
else
click = ClkWinTitle;
@@ -490,6 +527,11 @@ cleanup(void)
@@ -490,6 +527,13 @@ cleanup(void)
XUngrabKey(dpy, AnyKey, AnyModifier, root);
while (mons)
cleanupmon(mons);
+ if (showsystray) {
+ while (systray->icons)
+ removesystrayicon(systray->icons);
+ XUnmapWindow(dpy, systray->win);
+ XDestroyWindow(dpy, systray->win);
+ free(systray);
@ -169,7 +171,7 @@ index 20f8309..f0c6638 100644
for (i = 0; i < CurLast; i++)
drw_cur_free(drw, cursor[i]);
for (i = 0; i < LENGTH(colors); i++)
@@ -520,9 +562,54 @@ cleanupmon(Monitor *mon)
@@ -520,9 +564,54 @@ cleanupmon(Monitor *mon)
void
clientmessage(XEvent *e)
{
@ -224,7 +226,7 @@ index 20f8309..f0c6638 100644
if (!c)
return;
if (cme->message_type == netatom[NetWMState]) {
@@ -660,6 +747,10 @@ destroynotify(XEvent *e)
@@ -660,6 +749,10 @@ destroynotify(XEvent *e)
if ((c = wintoclient(ev->window)))
unmanage(c, 1);
@ -235,7 +237,7 @@ index 20f8309..f0c6638 100644
}
void
@@ -703,17 +794,20 @@ dirtomon(int dir)
@@ -703,17 +796,20 @@ dirtomon(int dir)
void
drawbar(Monitor *m)
{
@ -258,7 +260,7 @@ index 20f8309..f0c6638 100644
}
for (c = m->clients; c; c = c->next) {
@@ -736,7 +830,7 @@ drawbar(Monitor *m)
@@ -736,7 +832,7 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[SchemeNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
@ -267,7 +269,7 @@ index 20f8309..f0c6638 100644
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
@@ -747,7 +841,7 @@ drawbar(Monitor *m)
@@ -747,7 +843,7 @@ drawbar(Monitor *m)
drw_rect(drw, x, 0, w, bh, 1, 1);
}
}
@ -276,7 +278,7 @@ index 20f8309..f0c6638 100644
}
void
@@ -755,8 +849,18 @@ drawbars(void)
@@ -755,8 +851,18 @@ drawbars(void)
{
Monitor *m;
@ -295,7 +297,7 @@ index 20f8309..f0c6638 100644
}
void
@@ -784,8 +888,11 @@ expose(XEvent *e)
@@ -784,8 +890,11 @@ expose(XEvent *e)
Monitor *m;
XExposeEvent *ev = &e->xexpose;
@ -308,7 +310,7 @@ index 20f8309..f0c6638 100644
}
void
@@ -871,9 +978,17 @@ getatomprop(Client *c, Atom prop)
@@ -871,9 +980,17 @@ getatomprop(Client *c, Atom prop)
unsigned char *p = NULL;
Atom da, atom = None;
@ -327,7 +329,7 @@ index 20f8309..f0c6638 100644
XFree(p);
}
return atom;
@@ -907,6 +1022,16 @@ getstate(Window w)
@@ -907,6 +1024,16 @@ getstate(Window w)
return result;
}
@ -344,7 +346,7 @@ index 20f8309..f0c6638 100644
int
gettextprop(Window w, Atom atom, char *text, unsigned int size)
{
@@ -1011,7 +1136,7 @@ killclient(const Arg *arg)
@@ -1011,7 +1138,7 @@ killclient(const Arg *arg)
{
if (!selmon->sel)
return;
@ -353,7 +355,7 @@ index 20f8309..f0c6638 100644
XGrabServer(dpy);
XSetErrorHandler(xerrordummy);
XSetCloseDownMode(dpy, DestroyAll);
@@ -1100,6 +1225,12 @@ maprequest(XEvent *e)
@@ -1100,6 +1227,12 @@ maprequest(XEvent *e)
static XWindowAttributes wa;
XMapRequestEvent *ev = &e->xmaprequest;
@ -366,7 +368,7 @@ index 20f8309..f0c6638 100644
if (!XGetWindowAttributes(dpy, ev->window, &wa))
return;
if (wa.override_redirect)
@@ -1223,6 +1354,16 @@ propertynotify(XEvent *e)
@@ -1223,6 +1356,16 @@ propertynotify(XEvent *e)
Window trans;
XPropertyEvent *ev = &e->xproperty;
@ -383,7 +385,7 @@ index 20f8309..f0c6638 100644
if ((ev->window == root) && (ev->atom == XA_WM_NAME))
updatestatus();
else if (ev->state == PropertyDelete)
@@ -1273,6 +1414,19 @@ recttomon(int x, int y, int w, int h)
@@ -1273,6 +1416,19 @@ recttomon(int x, int y, int w, int h)
return r;
}
@ -403,7 +405,7 @@ index 20f8309..f0c6638 100644
void
resize(Client *c, int x, int y, int w, int h, int interact)
{
@@ -1352,6 +1506,18 @@ resizemouse(const Arg *arg)
@@ -1352,6 +1508,18 @@ resizemouse(const Arg *arg)
}
}
@ -422,7 +424,7 @@ index 20f8309..f0c6638 100644
void
restack(Monitor *m)
{
@@ -1441,26 +1607,35 @@ setclientstate(Client *c, long state)
@@ -1441,26 +1609,35 @@ setclientstate(Client *c, long state)
}
int
@ -469,7 +471,7 @@ index 20f8309..f0c6638 100644
}
return exists;
}
@@ -1474,7 +1649,7 @@ setfocus(Client *c)
@@ -1474,7 +1651,7 @@ setfocus(Client *c)
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &(c->win), 1);
}
@ -478,7 +480,7 @@ index 20f8309..f0c6638 100644
}
void
@@ -1564,13 +1739,22 @@ setup(void)
@@ -1564,13 +1741,22 @@ setup(void)
wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
@ -501,7 +503,7 @@ index 20f8309..f0c6638 100644
/* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
@@ -1579,6 +1763,9 @@ setup(void)
@@ -1579,6 +1765,9 @@ setup(void)
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
for (i = 0; i < LENGTH(colors); i++)
scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3);
@ -511,7 +513,7 @@ index 20f8309..f0c6638 100644
/* init bars */
updatebars();
updatestatus();
@@ -1661,6 +1848,22 @@ spawn(const Arg *arg)
@@ -1661,6 +1850,22 @@ spawn(const Arg *arg)
}
}
@ -534,7 +536,7 @@ index 20f8309..f0c6638 100644
void
tag(const Arg *arg)
{
@@ -1711,6 +1914,23 @@ togglebar(const Arg *arg)
@@ -1711,6 +1916,23 @@ togglebar(const Arg *arg)
selmon->showbar = !selmon->showbar;
updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
@ -558,7 +560,7 @@ index 20f8309..f0c6638 100644
arrange(selmon);
}
@@ -1804,12 +2024,18 @@ unmapnotify(XEvent *e)
@@ -1804,12 +2026,18 @@ unmapnotify(XEvent *e)
setclientstate(c, WithdrawnState);
else
unmanage(c, 0);
@ -577,7 +579,7 @@ index 20f8309..f0c6638 100644
Monitor *m;
XSetWindowAttributes wa = {
.override_redirect = True,
@@ -1822,10 +2048,15 @@ updatebars(void)
@@ -1822,10 +2050,15 @@ updatebars(void)
for (m = mons; m; m = m->next) {
if (m->barwin)
continue;
@ -594,7 +596,7 @@ index 20f8309..f0c6638 100644
XMapRaised(dpy, m->barwin);
XSetClassHint(dpy, m->barwin, &ch);
}
@@ -2001,6 +2232,138 @@ updatestatus(void)
@@ -2001,6 +2234,138 @@ updatestatus(void)
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
strcpy(stext, "dwm-"VERSION);
drawbar(selmon);
@ -733,7 +735,7 @@ index 20f8309..f0c6638 100644
}
void
@@ -2085,6 +2448,16 @@ wintomon(Window w)
@@ -2085,6 +2450,16 @@ wintomon(Window w)
return selmon;
}

@ -1,16 +1,16 @@
From c9abc365fe139c55f564daf386aa5c1c29a20111 Mon Sep 17 00:00:00 2001
From 6c4fcf6c03689c39aba7ab2e7c28ee81145e3f3d Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Mon, 20 Jul 2020 11:19:12 +0200
Subject: [PATCH 2/2] Adding systray module
---
config.def.h | 3 +
dwm.c | 129 ++++++++++++++++++++++++++----
dwm.c | 131 ++++++++++++++++++++++++++----
patch/bar_systray.c | 190 ++++++++++++++++++++++++++++++++++++++++++++
patch/bar_systray.h | 40 ++++++++++
patch/include.c | 3 +-
patch/include.h | 3 +-
6 files changed, 351 insertions(+), 17 deletions(-)
6 files changed, 353 insertions(+), 17 deletions(-)
create mode 100644 patch/bar_systray.c
create mode 100644 patch/bar_systray.h
@ -36,7 +36,7 @@ index 2534eac..d17b65c 100644
{ -1, 0, BAR_ALIGN_NONE, width_wintitle, draw_wintitle, click_wintitle, "wintitle" },
};
diff --git a/dwm.c b/dwm.c
index 03dccfb..ed3fc50 100644
index 03dccfb..39fbfdb 100644
--- a/dwm.c
+++ b/dwm.c
@@ -63,6 +63,8 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
@ -69,11 +69,13 @@ index 03dccfb..ed3fc50 100644
static int running = 1;
static Cur *cursor[CurLast];
static Clr **scheme;
@@ -555,6 +558,13 @@ cleanup(void)
@@ -555,6 +558,15 @@ cleanup(void)
XUngrabKey(dpy, AnyKey, AnyModifier, root);
while (mons)
cleanupmon(mons);
+ if (showsystray && systray) {
+ while (systray->icons)
+ removesystrayicon(systray->icons);
+ if (systray->win) {
+ XUnmapWindow(dpy, systray->win);
+ XDestroyWindow(dpy, systray->win);
@ -83,7 +85,7 @@ index 03dccfb..ed3fc50 100644
for (i = 0; i < CurLast; i++)
drw_cur_free(drw, cursor[i]);
for (i = 0; i < LENGTH(colors); i++)
@@ -590,9 +600,48 @@ cleanupmon(Monitor *mon)
@@ -590,9 +602,48 @@ cleanupmon(Monitor *mon)
void
clientmessage(XEvent *e)
{
@ -132,7 +134,7 @@ index 03dccfb..ed3fc50 100644
if (!c)
return;
if (cme->message_type == netatom[NetWMState]) {
@@ -755,6 +804,10 @@ destroynotify(XEvent *e)
@@ -755,6 +806,10 @@ destroynotify(XEvent *e)
if ((c = wintoclient(ev->window)))
unmanage(c, 1);
@ -143,7 +145,7 @@ index 03dccfb..ed3fc50 100644
}
void
@@ -1021,9 +1074,15 @@ getatomprop(Client *c, Atom prop)
@@ -1021,9 +1076,15 @@ getatomprop(Client *c, Atom prop)
unsigned char *p = NULL;
Atom da, atom = None;
@ -160,7 +162,7 @@ index 03dccfb..ed3fc50 100644
XFree(p);
}
return atom;
@@ -1161,7 +1220,7 @@ killclient(const Arg *arg)
@@ -1161,7 +1222,7 @@ killclient(const Arg *arg)
{
if (!selmon->sel)
return;
@ -169,7 +171,7 @@ index 03dccfb..ed3fc50 100644
XGrabServer(dpy);
XSetErrorHandler(xerrordummy);
XSetCloseDownMode(dpy, DestroyAll);
@@ -1247,9 +1306,15 @@ mappingnotify(XEvent *e)
@@ -1247,9 +1308,15 @@ mappingnotify(XEvent *e)
void
maprequest(XEvent *e)
{
@ -185,7 +187,7 @@ index 03dccfb..ed3fc50 100644
if (!XGetWindowAttributes(dpy, ev->window, &wa))
return;
if (wa.override_redirect)
@@ -1373,6 +1438,16 @@ propertynotify(XEvent *e)
@@ -1373,6 +1440,16 @@ propertynotify(XEvent *e)
Window trans;
XPropertyEvent *ev = &e->xproperty;
@ -202,7 +204,7 @@ index 03dccfb..ed3fc50 100644
if ((ev->window == root) && (ev->atom == XA_WM_NAME))
updatestatus();
else if (ev->state == PropertyDelete)
@@ -1592,26 +1667,36 @@ setclientstate(Client *c, long state)
@@ -1592,26 +1669,36 @@ setclientstate(Client *c, long state)
}
int
@ -249,7 +251,7 @@ index 03dccfb..ed3fc50 100644
}
return exists;
}
@@ -1625,7 +1710,7 @@ setfocus(Client *c)
@@ -1625,7 +1712,7 @@ setfocus(Client *c)
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &(c->win), 1);
}
@ -258,7 +260,7 @@ index 03dccfb..ed3fc50 100644
}
void
@@ -1714,6 +1799,15 @@ setup(void)
@@ -1714,6 +1801,15 @@ setup(void)
wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
@ -274,7 +276,7 @@ index 03dccfb..ed3fc50 100644
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
@@ -1956,6 +2050,11 @@ unmapnotify(XEvent *e)
@@ -1956,6 +2052,11 @@ unmapnotify(XEvent *e)
setclientstate(c, WithdrawnState);
else
unmanage(c, 0);

@ -1,4 +1,4 @@
From 9484f887c623ec16d90c7a25ec1160bdb884258b Mon Sep 17 00:00:00 2001
From fd2e8fbc859d688521e50d98d5c47d1f98657afb Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 7 Apr 2020 12:33:04 +0200
Subject: [PATCH] Activate a window in response to _NET_ACTIVE_WINDOW
@ -22,11 +22,11 @@ management utilities
Refer to:
https://dwm.suckless.org/patches/focusonnetactive/
---
dwm.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
dwm.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/dwm.c b/dwm.c
index 4465af1..3919d47 100644
index 4465af1..4ca8891 100644
--- a/dwm.c
+++ b/dwm.c
@@ -514,6 +514,7 @@ clientmessage(XEvent *e)
@ -37,7 +37,7 @@ index 4465af1..3919d47 100644
if (!c)
return;
@@ -523,8 +524,14 @@ clientmessage(XEvent *e)
@@ -523,8 +524,15 @@ clientmessage(XEvent *e)
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
|| (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
} else if (cme->message_type == netatom[NetActiveWindow]) {
@ -46,6 +46,7 @@ index 4465af1..3919d47 100644
+ for (i = 0; i < LENGTH(tags) && !((1 << i) & c->tags); i++);
+ if (i < LENGTH(tags)) {
+ const Arg a = {.ui = 1 << i};
+ unfocus(selmon->sel, 0);
+ selmon = c->mon;
+ view(&a);
+ focus(c);

@ -1,4 +1,4 @@
From 95f79d41f42188d4e4b3d714eac7031ba79b2acf Mon Sep 17 00:00:00 2001
From 9ef25ecff0f049f7c3c5afe3a71da1961807ddb8 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 7 Apr 2020 12:34:15 +0200
Subject: [PATCH] pertag patch, keeps layout, mwfact, barpos and nmaster per
@ -6,11 +6,11 @@ Subject: [PATCH] pertag patch, keeps layout, mwfact, barpos and nmaster per
Refer to https://dwm.suckless.org/patches/pertag/
---
dwm.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 89 insertions(+), 7 deletions(-)
dwm.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 90 insertions(+), 7 deletions(-)
diff --git a/dwm.c b/dwm.c
index 4465af1..5254f27 100644
index 4465af1..466177c 100644
--- a/dwm.c
+++ b/dwm.c
@@ -111,6 +111,7 @@ typedef struct {
@ -48,7 +48,15 @@ index 4465af1..5254f27 100644
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -631,6 +645,7 @@ Monitor *
@@ -506,6 +520,7 @@ cleanupmon(Monitor *mon)
}
XUnmapWindow(dpy, mon->barwin);
XDestroyWindow(dpy, mon->barwin);
+ free(mon->pertag);
free(mon);
}
@@ -631,6 +646,7 @@ Monitor *
createmon(void)
{
Monitor *m;
@ -56,7 +64,7 @@ index 4465af1..5254f27 100644
m = ecalloc(1, sizeof(Monitor));
m->tagset[0] = m->tagset[1] = 1;
@@ -641,6 +656,28 @@ createmon(void)
@@ -641,6 +657,28 @@ createmon(void)
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
@ -85,7 +93,7 @@ index 4465af1..5254f27 100644
return m;
}
@@ -966,7 +1003,7 @@ grabkeys(void)
@@ -966,7 +1004,7 @@ grabkeys(void)
void
incnmaster(const Arg *arg)
{
@ -94,7 +102,7 @@ index 4465af1..5254f27 100644
arrange(selmon);
}
@@ -1500,10 +1537,13 @@ setfullscreen(Client *c, int fullscreen)
@@ -1500,10 +1538,13 @@ setfullscreen(Client *c, int fullscreen)
void
setlayout(const Arg *arg)
{
@ -111,7 +119,7 @@ index 4465af1..5254f27 100644
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
if (selmon->sel)
arrange(selmon);
@@ -1522,7 +1562,7 @@ setmfact(const Arg *arg)
@@ -1522,7 +1563,7 @@ setmfact(const Arg *arg)
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
if (f < 0.1 || f > 0.9)
return;
@ -120,7 +128,7 @@ index 4465af1..5254f27 100644
arrange(selmon);
}
@@ -1699,7 +1739,7 @@ tile(Monitor *m)
@@ -1699,7 +1740,7 @@ tile(Monitor *m)
void
togglebar(const Arg *arg)
{
@ -129,7 +137,7 @@ index 4465af1..5254f27 100644
updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
arrange(selmon);
@@ -1738,9 +1778,29 @@ void
@@ -1738,9 +1779,29 @@ void
toggleview(const Arg *arg)
{
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
@ -159,7 +167,7 @@ index 4465af1..5254f27 100644
focus(NULL);
arrange(selmon);
}
@@ -2035,11 +2095,33 @@ updatewmhints(Client *c)
@@ -2035,11 +2096,33 @@ updatewmhints(Client *c)
void
view(const Arg *arg)
{

@ -1,4 +1,4 @@
From 373abb6af8203ae73194a5a1121c2a374e425352 Mon Sep 17 00:00:00 2001
From 5f801f3a6995a034bca70df655f2e6ede051fbb8 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Fri, 1 May 2020 22:46:52 +0200
Subject: [PATCH] flextile-deluxe layout - a re-envisoned and revamped
@ -28,10 +28,10 @@ Features:
- supports rmaster like layout mirroring
---
config.def.h | 33 +-
dwm.c | 189 +++++++---
dwm.c | 190 +++++++---
flextile-deluxe.c | 861 ++++++++++++++++++++++++++++++++++++++++++++++
flextile-deluxe.h | 116 +++++++
4 files changed, 1145 insertions(+), 54 deletions(-)
4 files changed, 1146 insertions(+), 54 deletions(-)
create mode 100644 flextile-deluxe.c
create mode 100644 flextile-deluxe.h
@ -97,7 +97,7 @@ index 1c0b587..57b88f9 100644
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
diff --git a/dwm.c b/dwm.c
index 4465af1..efd00e7 100644
index 4465af1..98bc2bd 100644
--- a/dwm.c
+++ b/dwm.c
@@ -106,14 +106,28 @@ typedef struct {
@ -183,7 +183,15 @@ index 4465af1..efd00e7 100644
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -631,16 +660,51 @@ Monitor *
@@ -506,6 +535,7 @@ cleanupmon(Monitor *mon)
}
XUnmapWindow(dpy, mon->barwin);
XDestroyWindow(dpy, mon->barwin);
+ free(mon->pertag);
free(mon);
}
@@ -631,16 +661,51 @@ Monitor *
createmon(void)
{
Monitor *m;
@ -235,7 +243,7 @@ index 4465af1..efd00e7 100644
return m;
}
@@ -966,7 +1030,7 @@ grabkeys(void)
@@ -966,7 +1031,7 @@ grabkeys(void)
void
incnmaster(const Arg *arg)
{
@ -244,7 +252,7 @@ index 4465af1..efd00e7 100644
arrange(selmon);
}
@@ -1100,21 +1164,6 @@ maprequest(XEvent *e)
@@ -1100,21 +1165,6 @@ maprequest(XEvent *e)
manage(ev->window, &wa);
}
@ -266,7 +274,7 @@ index 4465af1..efd00e7 100644
void
motionnotify(XEvent *e)
{
@@ -1500,10 +1549,29 @@ setfullscreen(Client *c, int fullscreen)
@@ -1500,10 +1550,29 @@ setfullscreen(Client *c, int fullscreen)
void
setlayout(const Arg *arg)
{
@ -299,7 +307,7 @@ index 4465af1..efd00e7 100644
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
if (selmon->sel)
arrange(selmon);
@@ -1522,7 +1590,7 @@ setmfact(const Arg *arg)
@@ -1522,7 +1591,7 @@ setmfact(const Arg *arg)
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
if (f < 0.1 || f > 0.9)
return;
@ -308,7 +316,7 @@ index 4465af1..efd00e7 100644
arrange(selmon);
}
@@ -1670,36 +1738,10 @@ tagmon(const Arg *arg)
@@ -1670,36 +1739,10 @@ tagmon(const Arg *arg)
sendmon(selmon->sel, dirtomon(arg->i));
}
@ -346,7 +354,7 @@ index 4465af1..efd00e7 100644
updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
arrange(selmon);
@@ -1738,9 +1780,29 @@ void
@@ -1738,9 +1781,29 @@ void
toggleview(const Arg *arg)
{
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
@ -376,7 +384,7 @@ index 4465af1..efd00e7 100644
focus(NULL);
arrange(selmon);
}
@@ -2035,11 +2097,38 @@ updatewmhints(Client *c)
@@ -2035,11 +2098,38 @@ updatewmhints(Client *c)
void
view(const Arg *arg)
{

@ -1,4 +1,4 @@
From 771720506061c72a5217685e3fd7001db85690b4 Mon Sep 17 00:00:00 2001
From 1e8c293b43ab16219344d63c7fda809b66b39f19 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 3 Nov 2020 20:15:29 +0100
Subject: [PATCH 2/2] Monitor rules patch on top of pertag
@ -32,7 +32,7 @@ index 1c0b587..36bfa8c 100644
#define MODKEY Mod1Mask
#define TAGKEYS(KEY,TAG) \
diff --git a/dwm.c b/dwm.c
index 5254f27..b7a2782 100644
index 466177c..8597936 100644
--- a/dwm.c
+++ b/dwm.c
@@ -143,6 +143,16 @@ typedef struct {
@ -52,7 +52,7 @@ index 5254f27..b7a2782 100644
/* function declarations */
static void applyrules(Client *c);
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
@@ -644,31 +654,46 @@ configurerequest(XEvent *e)
@@ -645,31 +655,46 @@ configurerequest(XEvent *e)
Monitor *
createmon(void)
{
@ -113,7 +113,7 @@ index 5254f27..b7a2782 100644
m->pertag->sellts[i] = m->sellt;
/* init showbar */
@@ -677,6 +702,20 @@ createmon(void)
@@ -678,6 +703,20 @@ createmon(void)
#if ZOOMSWAP_PATCH
m->pertag->prevzooms[i] = NULL;
#endif // ZOOMSWAP_PATCH

@ -1,4 +1,4 @@
From 1e0cad18ab363bca14b2e7e42cde5678b6b23e5e Mon Sep 17 00:00:00 2001
From 995fccf76dea0e701a76a39ff11d8f98f8ba1b87 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Thu, 11 Feb 2021 11:08:32 +0100
Subject: [PATCH] Adding rio-like draw-to-resize windows.
@ -60,7 +60,7 @@ index 6d36cb7..e65c09a 100644
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
diff --git a/dwm.c b/dwm.c
index 4465af1..8954fcb 100644
index 4465af1..59eb871 100644
--- a/dwm.c
+++ b/dwm.c
@@ -40,6 +40,12 @@
@ -255,8 +255,8 @@ index 4465af1..8954fcb 100644
+riodraw(Client *c, const char slopstyle[])
+{
+ int i;
+ char str[100];
+ char strout[100];
+ char str[100] = {0};
+ char strout[100] = {0};
+ char tmpstring[30] = {0};
+ char slopcmd[100] = "slop -f x%xx%yx%wx%hx ";
+ int firstchar = 0;

@ -1,4 +1,4 @@
From bf9f15f792dd00b172c9a5094a5455de0a60ff4a Mon Sep 17 00:00:00 2001
From a5897a4c6bc88009dd3cf905cb98190d09341fba Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
Date: Tue, 7 Apr 2020 11:32:02 +0200
Subject: [PATCH] Adding systray patch
@ -6,8 +6,8 @@ Subject: [PATCH] Adding systray patch
Refer to https://dwm.suckless.org/patches/systray/
---
config.def.h | 4 +
dwm.c | 406 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 382 insertions(+), 28 deletions(-)
dwm.c | 408 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 384 insertions(+), 28 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..dd8e07a 100644
@ -25,7 +25,7 @@ index 1c0b587..dd8e07a 100644
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { "monospace:size=10" };
diff --git a/dwm.c b/dwm.c
index 4465af1..7f3cc51 100644
index 4465af1..1f31fb7 100644
--- a/dwm.c
+++ b/dwm.c
@@ -57,12 +57,30 @@
@ -158,11 +158,13 @@ index 4465af1..7f3cc51 100644
click = ClkStatusText;
else
click = ClkWinTitle;
@@ -482,6 +519,11 @@ cleanup(void)
@@ -482,6 +519,13 @@ cleanup(void)
XUngrabKey(dpy, AnyKey, AnyModifier, root);
while (mons)
cleanupmon(mons);
+ if (showsystray) {
+ while (systray->icons)
+ removesystrayicon(systray->icons);
+ XUnmapWindow(dpy, systray->win);
+ XDestroyWindow(dpy, systray->win);
+ free(systray);
@ -170,7 +172,7 @@ index 4465af1..7f3cc51 100644
for (i = 0; i < CurLast; i++)
drw_cur_free(drw, cursor[i]);
for (i = 0; i < LENGTH(colors); i++)
@@ -512,9 +554,50 @@ cleanupmon(Monitor *mon)
@@ -512,9 +556,50 @@ cleanupmon(Monitor *mon)
void
clientmessage(XEvent *e)
{
@ -221,7 +223,7 @@ index 4465af1..7f3cc51 100644
if (!c)
return;
if (cme->message_type == netatom[NetWMState]) {
@@ -567,7 +650,7 @@ configurenotify(XEvent *e)
@@ -567,7 +652,7 @@ configurenotify(XEvent *e)
for (c = m->clients; c; c = c->next)
if (c->isfullscreen)
resizeclient(c, m->mx, m->my, m->mw, m->mh);
@ -230,7 +232,7 @@ index 4465af1..7f3cc51 100644
}
focus(NULL);
arrange(NULL);
@@ -652,6 +735,11 @@ destroynotify(XEvent *e)
@@ -652,6 +737,11 @@ destroynotify(XEvent *e)
if ((c = wintoclient(ev->window)))
unmanage(c, 1);
@ -242,7 +244,7 @@ index 4465af1..7f3cc51 100644
}
void
@@ -695,19 +783,23 @@ dirtomon(int dir)
@@ -695,19 +785,23 @@ dirtomon(int dir)
void
drawbar(Monitor *m)
{
@ -268,7 +270,7 @@ index 4465af1..7f3cc51 100644
for (c = m->clients; c; c = c->next) {
occ |= c->tags;
if (c->isurgent)
@@ -728,7 +820,7 @@ drawbar(Monitor *m)
@@ -728,7 +822,7 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[SchemeNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
@ -277,7 +279,7 @@ index 4465af1..7f3cc51 100644
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
@@ -739,7 +831,7 @@ drawbar(Monitor *m)
@@ -739,7 +833,7 @@ drawbar(Monitor *m)
drw_rect(drw, x, 0, w, bh, 1, 1);
}
}
@ -286,7 +288,7 @@ index 4465af1..7f3cc51 100644
}
void
@@ -776,8 +868,11 @@ expose(XEvent *e)
@@ -776,8 +870,11 @@ expose(XEvent *e)
Monitor *m;
XExposeEvent *ev = &e->xexpose;
@ -299,7 +301,7 @@ index 4465af1..7f3cc51 100644
}
void
@@ -862,10 +957,17 @@ getatomprop(Client *c, Atom prop)
@@ -862,10 +959,17 @@ getatomprop(Client *c, Atom prop)
unsigned long dl;
unsigned char *p = NULL;
Atom da, atom = None;
@ -318,7 +320,7 @@ index 4465af1..7f3cc51 100644
XFree(p);
}
return atom;
@@ -899,6 +1001,16 @@ getstate(Window w)
@@ -899,6 +1003,16 @@ getstate(Window w)
return result;
}
@ -335,7 +337,7 @@ index 4465af1..7f3cc51 100644
int
gettextprop(Window w, Atom atom, char *text, unsigned int size)
{
@@ -1003,7 +1115,7 @@ killclient(const Arg *arg)
@@ -1003,7 +1117,7 @@ killclient(const Arg *arg)
{
if (!selmon->sel)
return;
@ -344,7 +346,7 @@ index 4465af1..7f3cc51 100644
XGrabServer(dpy);
XSetErrorHandler(xerrordummy);
XSetCloseDownMode(dpy, DestroyAll);
@@ -1091,6 +1203,12 @@ maprequest(XEvent *e)
@@ -1091,6 +1205,12 @@ maprequest(XEvent *e)
{
static XWindowAttributes wa;
XMapRequestEvent *ev = &e->xmaprequest;
@ -357,7 +359,7 @@ index 4465af1..7f3cc51 100644
if (!XGetWindowAttributes(dpy, ev->window, &wa))
return;
@@ -1215,6 +1333,16 @@ propertynotify(XEvent *e)
@@ -1215,6 +1335,16 @@ propertynotify(XEvent *e)
Window trans;
XPropertyEvent *ev = &e->xproperty;
@ -374,7 +376,7 @@ index 4465af1..7f3cc51 100644
if ((ev->window == root) && (ev->atom == XA_WM_NAME))
updatestatus();
else if (ev->state == PropertyDelete)
@@ -1265,6 +1393,19 @@ recttomon(int x, int y, int w, int h)
@@ -1265,6 +1395,19 @@ recttomon(int x, int y, int w, int h)
return r;
}
@ -394,7 +396,7 @@ index 4465af1..7f3cc51 100644
void
resize(Client *c, int x, int y, int w, int h, int interact)
{
@@ -1272,6 +1413,14 @@ resize(Client *c, int x, int y, int w, int h, int interact)
@@ -1272,6 +1415,14 @@ resize(Client *c, int x, int y, int w, int h, int interact)
resizeclient(c, x, y, w, h);
}
@ -409,7 +411,7 @@ index 4465af1..7f3cc51 100644
void
resizeclient(Client *c, int x, int y, int w, int h)
{
@@ -1344,6 +1493,19 @@ resizemouse(const Arg *arg)
@@ -1344,6 +1495,19 @@ resizemouse(const Arg *arg)
}
}
@ -429,7 +431,7 @@ index 4465af1..7f3cc51 100644
void
restack(Monitor *m)
{
@@ -1433,26 +1595,36 @@ setclientstate(Client *c, long state)
@@ -1433,26 +1597,36 @@ setclientstate(Client *c, long state)
}
int
@ -477,7 +479,7 @@ index 4465af1..7f3cc51 100644
}
return exists;
}
@@ -1466,7 +1638,7 @@ setfocus(Client *c)
@@ -1466,7 +1640,7 @@ setfocus(Client *c)
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &(c->win), 1);
}
@ -486,7 +488,7 @@ index 4465af1..7f3cc51 100644
}
void
@@ -1555,13 +1727,21 @@ setup(void)
@@ -1555,13 +1729,21 @@ setup(void)
wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
@ -508,7 +510,7 @@ index 4465af1..7f3cc51 100644
/* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
@@ -1570,6 +1750,8 @@ setup(void)
@@ -1570,6 +1752,8 @@ setup(void)
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
for (i = 0; i < LENGTH(colors); i++)
scheme[i] = drw_scm_create(drw, colors[i], 3);
@ -517,7 +519,7 @@ index 4465af1..7f3cc51 100644
/* init bars */
updatebars();
updatestatus();
@@ -1701,7 +1883,18 @@ togglebar(const Arg *arg)
@@ -1701,7 +1885,18 @@ togglebar(const Arg *arg)
{
selmon->showbar = !selmon->showbar;
updatebarpos(selmon);
@ -537,7 +539,7 @@ index 4465af1..7f3cc51 100644
arrange(selmon);
}
@@ -1796,11 +1989,18 @@ unmapnotify(XEvent *e)
@@ -1796,11 +1991,18 @@ unmapnotify(XEvent *e)
else
unmanage(c, 0);
}
@ -556,7 +558,7 @@ index 4465af1..7f3cc51 100644
Monitor *m;
XSetWindowAttributes wa = {
.override_redirect = True,
@@ -1811,10 +2011,15 @@ updatebars(void)
@@ -1811,10 +2013,15 @@ updatebars(void)
for (m = mons; m; m = m->next) {
if (m->barwin)
continue;
@ -573,7 +575,7 @@ index 4465af1..7f3cc51 100644
XMapRaised(dpy, m->barwin);
XSetClassHint(dpy, m->barwin, &ch);
}
@@ -1990,6 +2195,125 @@ updatestatus(void)
@@ -1990,6 +2197,125 @@ updatestatus(void)
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
strcpy(stext, "dwm-"VERSION);
drawbar(selmon);
@ -699,7 +701,7 @@ index 4465af1..7f3cc51 100644
}
void
@@ -2057,6 +2381,16 @@ wintoclient(Window w)
@@ -2057,6 +2383,16 @@ wintoclient(Window w)
return NULL;
}
@ -716,7 +718,7 @@ index 4465af1..7f3cc51 100644
Monitor *
wintomon(Window w)
{
@@ -2110,6 +2444,22 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
@@ -2110,6 +2446,22 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
return -1;
}

Loading…
Cancel
Save