From 20cd4e3acf424a4b001a0f9dea259ea043059329 Mon Sep 17 00:00:00 2001 From: Acid Bong Date: Thu, 1 Dec 2022 00:30:42 +0200 Subject: reordered patched since systray is replaced --- patches/3-ru-gaps-6.3.diff | 151 +++++++++++++++++++++ patches/4-movestack-20211115-a786211.diff | 93 +++++++++++++ patches/4-ru-gaps-6.3.diff | 151 --------------------- patches/5-focusurgent-20160831-56a31dc.diff | 55 ++++++++ patches/5-movestack-20211115-a786211.diff | 93 ------------- patches/6-focusonclick-20200110-61bb8b2.diff | 130 ++++++++++++++++++ patches/6-focusurgent-20160831-56a31dc.diff | 55 -------- patches/7-focusonclick-20200110-61bb8b2.diff | 130 ------------------ patches/7-restartsig-20180523-6.2.diff | 139 +++++++++++++++++++ patches/8-restartsig-20180523-6.2.diff | 139 ------------------- .../8-restoreafterrestart-20220709-d3f93c7.diff | 101 ++++++++++++++ .../9-restoreafterrestart-20220709-d3f93c7.diff | 101 -------------- 12 files changed, 669 insertions(+), 669 deletions(-) create mode 100644 patches/3-ru-gaps-6.3.diff create mode 100644 patches/4-movestack-20211115-a786211.diff delete mode 100644 patches/4-ru-gaps-6.3.diff create mode 100644 patches/5-focusurgent-20160831-56a31dc.diff delete mode 100644 patches/5-movestack-20211115-a786211.diff create mode 100644 patches/6-focusonclick-20200110-61bb8b2.diff delete mode 100644 patches/6-focusurgent-20160831-56a31dc.diff delete mode 100644 patches/7-focusonclick-20200110-61bb8b2.diff create mode 100644 patches/7-restartsig-20180523-6.2.diff delete mode 100644 patches/8-restartsig-20180523-6.2.diff create mode 100644 patches/8-restoreafterrestart-20220709-d3f93c7.diff delete mode 100644 patches/9-restoreafterrestart-20220709-d3f93c7.diff (limited to 'patches') diff --git a/patches/3-ru-gaps-6.3.diff b/patches/3-ru-gaps-6.3.diff new file mode 100644 index 0000000..8e83755 --- /dev/null +++ b/patches/3-ru-gaps-6.3.diff @@ -0,0 +1,151 @@ +From dee230eb56b95c5bc336ad5494675009e76830d1 Mon Sep 17 00:00:00 2001 +From: save196 +Date: Tue, 22 Mar 2022 22:10:05 +0200 +Subject: [PATCH] fixes and updated to work with dwm 6.3 + version + +- Fix bug where windows moved incorrectly while dragged with the mouse + in the floating layout +- Updated patch to work with dwm 6.3 +--- + config.def.h | 4 ++++ + dwm.c | 57 ++++++++++++++++++++++++++++++++++++++++------------ + 2 files changed, 48 insertions(+), 13 deletions(-) + +diff --git a/config.def.h b/config.def.h +index a2ac963..8f3da2b 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -2,6 +2,7 @@ + + /* appearance */ + static const unsigned int borderpx = 1; /* border pixel of windows */ ++static const int gappx = 5; /* gaps between windows */ + static const unsigned int snap = 32; /* snap pixel */ + static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ +@@ -85,6 +86,9 @@ static Key keys[] = { + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, ++ { MODKEY, XK_minus, setgaps, {.i = -5 } }, ++ { MODKEY, XK_equal, setgaps, {.i = +5 } }, ++ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) +diff --git a/dwm.c b/dwm.c +index 5f16260..506bb1a 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -119,6 +119,7 @@ struct Monitor { + int by; /* bar geometry */ + int mx, my, mw, mh; /* screen size */ + int wx, wy, ww, wh; /* window area */ ++ int gappx; /* gaps between windows */ + unsigned int seltags; + unsigned int sellt; + unsigned int tagset[2]; +@@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *m); + static void setclientstate(Client *c, long state); + static void setfocus(Client *c); + static void setfullscreen(Client *c, int fullscreen); ++static void setgaps(const Arg *arg); + static void setlayout(const Arg *arg); + static void setmfact(const Arg *arg); + static void setup(void); +@@ -640,6 +642,7 @@ createmon(void) + m->nmaster = nmaster; + m->showbar = showbar; + m->topbar = topbar; ++ m->gappx = gappx; + m->lt[0] = &layouts[0]; + m->lt[1] = &layouts[1 % LENGTH(layouts)]; + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); +@@ -1287,6 +1290,15 @@ resizeclient(Client *c, int x, int y, int w, int h) + c->oldw = c->w; c->w = wc.width = w; + c->oldh = c->h; c->h = wc.height = h; + wc.border_width = c->bw; ++ if (((nexttiled(c->mon->clients) == c && !nexttiled(c->next)) ++ || &monocle == c->mon->lt[c->mon->sellt]->arrange) ++ && !c->isfullscreen && !c->isfloating ++ && c->mon->lt[c->mon->sellt]->arrange) ++ { ++ c->w = wc.width += c->bw * 2; ++ c->h = wc.height += c->bw * 2; ++ wc.border_width = 0; ++ } + XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); + configure(c); + XSync(dpy, False); +@@ -1502,6 +1514,16 @@ setfullscreen(Client *c, int fullscreen) + } + } + ++void ++setgaps(const Arg *arg) ++{ ++ if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) ++ selmon->gappx = 0; ++ else ++ selmon->gappx += arg->i; ++ arrange(selmon); ++} ++ + void + setlayout(const Arg *arg) + { +@@ -1678,28 +1700,37 @@ tagmon(const Arg *arg) + void + tile(Monitor *m) + { +- unsigned int i, n, h, mw, my, ty; ++ unsigned int i, n, h, mw, my, ty, ns; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; ++ if(n == 1){ ++ c = nexttiled(m->clients); ++ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); ++ return; ++ } + +- if (n > m->nmaster) ++ if (n > m->nmaster) { + mw = m->nmaster ? m->ww * m->mfact : 0; +- else +- mw = m->ww; +- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) ++ ns = m->nmaster > 0 ? 2 : 1; ++ } ++ else{ ++ mw = m->ww - m->gappx; ++ ns = 1; ++ } ++ for (i = 0, my = ty = m->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), 0); +- if (my + HEIGHT(c) < m->wh) +- my += HEIGHT(c); ++ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx; ++ resize(c, m->wx + m->gappx, m->wy + my, mw - 2*c->bw - m->gappx*(5-ns)/2, h - 2*c->bw, 0); ++ if(my + HEIGHT(c) + m->gappx < m->wh) ++ my += HEIGHT(c) + m->gappx; + } else { +- h = (m->wh - ty) / (n - i); +- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); +- if (ty + HEIGHT(c) < m->wh) +- ty += HEIGHT(c); ++ h = (m->wh - ty) / (n - i) - m->gappx; ++ resize(c, m->wx + mw + m->gappx/ns, m->wy + ty, m->ww - mw - (2*c->bw) - m->gappx*(5-ns)/2, h - 2*c->bw, 0); ++ if(ty + HEIGHT(c) + m->gappx < m->wh) ++ ty += HEIGHT(c) + m->gappx; + } + } + +-- +2.35.1 + diff --git a/patches/4-movestack-20211115-a786211.diff b/patches/4-movestack-20211115-a786211.diff new file mode 100644 index 0000000..4428611 --- /dev/null +++ b/patches/4-movestack-20211115-a786211.diff @@ -0,0 +1,93 @@ +From 47cdf02e01103d2d16f74b90bd65a30201c9d80d Mon Sep 17 00:00:00 2001 +From: Acid Bong +Date: Wed, 19 Oct 2022 13:03:12 +0300 +Subject: [PATCH] patch: movestack + +--- + config.def.h | 6 ++++++ + movestack.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 54 insertions(+) + create mode 100644 movestack.c + +diff --git a/config.def.h b/config.def.h +index c954087..b8f0908 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -58,6 +58,7 @@ static const char *dmenucmd[] = { "rofi", "-show", "drun", "-show-icons", NULL } + static const char *termcmd[] = { "st", NULL }; + + #include ++#include "movestack.c" + static const Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_space, spawn, {.v = dmenucmd } }, +@@ -118,6 +119,11 @@ static const Key keys[] = { + { 0, XF86XK_AudioNext, spawn, SHCMD("playerctl next") }, + /* misc */ + { 0, XF86XK_TouchpadToggle, spawn, SHCMD("tp-toggle") }, ++ /* movestack patch */ ++ { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, /* vim keys */ ++ { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, ++ { MODKEY|ShiftMask, XK_Down, movestack, {.i = +1 } }, /* arrow keys */ ++ { MODKEY|ShiftMask, XK_Up, movestack, {.i = -1 } }, + }; + + /* button definitions */ +diff --git a/movestack.c b/movestack.c +new file mode 100644 +index 0000000..520f4ae +--- /dev/null ++++ b/movestack.c +@@ -0,0 +1,48 @@ ++void ++movestack(const Arg *arg) { ++ Client *c = NULL, *p = NULL, *pc = NULL, *i; ++ ++ if(arg->i > 0) { ++ /* find the client after selmon->sel */ ++ for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next); ++ if(!c) ++ for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next); ++ ++ } ++ else { ++ /* find the client before selmon->sel */ ++ for(i = selmon->clients; i != selmon->sel; i = i->next) ++ if(ISVISIBLE(i) && !i->isfloating) ++ c = i; ++ if(!c) ++ for(; i; i = i->next) ++ if(ISVISIBLE(i) && !i->isfloating) ++ c = i; ++ } ++ /* find the client before selmon->sel and c */ ++ for(i = selmon->clients; i && (!p || !pc); i = i->next) { ++ if(i->next == selmon->sel) ++ p = i; ++ if(i->next == c) ++ pc = i; ++ } ++ ++ /* swap c and selmon->sel selmon->clients in the selmon->clients list */ ++ if(c && c != selmon->sel) { ++ Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next; ++ selmon->sel->next = c->next==selmon->sel?c:c->next; ++ c->next = temp; ++ ++ if(p && p != c) ++ p->next = c; ++ if(pc && pc != selmon->sel) ++ pc->next = selmon->sel; ++ ++ if(selmon->sel == selmon->clients) ++ selmon->clients = c; ++ else if(c == selmon->clients) ++ selmon->clients = selmon->sel; ++ ++ arrange(selmon); ++ } ++} +\ No newline at end of file +-- +2.38.0 + diff --git a/patches/4-ru-gaps-6.3.diff b/patches/4-ru-gaps-6.3.diff deleted file mode 100644 index 8e83755..0000000 --- a/patches/4-ru-gaps-6.3.diff +++ /dev/null @@ -1,151 +0,0 @@ -From dee230eb56b95c5bc336ad5494675009e76830d1 Mon Sep 17 00:00:00 2001 -From: save196 -Date: Tue, 22 Mar 2022 22:10:05 +0200 -Subject: [PATCH] fixes and updated to work with dwm 6.3 - version - -- Fix bug where windows moved incorrectly while dragged with the mouse - in the floating layout -- Updated patch to work with dwm 6.3 ---- - config.def.h | 4 ++++ - dwm.c | 57 ++++++++++++++++++++++++++++++++++++++++------------ - 2 files changed, 48 insertions(+), 13 deletions(-) - -diff --git a/config.def.h b/config.def.h -index a2ac963..8f3da2b 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -2,6 +2,7 @@ - - /* appearance */ - static const unsigned int borderpx = 1; /* border pixel of windows */ -+static const int gappx = 5; /* gaps between windows */ - static const unsigned int snap = 32; /* snap pixel */ - static const int showbar = 1; /* 0 means no bar */ - static const int topbar = 1; /* 0 means bottom bar */ -@@ -85,6 +86,9 @@ static Key keys[] = { - { MODKEY, XK_period, focusmon, {.i = +1 } }, - { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, - { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, -+ { MODKEY, XK_minus, setgaps, {.i = -5 } }, -+ { MODKEY, XK_equal, setgaps, {.i = +5 } }, -+ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, - TAGKEYS( XK_1, 0) - TAGKEYS( XK_2, 1) - TAGKEYS( XK_3, 2) -diff --git a/dwm.c b/dwm.c -index 5f16260..506bb1a 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -119,6 +119,7 @@ struct Monitor { - int by; /* bar geometry */ - int mx, my, mw, mh; /* screen size */ - int wx, wy, ww, wh; /* window area */ -+ int gappx; /* gaps between windows */ - unsigned int seltags; - unsigned int sellt; - unsigned int tagset[2]; -@@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *m); - static void setclientstate(Client *c, long state); - static void setfocus(Client *c); - static void setfullscreen(Client *c, int fullscreen); -+static void setgaps(const Arg *arg); - static void setlayout(const Arg *arg); - static void setmfact(const Arg *arg); - static void setup(void); -@@ -640,6 +642,7 @@ createmon(void) - m->nmaster = nmaster; - m->showbar = showbar; - m->topbar = topbar; -+ m->gappx = gappx; - m->lt[0] = &layouts[0]; - m->lt[1] = &layouts[1 % LENGTH(layouts)]; - strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); -@@ -1287,6 +1290,15 @@ resizeclient(Client *c, int x, int y, int w, int h) - c->oldw = c->w; c->w = wc.width = w; - c->oldh = c->h; c->h = wc.height = h; - wc.border_width = c->bw; -+ if (((nexttiled(c->mon->clients) == c && !nexttiled(c->next)) -+ || &monocle == c->mon->lt[c->mon->sellt]->arrange) -+ && !c->isfullscreen && !c->isfloating -+ && c->mon->lt[c->mon->sellt]->arrange) -+ { -+ c->w = wc.width += c->bw * 2; -+ c->h = wc.height += c->bw * 2; -+ wc.border_width = 0; -+ } - XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); - configure(c); - XSync(dpy, False); -@@ -1502,6 +1514,16 @@ setfullscreen(Client *c, int fullscreen) - } - } - -+void -+setgaps(const Arg *arg) -+{ -+ if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) -+ selmon->gappx = 0; -+ else -+ selmon->gappx += arg->i; -+ arrange(selmon); -+} -+ - void - setlayout(const Arg *arg) - { -@@ -1678,28 +1700,37 @@ tagmon(const Arg *arg) - void - tile(Monitor *m) - { -- unsigned int i, n, h, mw, my, ty; -+ unsigned int i, n, h, mw, my, ty, ns; - Client *c; - - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if (n == 0) - return; -+ if(n == 1){ -+ c = nexttiled(m->clients); -+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); -+ return; -+ } - -- if (n > m->nmaster) -+ if (n > m->nmaster) { - mw = m->nmaster ? m->ww * m->mfact : 0; -- else -- mw = m->ww; -- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) -+ ns = m->nmaster > 0 ? 2 : 1; -+ } -+ else{ -+ mw = m->ww - m->gappx; -+ ns = 1; -+ } -+ for (i = 0, my = ty = m->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), 0); -- if (my + HEIGHT(c) < m->wh) -- my += HEIGHT(c); -+ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx; -+ resize(c, m->wx + m->gappx, m->wy + my, mw - 2*c->bw - m->gappx*(5-ns)/2, h - 2*c->bw, 0); -+ if(my + HEIGHT(c) + m->gappx < m->wh) -+ my += HEIGHT(c) + m->gappx; - } else { -- h = (m->wh - ty) / (n - i); -- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); -- if (ty + HEIGHT(c) < m->wh) -- ty += HEIGHT(c); -+ h = (m->wh - ty) / (n - i) - m->gappx; -+ resize(c, m->wx + mw + m->gappx/ns, m->wy + ty, m->ww - mw - (2*c->bw) - m->gappx*(5-ns)/2, h - 2*c->bw, 0); -+ if(ty + HEIGHT(c) + m->gappx < m->wh) -+ ty += HEIGHT(c) + m->gappx; - } - } - --- -2.35.1 - diff --git a/patches/5-focusurgent-20160831-56a31dc.diff b/patches/5-focusurgent-20160831-56a31dc.diff new file mode 100644 index 0000000..23a0858 --- /dev/null +++ b/patches/5-focusurgent-20160831-56a31dc.diff @@ -0,0 +1,55 @@ +From e9c46c8624e3de1fba021c30bbc42707ef51353c Mon Sep 17 00:00:00 2001 +From: Acid Bong +Date: Wed, 19 Oct 2022 13:23:34 +0300 +Subject: [PATCH] patch: focusurgent + +--- + config.def.h | 3 +++ + focusurgent.c | 14 ++++++++++++++ + 2 files changed, 17 insertions(+) + create mode 100644 focusurgent.c + +diff --git a/config.def.h b/config.def.h +index b8f0908..1de3c06 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -59,6 +59,7 @@ static const char *termcmd[] = { "st", NULL }; + + #include + #include "movestack.c" ++#include "focusurgent.c" + static const Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_space, spawn, {.v = dmenucmd } }, +@@ -124,6 +125,8 @@ static const Key keys[] = { + { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, + { MODKEY|ShiftMask, XK_Down, movestack, {.i = +1 } }, /* arrow keys */ + { MODKEY|ShiftMask, XK_Up, movestack, {.i = -1 } }, ++ /* focusurgent patch */ ++ { MODKEY, XK_a, focusurgent, {0} }, + }; + + /* button definitions */ +diff --git a/focusurgent.c b/focusurgent.c +new file mode 100644 +index 0000000..bc6eee6 +--- /dev/null ++++ b/focusurgent.c +@@ -0,0 +1,14 @@ ++static void ++focusurgent(const Arg *arg) { ++ Client *c; ++ int i; ++ for(c=selmon->clients; c && !c->isurgent; c=c->next); ++ if(c) { ++ for(i=0; i < LENGTH(tags) && !((1 << i) & c->tags); i++); ++ if(i < LENGTH(tags)) { ++ const Arg a = {.ui = 1 << i}; ++ view(&a); ++ focus(c); ++ } ++ } ++} +-- +2.38.0 + diff --git a/patches/5-movestack-20211115-a786211.diff b/patches/5-movestack-20211115-a786211.diff deleted file mode 100644 index 4428611..0000000 --- a/patches/5-movestack-20211115-a786211.diff +++ /dev/null @@ -1,93 +0,0 @@ -From 47cdf02e01103d2d16f74b90bd65a30201c9d80d Mon Sep 17 00:00:00 2001 -From: Acid Bong -Date: Wed, 19 Oct 2022 13:03:12 +0300 -Subject: [PATCH] patch: movestack - ---- - config.def.h | 6 ++++++ - movestack.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 54 insertions(+) - create mode 100644 movestack.c - -diff --git a/config.def.h b/config.def.h -index c954087..b8f0908 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -58,6 +58,7 @@ static const char *dmenucmd[] = { "rofi", "-show", "drun", "-show-icons", NULL } - static const char *termcmd[] = { "st", NULL }; - - #include -+#include "movestack.c" - static const Key keys[] = { - /* modifier key function argument */ - { MODKEY, XK_space, spawn, {.v = dmenucmd } }, -@@ -118,6 +119,11 @@ static const Key keys[] = { - { 0, XF86XK_AudioNext, spawn, SHCMD("playerctl next") }, - /* misc */ - { 0, XF86XK_TouchpadToggle, spawn, SHCMD("tp-toggle") }, -+ /* movestack patch */ -+ { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, /* vim keys */ -+ { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, -+ { MODKEY|ShiftMask, XK_Down, movestack, {.i = +1 } }, /* arrow keys */ -+ { MODKEY|ShiftMask, XK_Up, movestack, {.i = -1 } }, - }; - - /* button definitions */ -diff --git a/movestack.c b/movestack.c -new file mode 100644 -index 0000000..520f4ae ---- /dev/null -+++ b/movestack.c -@@ -0,0 +1,48 @@ -+void -+movestack(const Arg *arg) { -+ Client *c = NULL, *p = NULL, *pc = NULL, *i; -+ -+ if(arg->i > 0) { -+ /* find the client after selmon->sel */ -+ for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next); -+ if(!c) -+ for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next); -+ -+ } -+ else { -+ /* find the client before selmon->sel */ -+ for(i = selmon->clients; i != selmon->sel; i = i->next) -+ if(ISVISIBLE(i) && !i->isfloating) -+ c = i; -+ if(!c) -+ for(; i; i = i->next) -+ if(ISVISIBLE(i) && !i->isfloating) -+ c = i; -+ } -+ /* find the client before selmon->sel and c */ -+ for(i = selmon->clients; i && (!p || !pc); i = i->next) { -+ if(i->next == selmon->sel) -+ p = i; -+ if(i->next == c) -+ pc = i; -+ } -+ -+ /* swap c and selmon->sel selmon->clients in the selmon->clients list */ -+ if(c && c != selmon->sel) { -+ Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next; -+ selmon->sel->next = c->next==selmon->sel?c:c->next; -+ c->next = temp; -+ -+ if(p && p != c) -+ p->next = c; -+ if(pc && pc != selmon->sel) -+ pc->next = selmon->sel; -+ -+ if(selmon->sel == selmon->clients) -+ selmon->clients = c; -+ else if(c == selmon->clients) -+ selmon->clients = selmon->sel; -+ -+ arrange(selmon); -+ } -+} -\ No newline at end of file --- -2.38.0 - diff --git a/patches/6-focusonclick-20200110-61bb8b2.diff b/patches/6-focusonclick-20200110-61bb8b2.diff new file mode 100644 index 0000000..b6ba2bb --- /dev/null +++ b/patches/6-focusonclick-20200110-61bb8b2.diff @@ -0,0 +1,130 @@ +From f44fcd4f15932c08ca0d2e1b995a4707c476a564 Mon Sep 17 00:00:00 2001 +From: Acid Bong +Date: Wed, 19 Oct 2022 13:28:19 +0300 +Subject: [PATCH] patch: focusonclick (my fav) + +--- + config.def.h | 1 + + dwm.c | 47 ++++------------------------------------------- + 2 files changed, 5 insertions(+), 43 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1de3c06..eddbc03 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -9,6 +9,7 @@ static const unsigned int systrayonleft = 0; /* 0: systray in the right corne + static const unsigned int systrayspacing = 2; /* systray spacing */ + static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ + static const int showsystray = 1; /* 0 means no systray */ ++static const int focusonwheel = 0; + 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" }; +diff --git a/dwm.c b/dwm.c +index 40ac0df..412f04f 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -186,7 +186,6 @@ static void detachstack(Client *c); + static Monitor *dirtomon(int dir); + static void drawbar(Monitor *m); + static void drawbars(void); +-static void enternotify(XEvent *e); + static void expose(XEvent *e); + static void focus(Client *c); + static void focusin(XEvent *e); +@@ -206,7 +205,6 @@ static void manage(Window w, XWindowAttributes *wa); + static void mappingnotify(XEvent *e); + static void maprequest(XEvent *e); + static void monocle(Monitor *m); +-static void motionnotify(XEvent *e); + static void movemouse(const Arg *arg); + static Client *nexttiled(Client *c); + static void pop(Client *c); +@@ -284,13 +282,11 @@ static void (*handler[LASTEvent]) (XEvent *) = { + [ConfigureRequest] = configurerequest, + [ConfigureNotify] = configurenotify, + [DestroyNotify] = destroynotify, +- [EnterNotify] = enternotify, + [Expose] = expose, + [FocusIn] = focusin, + [KeyPress] = keypress, + [MappingNotify] = mappingnotify, + [MapRequest] = maprequest, +- [MotionNotify] = motionnotify, + [PropertyNotify] = propertynotify, + [ResizeRequest] = resizerequest, + [UnmapNotify] = unmapnotify +@@ -462,7 +458,8 @@ buttonpress(XEvent *e) + + click = ClkRootWin; + /* focus monitor if necessary */ +- if ((m = wintomon(ev->window)) && m != selmon) { ++ if ((m = wintomon(ev->window)) && m != selmon ++ && (focusonwheel || (ev->button != Button4 && ev->button != Button5))) { + unfocus(selmon->sel, 1); + selmon = m; + focus(NULL); +@@ -482,8 +479,8 @@ buttonpress(XEvent *e) + else + click = ClkWinTitle; + } else if ((c = wintoclient(ev->window))) { +- focus(c); +- restack(selmon); ++ if (focusonwheel || (ev->button != Button4 && ev->button != Button5)) ++ focus(c); + XAllowEvents(dpy, ReplayPointer, CurrentTime); + click = ClkClientWin; + } +@@ -859,25 +856,6 @@ drawbars(void) + drawbar(m); + } + +-void +-enternotify(XEvent *e) +-{ +- Client *c; +- Monitor *m; +- XCrossingEvent *ev = &e->xcrossing; +- +- if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) +- return; +- c = wintoclient(ev->window); +- m = c ? c->mon : wintomon(ev->window); +- if (m != selmon) { +- unfocus(selmon->sel, 1); +- selmon = m; +- } else if (!c || c == selmon->sel) +- return; +- focus(c); +-} +- + void + expose(XEvent *e) + { +@@ -1257,23 +1235,6 @@ monocle(Monitor *m) + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); + } + +-void +-motionnotify(XEvent *e) +-{ +- static Monitor *mon = NULL; +- Monitor *m; +- XMotionEvent *ev = &e->xmotion; +- +- if (ev->window != root) +- return; +- if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { +- unfocus(selmon->sel, 1); +- selmon = m; +- focus(NULL); +- } +- mon = m; +-} +- + void + movemouse(const Arg *arg) + { +-- +2.38.0 + diff --git a/patches/6-focusurgent-20160831-56a31dc.diff b/patches/6-focusurgent-20160831-56a31dc.diff deleted file mode 100644 index 23a0858..0000000 --- a/patches/6-focusurgent-20160831-56a31dc.diff +++ /dev/null @@ -1,55 +0,0 @@ -From e9c46c8624e3de1fba021c30bbc42707ef51353c Mon Sep 17 00:00:00 2001 -From: Acid Bong -Date: Wed, 19 Oct 2022 13:23:34 +0300 -Subject: [PATCH] patch: focusurgent - ---- - config.def.h | 3 +++ - focusurgent.c | 14 ++++++++++++++ - 2 files changed, 17 insertions(+) - create mode 100644 focusurgent.c - -diff --git a/config.def.h b/config.def.h -index b8f0908..1de3c06 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -59,6 +59,7 @@ static const char *termcmd[] = { "st", NULL }; - - #include - #include "movestack.c" -+#include "focusurgent.c" - static const Key keys[] = { - /* modifier key function argument */ - { MODKEY, XK_space, spawn, {.v = dmenucmd } }, -@@ -124,6 +125,8 @@ static const Key keys[] = { - { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, - { MODKEY|ShiftMask, XK_Down, movestack, {.i = +1 } }, /* arrow keys */ - { MODKEY|ShiftMask, XK_Up, movestack, {.i = -1 } }, -+ /* focusurgent patch */ -+ { MODKEY, XK_a, focusurgent, {0} }, - }; - - /* button definitions */ -diff --git a/focusurgent.c b/focusurgent.c -new file mode 100644 -index 0000000..bc6eee6 ---- /dev/null -+++ b/focusurgent.c -@@ -0,0 +1,14 @@ -+static void -+focusurgent(const Arg *arg) { -+ Client *c; -+ int i; -+ for(c=selmon->clients; c && !c->isurgent; c=c->next); -+ if(c) { -+ for(i=0; i < LENGTH(tags) && !((1 << i) & c->tags); i++); -+ if(i < LENGTH(tags)) { -+ const Arg a = {.ui = 1 << i}; -+ view(&a); -+ focus(c); -+ } -+ } -+} --- -2.38.0 - diff --git a/patches/7-focusonclick-20200110-61bb8b2.diff b/patches/7-focusonclick-20200110-61bb8b2.diff deleted file mode 100644 index b6ba2bb..0000000 --- a/patches/7-focusonclick-20200110-61bb8b2.diff +++ /dev/null @@ -1,130 +0,0 @@ -From f44fcd4f15932c08ca0d2e1b995a4707c476a564 Mon Sep 17 00:00:00 2001 -From: Acid Bong -Date: Wed, 19 Oct 2022 13:28:19 +0300 -Subject: [PATCH] patch: focusonclick (my fav) - ---- - config.def.h | 1 + - dwm.c | 47 ++++------------------------------------------- - 2 files changed, 5 insertions(+), 43 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 1de3c06..eddbc03 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -9,6 +9,7 @@ static const unsigned int systrayonleft = 0; /* 0: systray in the right corne - static const unsigned int systrayspacing = 2; /* systray spacing */ - static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ - static const int showsystray = 1; /* 0 means no systray */ -+static const int focusonwheel = 0; - 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" }; -diff --git a/dwm.c b/dwm.c -index 40ac0df..412f04f 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -186,7 +186,6 @@ static void detachstack(Client *c); - static Monitor *dirtomon(int dir); - static void drawbar(Monitor *m); - static void drawbars(void); --static void enternotify(XEvent *e); - static void expose(XEvent *e); - static void focus(Client *c); - static void focusin(XEvent *e); -@@ -206,7 +205,6 @@ static void manage(Window w, XWindowAttributes *wa); - static void mappingnotify(XEvent *e); - static void maprequest(XEvent *e); - static void monocle(Monitor *m); --static void motionnotify(XEvent *e); - static void movemouse(const Arg *arg); - static Client *nexttiled(Client *c); - static void pop(Client *c); -@@ -284,13 +282,11 @@ static void (*handler[LASTEvent]) (XEvent *) = { - [ConfigureRequest] = configurerequest, - [ConfigureNotify] = configurenotify, - [DestroyNotify] = destroynotify, -- [EnterNotify] = enternotify, - [Expose] = expose, - [FocusIn] = focusin, - [KeyPress] = keypress, - [MappingNotify] = mappingnotify, - [MapRequest] = maprequest, -- [MotionNotify] = motionnotify, - [PropertyNotify] = propertynotify, - [ResizeRequest] = resizerequest, - [UnmapNotify] = unmapnotify -@@ -462,7 +458,8 @@ buttonpress(XEvent *e) - - click = ClkRootWin; - /* focus monitor if necessary */ -- if ((m = wintomon(ev->window)) && m != selmon) { -+ if ((m = wintomon(ev->window)) && m != selmon -+ && (focusonwheel || (ev->button != Button4 && ev->button != Button5))) { - unfocus(selmon->sel, 1); - selmon = m; - focus(NULL); -@@ -482,8 +479,8 @@ buttonpress(XEvent *e) - else - click = ClkWinTitle; - } else if ((c = wintoclient(ev->window))) { -- focus(c); -- restack(selmon); -+ if (focusonwheel || (ev->button != Button4 && ev->button != Button5)) -+ focus(c); - XAllowEvents(dpy, ReplayPointer, CurrentTime); - click = ClkClientWin; - } -@@ -859,25 +856,6 @@ drawbars(void) - drawbar(m); - } - --void --enternotify(XEvent *e) --{ -- Client *c; -- Monitor *m; -- XCrossingEvent *ev = &e->xcrossing; -- -- if ((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) -- return; -- c = wintoclient(ev->window); -- m = c ? c->mon : wintomon(ev->window); -- if (m != selmon) { -- unfocus(selmon->sel, 1); -- selmon = m; -- } else if (!c || c == selmon->sel) -- return; -- focus(c); --} -- - void - expose(XEvent *e) - { -@@ -1257,23 +1235,6 @@ monocle(Monitor *m) - resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); - } - --void --motionnotify(XEvent *e) --{ -- static Monitor *mon = NULL; -- Monitor *m; -- XMotionEvent *ev = &e->xmotion; -- -- if (ev->window != root) -- return; -- if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { -- unfocus(selmon->sel, 1); -- selmon = m; -- focus(NULL); -- } -- mon = m; --} -- - void - movemouse(const Arg *arg) - { --- -2.38.0 - diff --git a/patches/7-restartsig-20180523-6.2.diff b/patches/7-restartsig-20180523-6.2.diff new file mode 100644 index 0000000..f1f8680 --- /dev/null +++ b/patches/7-restartsig-20180523-6.2.diff @@ -0,0 +1,139 @@ +From 2991f37f0aaf44b9f9b11e7893ff0af8eb88f649 Mon Sep 17 00:00:00 2001 +From: Christopher Drelich +Date: Wed, 23 May 2018 22:50:38 -0400 +Subject: [PATCH] Modifies quit to handle restarts and adds SIGHUP and SIGTERM + handlers. + +Modified quit() to restart if it receives arg .i = 1 +MOD+CTRL+SHIFT+Q was added to confid.def.h to do just that. + +Signal handlers were handled for SIGHUP and SIGTERM. +If dwm receives these signals it calls quit() with +arg .i = to 1 or 0, respectively. + +To restart dwm: +MOD+CTRL+SHIFT+Q +or +kill -HUP dwmpid + +To quit dwm cleanly: +MOD+SHIFT+Q +or +kill -TERM dwmpid +--- + config.def.h | 1 + + dwm.1 | 10 ++++++++++ + dwm.c | 22 ++++++++++++++++++++++ + 3 files changed, 33 insertions(+) + +diff --git a/config.def.h b/config.def.h +index a9ac303..e559429 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -94,6 +94,7 @@ static Key keys[] = { + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_q, quit, {0} }, ++ { MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} }, + }; + + /* button definitions */ +diff --git a/dwm.1 b/dwm.1 +index 13b3729..36a331c 100644 +--- a/dwm.1 ++++ b/dwm.1 +@@ -142,6 +142,9 @@ Add/remove all windows with nth tag to/from the view. + .TP + .B Mod1\-Shift\-q + Quit dwm. ++.TP ++.B Mod1\-Control\-Shift\-q ++Restart dwm. + .SS Mouse commands + .TP + .B Mod1\-Button1 +@@ -155,6 +158,13 @@ Resize focused window while dragging. Tiled windows will be toggled to the float + .SH CUSTOMIZATION + dwm is customized by creating a custom config.h and (re)compiling the source + code. This keeps it fast, secure and simple. ++.SH SIGNALS ++.TP ++.B SIGHUP - 1 ++Restart the dwm process. ++.TP ++.B SIGTERM - 15 ++Cleanly terminate the dwm process. + .SH SEE ALSO + .BR dmenu (1), + .BR st (1) +diff --git a/dwm.c b/dwm.c +index bb95e26..286eecd 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -205,6 +205,8 @@ static void setup(void); + static void seturgent(Client *c, int urg); + static void showhide(Client *c); + static void sigchld(int unused); ++static void sighup(int unused); ++static void sigterm(int unused); + static void spawn(const Arg *arg); + static void tag(const Arg *arg); + static void tagmon(const Arg *arg); +@@ -260,6 +262,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { + [UnmapNotify] = unmapnotify + }; + static Atom wmatom[WMLast], netatom[NetLast]; ++static int restart = 0; + static int running = 1; + static Cur *cursor[CurLast]; + static Clr **scheme; +@@ -1248,6 +1251,7 @@ propertynotify(XEvent *e) + void + quit(const Arg *arg) + { ++ if(arg->i) restart = 1; + running = 0; + } + +@@ -1536,6 +1540,9 @@ setup(void) + /* clean up any zombies immediately */ + sigchld(0); + ++ signal(SIGHUP, sighup); ++ signal(SIGTERM, sigterm); ++ + /* init screen */ + screen = DefaultScreen(dpy); + sw = DisplayWidth(dpy, screen); +@@ -1637,6 +1644,20 @@ sigchld(int unused) + } + + void ++sighup(int unused) ++{ ++ Arg a = {.i = 1}; ++ quit(&a); ++} ++ ++void ++sigterm(int unused) ++{ ++ Arg a = {.i = 0}; ++ quit(&a); ++} ++ ++void + spawn(const Arg *arg) + { + if (arg->v == dmenucmd) +@@ -2139,6 +2160,7 @@ main(int argc, char *argv[]) + setup(); + scan(); + run(); ++ if(restart) execvp(argv[0], argv); + cleanup(); + XCloseDisplay(dpy); + return EXIT_SUCCESS; +-- +2.7.4 + diff --git a/patches/8-restartsig-20180523-6.2.diff b/patches/8-restartsig-20180523-6.2.diff deleted file mode 100644 index f1f8680..0000000 --- a/patches/8-restartsig-20180523-6.2.diff +++ /dev/null @@ -1,139 +0,0 @@ -From 2991f37f0aaf44b9f9b11e7893ff0af8eb88f649 Mon Sep 17 00:00:00 2001 -From: Christopher Drelich -Date: Wed, 23 May 2018 22:50:38 -0400 -Subject: [PATCH] Modifies quit to handle restarts and adds SIGHUP and SIGTERM - handlers. - -Modified quit() to restart if it receives arg .i = 1 -MOD+CTRL+SHIFT+Q was added to confid.def.h to do just that. - -Signal handlers were handled for SIGHUP and SIGTERM. -If dwm receives these signals it calls quit() with -arg .i = to 1 or 0, respectively. - -To restart dwm: -MOD+CTRL+SHIFT+Q -or -kill -HUP dwmpid - -To quit dwm cleanly: -MOD+SHIFT+Q -or -kill -TERM dwmpid ---- - config.def.h | 1 + - dwm.1 | 10 ++++++++++ - dwm.c | 22 ++++++++++++++++++++++ - 3 files changed, 33 insertions(+) - -diff --git a/config.def.h b/config.def.h -index a9ac303..e559429 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -94,6 +94,7 @@ static Key keys[] = { - TAGKEYS( XK_8, 7) - TAGKEYS( XK_9, 8) - { MODKEY|ShiftMask, XK_q, quit, {0} }, -+ { MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} }, - }; - - /* button definitions */ -diff --git a/dwm.1 b/dwm.1 -index 13b3729..36a331c 100644 ---- a/dwm.1 -+++ b/dwm.1 -@@ -142,6 +142,9 @@ Add/remove all windows with nth tag to/from the view. - .TP - .B Mod1\-Shift\-q - Quit dwm. -+.TP -+.B Mod1\-Control\-Shift\-q -+Restart dwm. - .SS Mouse commands - .TP - .B Mod1\-Button1 -@@ -155,6 +158,13 @@ Resize focused window while dragging. Tiled windows will be toggled to the float - .SH CUSTOMIZATION - dwm is customized by creating a custom config.h and (re)compiling the source - code. This keeps it fast, secure and simple. -+.SH SIGNALS -+.TP -+.B SIGHUP - 1 -+Restart the dwm process. -+.TP -+.B SIGTERM - 15 -+Cleanly terminate the dwm process. - .SH SEE ALSO - .BR dmenu (1), - .BR st (1) -diff --git a/dwm.c b/dwm.c -index bb95e26..286eecd 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -205,6 +205,8 @@ static void setup(void); - static void seturgent(Client *c, int urg); - static void showhide(Client *c); - static void sigchld(int unused); -+static void sighup(int unused); -+static void sigterm(int unused); - static void spawn(const Arg *arg); - static void tag(const Arg *arg); - static void tagmon(const Arg *arg); -@@ -260,6 +262,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { - [UnmapNotify] = unmapnotify - }; - static Atom wmatom[WMLast], netatom[NetLast]; -+static int restart = 0; - static int running = 1; - static Cur *cursor[CurLast]; - static Clr **scheme; -@@ -1248,6 +1251,7 @@ propertynotify(XEvent *e) - void - quit(const Arg *arg) - { -+ if(arg->i) restart = 1; - running = 0; - } - -@@ -1536,6 +1540,9 @@ setup(void) - /* clean up any zombies immediately */ - sigchld(0); - -+ signal(SIGHUP, sighup); -+ signal(SIGTERM, sigterm); -+ - /* init screen */ - screen = DefaultScreen(dpy); - sw = DisplayWidth(dpy, screen); -@@ -1637,6 +1644,20 @@ sigchld(int unused) - } - - void -+sighup(int unused) -+{ -+ Arg a = {.i = 1}; -+ quit(&a); -+} -+ -+void -+sigterm(int unused) -+{ -+ Arg a = {.i = 0}; -+ quit(&a); -+} -+ -+void - spawn(const Arg *arg) - { - if (arg->v == dmenucmd) -@@ -2139,6 +2160,7 @@ main(int argc, char *argv[]) - setup(); - scan(); - run(); -+ if(restart) execvp(argv[0], argv); - cleanup(); - XCloseDisplay(dpy); - return EXIT_SUCCESS; --- -2.7.4 - diff --git a/patches/8-restoreafterrestart-20220709-d3f93c7.diff b/patches/8-restoreafterrestart-20220709-d3f93c7.diff new file mode 100644 index 0000000..cfcb607 --- /dev/null +++ b/patches/8-restoreafterrestart-20220709-d3f93c7.diff @@ -0,0 +1,101 @@ +From 9fd4a02b57aa8a764d8105d5f2f854372f4ef559 Mon Sep 17 00:00:00 2001 +From: ViliamKovac1223 +Date: Sat, 9 Jul 2022 17:35:54 +0200 +Subject: [PATCH] add restore patch + +--- + config.def.h | 2 ++ + dwm.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 55 insertions(+) + +diff --git a/config.def.h b/config.def.h +index 6ec4146..0b91976 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -1,5 +1,7 @@ + /* See LICENSE file for copyright and license details. */ + ++#define SESSION_FILE "/tmp/dwm-session" ++ + /* appearance */ + static const unsigned int borderpx = 1; /* border pixel of windows */ + static const unsigned int snap = 32; /* snap pixel */ +diff --git a/dwm.c b/dwm.c +index 74cec7e..76b40a2 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -1255,11 +1255,63 @@ propertynotify(XEvent *e) + } + } + ++void ++saveSession(void) ++{ ++ FILE *fw = fopen(SESSION_FILE, "w"); ++ for (Client *c = selmon->clients; c != NULL; c = c->next) { // get all the clients with their tags and write them to the file ++ fprintf(fw, "%lu %u\n", c->win, c->tags); ++ } ++ fclose(fw); ++} ++ ++void ++restoreSession(void) ++{ ++ // restore session ++ FILE *fr = fopen(SESSION_FILE, "r"); ++ if (!fr) ++ return; ++ ++ char *str = malloc(23 * sizeof(char)); // allocate enough space for excepted input from text file ++ while (fscanf(fr, "%[^\n] ", str) != EOF) { // read file till the end ++ long unsigned int winId; ++ unsigned int tagsForWin; ++ int check = sscanf(str, "%lu %u", &winId, &tagsForWin); // get data ++ if (check != 2) // break loop if data wasn't read correctly ++ break; ++ ++ for (Client *c = selmon->clients; c ; c = c->next) { // add tags to every window by winId ++ if (c->win == winId) { ++ c->tags = tagsForWin; ++ break; ++ } ++ } ++ } ++ ++ for (Client *c = selmon->clients; c ; c = c->next) { // refocus on windows ++ focus(c); ++ restack(c->mon); ++ } ++ ++ for (Monitor *m = selmon; m; m = m->next) // rearrange all monitors ++ arrange(m); ++ ++ free(str); ++ fclose(fr); ++ ++ // delete a file ++ remove(SESSION_FILE); ++} ++ + void + quit(const Arg *arg) + { + if(arg->i) restart = 1; + running = 0; ++ ++ if (restart == 1) ++ saveSession(); + } + + Monitor * +@@ -2173,6 +2225,7 @@ main(int argc, char *argv[]) + die("pledge"); + #endif /* __OpenBSD__ */ + scan(); ++ restoreSession(); + run(); + if(restart) execvp(argv[0], argv); + cleanup(); +-- +2.35.1 + diff --git a/patches/9-restoreafterrestart-20220709-d3f93c7.diff b/patches/9-restoreafterrestart-20220709-d3f93c7.diff deleted file mode 100644 index cfcb607..0000000 --- a/patches/9-restoreafterrestart-20220709-d3f93c7.diff +++ /dev/null @@ -1,101 +0,0 @@ -From 9fd4a02b57aa8a764d8105d5f2f854372f4ef559 Mon Sep 17 00:00:00 2001 -From: ViliamKovac1223 -Date: Sat, 9 Jul 2022 17:35:54 +0200 -Subject: [PATCH] add restore patch - ---- - config.def.h | 2 ++ - dwm.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 55 insertions(+) - -diff --git a/config.def.h b/config.def.h -index 6ec4146..0b91976 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -1,5 +1,7 @@ - /* See LICENSE file for copyright and license details. */ - -+#define SESSION_FILE "/tmp/dwm-session" -+ - /* appearance */ - static const unsigned int borderpx = 1; /* border pixel of windows */ - static const unsigned int snap = 32; /* snap pixel */ -diff --git a/dwm.c b/dwm.c -index 74cec7e..76b40a2 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -1255,11 +1255,63 @@ propertynotify(XEvent *e) - } - } - -+void -+saveSession(void) -+{ -+ FILE *fw = fopen(SESSION_FILE, "w"); -+ for (Client *c = selmon->clients; c != NULL; c = c->next) { // get all the clients with their tags and write them to the file -+ fprintf(fw, "%lu %u\n", c->win, c->tags); -+ } -+ fclose(fw); -+} -+ -+void -+restoreSession(void) -+{ -+ // restore session -+ FILE *fr = fopen(SESSION_FILE, "r"); -+ if (!fr) -+ return; -+ -+ char *str = malloc(23 * sizeof(char)); // allocate enough space for excepted input from text file -+ while (fscanf(fr, "%[^\n] ", str) != EOF) { // read file till the end -+ long unsigned int winId; -+ unsigned int tagsForWin; -+ int check = sscanf(str, "%lu %u", &winId, &tagsForWin); // get data -+ if (check != 2) // break loop if data wasn't read correctly -+ break; -+ -+ for (Client *c = selmon->clients; c ; c = c->next) { // add tags to every window by winId -+ if (c->win == winId) { -+ c->tags = tagsForWin; -+ break; -+ } -+ } -+ } -+ -+ for (Client *c = selmon->clients; c ; c = c->next) { // refocus on windows -+ focus(c); -+ restack(c->mon); -+ } -+ -+ for (Monitor *m = selmon; m; m = m->next) // rearrange all monitors -+ arrange(m); -+ -+ free(str); -+ fclose(fr); -+ -+ // delete a file -+ remove(SESSION_FILE); -+} -+ - void - quit(const Arg *arg) - { - if(arg->i) restart = 1; - running = 0; -+ -+ if (restart == 1) -+ saveSession(); - } - - Monitor * -@@ -2173,6 +2225,7 @@ main(int argc, char *argv[]) - die("pledge"); - #endif /* __OpenBSD__ */ - scan(); -+ restoreSession(); - run(); - if(restart) execvp(argv[0], argv); - cleanup(); --- -2.35.1 - -- cgit 1.4.1-2-gfad0