diff options
| -rw-r--r-- | PKGBUILD | 19 | ||||
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | config.def.h | 6 | ||||
| -rw-r--r-- | config.h | 5 | ||||
| -rw-r--r-- | dwm.c | 26 | ||||
| -rw-r--r-- | movestack.c | 49 | ||||
| -rw-r--r-- | patches/dwm-movestack-6.1.diff | 73 | ||||
| -rw-r--r-- | patches/dwm-r1615-selfrestart.diff | 101 | ||||
| -rw-r--r-- | patches/dwm-resizecorners-6.2.diff | 65 | ||||
| -rw-r--r-- | selfrestart.c | 65 |
10 files changed, 400 insertions, 12 deletions
@@ -11,23 +11,26 @@ depends=('libx11' 'libxinerama' 'libxft') provides=('dwm') conflicts=('dwm') source=( - 'config.h' 'config.mk' 'drw.c' 'drw.h' 'dwm.1' 'dwm.c' 'dwm.desktop' - 'dwm.png' 'LICENSE' 'Makefile' 'transient.c' 'util.c' 'util.h' + 'dwm.c' 'drw.c' 'drw.h' 'util.c' 'util.h' 'transient.c' + 'dwm.1' 'dwm.desktop' 'dwm.png' 'LICENSE' 'Makefile' 'config.mk' 'config.h' + 'movestack.c' 'selfrestart.c' ) md5sums=( - 'SKIP' - 'd61cf5e985e55bcb341977b5181ee24d' + '60fd1bd6bca80c5efa3cf30516a9c456' '37881ae1d06884f38b731b9103c9f373' '2170b6fe645068a2cad4be60d5ebbd84' + 'e1d877b57636568ba579b1bc0ae42e8f' + '007c065ca60e3f3c56bf153f2f769a90' + '1f002e4c3da39eed17c5581e8649daa1' '5074bde7dab8413cf187b1f9367220ff' - '9686e03383d58239dd19068a9a488b67' '939f403a71b6e85261d09fc3412269ee' 'b410e9a038520b0a117644dba003da62' 'd4af50c829a8dd3faf3699280a639c36' '13927472833ec86d00f6512f07f44af7' - '1f002e4c3da39eed17c5581e8649daa1' - 'e1d877b57636568ba579b1bc0ae42e8f' - '007c065ca60e3f3c56bf153f2f769a90' + 'd61cf5e985e55bcb341977b5181ee24d' + 'SKIP' + '32ba08c8322b4f3ff170c7476da7f4a2' + 'aada803e6a681e3e3b383ee860578ef3' ) build() { @@ -7,3 +7,6 @@ Installed patches: * [systray](https://dwm.suckless.org/patches/systray/) for simple system tray implementation * [tilegap](https://dwm.suckless.org/patches/tilegap/) for nice gaps between windows * [scratchpads](https://dwm.suckless.org/patches/scratchpads/) for scratchpads support +* [movestack](https://dwm.suckless.org/patches/movestack/) +* [resizecorners](https://dwm.suckless.org/patches/resizecorners/) +* [selfrestart](https://dwm.suckless.org/patches/selfrestart/) diff --git a/config.def.h b/config.def.h index cb9fbea..a3d0640 100644 --- a/config.def.h +++ b/config.def.h @@ -81,6 +81,8 @@ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, static const char *termcmd[] = { "st", NULL }; +#include "selfrestart.c" +#include "movestack.c" static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_p, spawn, {.v = dmenucmd } }, @@ -92,6 +94,8 @@ static Key keys[] = { { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, + { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, { MODKEY, XK_Return, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, { MODKEY|ShiftMask, XK_c, killclient, {0} }, @@ -119,6 +123,7 @@ static Key keys[] = { TAGKEYS( XK_7, 6) TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_r, self_restart, {0} }, { MODKEY|ShiftMask, XK_q, quit, {0} }, }; @@ -138,4 +143,3 @@ static Button buttons[] = { { ClkTagBar, MODKEY, Button1, tag, {0} }, { ClkTagBar, MODKEY, Button3, toggletag, {0} }, }; - @@ -83,6 +83,8 @@ static const char *dmenucmd[] = { static const char *termcmd[] = { "st", NULL }; #include <X11/XF86keysym.h> +#include "selfrestart.c" +#include "movestack.c" static Key keys[] = { /* modifier key function argument */ // These two shortcuts are handled by sxhkd @@ -95,6 +97,8 @@ static Key keys[] = { { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, + { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, // { MODKEY|ShiftMask, XK_Return, zoom, {0} }, // { MODKEY, XK_Tab, view, {0} }, { MODKEY, XK_q, killclient, {0} }, @@ -121,6 +125,7 @@ static Key keys[] = { TAGKEYS( XK_7, 6) TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_r, self_restart, {0} }, { MODKEY|ShiftMask, XK_e, quit, {0} }, }; @@ -1457,9 +1457,14 @@ void resizemouse(const Arg *arg) { int ocx, ocy, nw, nh; + int ocx2, ocy2, nx, ny; Client *c; Monitor *m; XEvent ev; + int horizcorner, vertcorner; + int di; + unsigned int dui; + Window dummy; Time lasttime = 0; if (!(c = selmon->sel)) @@ -1469,10 +1474,18 @@ resizemouse(const Arg *arg) restack(selmon); ocx = c->x; ocy = c->y; + ocx2 = c->x + c->w; + ocy2 = c->y + c->h; if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess) return; - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); + if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui)) + return; + horizcorner = nx < c->w / 2; + vertcorner = ny < c->h / 2; + XWarpPointer (dpy, None, c->win, 0, 0, 0, 0, + horizcorner ? (-c->bw) : (c->w + c->bw -1), + vertcorner ? (-c->bw) : (c->h + c->bw -1)); do { XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); switch(ev.type) { @@ -1488,6 +1501,11 @@ resizemouse(const Arg *arg) nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); + nx = horizcorner ? ev.xmotion.x : c->x; + ny = vertcorner ? ev.xmotion.y : c->y; + nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1); + nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1); + if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh) { @@ -1496,11 +1514,13 @@ resizemouse(const Arg *arg) togglefloating(NULL); } if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) - resize(c, c->x, c->y, nw, nh, 1); + resize(c, nx, ny, nw, nh, 1); break; } } while (ev.type != ButtonRelease); - XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, + horizcorner ? (-c->bw) : (c->w + c->bw - 1), + vertcorner ? (-c->bw) : (c->h + c->bw - 1)); XUngrabPointer(dpy, CurrentTime); while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { diff --git a/movestack.c b/movestack.c new file mode 100644 index 0000000..c040462 --- /dev/null +++ b/movestack.c @@ -0,0 +1,49 @@ +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); + } +} + diff --git a/patches/dwm-movestack-6.1.diff b/patches/dwm-movestack-6.1.diff new file mode 100644 index 0000000..a6c83fa --- /dev/null +++ b/patches/dwm-movestack-6.1.diff @@ -0,0 +1,73 @@ +diff -r 050d521d66d8 config.def.h +--- a/config.def.h Tue Aug 24 13:13:20 2010 +0100 ++++ b/config.def.h Sun Sep 05 18:43:07 2010 +0200 +@@ -57,6 +57,7 @@ + static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL }; + static const char *termcmd[] = { "st", NULL }; + ++#include "movestack.c" + static Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_p, spawn, {.v = dmenucmd } }, +@@ -68,6 +69,8 @@ + { MODKEY, XK_d, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, ++ { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, ++ { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, + { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, +diff -r 050d521d66d8 movestack.c +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/movestack.c Sun Sep 05 18:43:07 2010 +0200 +@@ -0,0 +1,49 @@ ++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); ++ } ++} ++ diff --git a/patches/dwm-r1615-selfrestart.diff b/patches/dwm-r1615-selfrestart.diff new file mode 100644 index 0000000..5d019b2 --- /dev/null +++ b/patches/dwm-r1615-selfrestart.diff @@ -0,0 +1,101 @@ +# HG changeset patch +# User Barbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com> +# Date 1354650884 -7200 +# Node ID 6c472a21a5887c5295a331c48c4da188ec2c8413 +# Parent aaab44133a6830c9a00263731d098c01cc1d6fb5 +selfrestart now magically locates the current dwm (no need to hardcode a path) + +diff -r aaab44133a68 -r 6c472a21a588 config.def.h +--- a/config.def.h Tue Dec 04 21:54:44 2012 +0200 ++++ b/config.def.h Tue Dec 04 21:54:44 2012 +0200 +@@ -54,6 +54,8 @@ + static const char *termcmd[] = { "urxvtc", NULL }; + static const char *filemancmd[] = { "thunar", NULL }; + ++#include "selfrestart.c" ++ + static Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_r, spawn, {.v = dmenucmd } }, +@@ -89,6 +91,7 @@ + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) ++ { MODKEY|ShiftMask, XK_r, self_restart, {0} }, + { MODKEY|ShiftMask, XK_q, quit, {0} }, + }; + +@@ -108,4 +111,3 @@ + { ClkTagBar, MODKEY, Button1, tag, {0} }, + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, + }; +- +diff -r aaab44133a68 -r 6c472a21a588 selfrestart.c +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/selfrestart.c Tue Dec 04 21:54:44 2012 +0200 +@@ -0,0 +1,65 @@ ++#include <unistd.h> ++#include <sys/types.h> ++#include <sys/stat.h> ++#include <stdio.h> ++#include <stdlib.h> ++ ++/** ++ * Magically finds the current's executable path ++ * ++ * I'm doing the do{}while(); trick because Linux (what I'm running) is not ++ * POSIX compilant and so lstat() cannot be trusted on /proc entries ++ * ++ * @return char* the path of the current executable ++ */ ++char *get_dwm_path(){ ++ struct stat s; ++ int r, length, rate = 42; ++ char *path = NULL; ++ ++ if(lstat("/proc/self/exe", &s) == -1){ ++ perror("lstat:"); ++ return NULL; ++ } ++ ++ length = s.st_size + 1 - rate; ++ ++ do{ ++ length+=rate; ++ ++ free(path); ++ path = malloc(sizeof(char) * length); ++ ++ if(path == NULL){ ++ perror("malloc:"); ++ return NULL; ++ } ++ ++ r = readlink("/proc/self/exe", path, length); ++ ++ if(r == -1){ ++ perror("readlink:"); ++ return NULL; ++ } ++ }while(r >= length); ++ ++ path[r] = '\0'; ++ ++ return path; ++} ++ ++/** ++ * self-restart ++ * ++ * Initially inspired by: Yu-Jie Lin ++ * https://sites.google.com/site/yjlnotes/notes/dwm ++ */ ++void self_restart(const Arg *arg) { ++ char *const argv[] = {get_dwm_path(), NULL}; ++ ++ if(argv[0] == NULL){ ++ return; ++ } ++ ++ execv(argv[0], argv); ++} diff --git a/patches/dwm-resizecorners-6.2.diff b/patches/dwm-resizecorners-6.2.diff new file mode 100644 index 0000000..72d50f6 --- /dev/null +++ b/patches/dwm-resizecorners-6.2.diff @@ -0,0 +1,65 @@ +--- a/dwm.c 2019-02-02 10:55:28.000000000 -0200 ++++ b/dwm.c 2020-06-11 20:09:16.786504007 -0300 +@@ -1291,9 +1291,14 @@ + resizemouse(const Arg *arg) + { + int ocx, ocy, nw, nh; ++ int ocx2, ocy2, nx, ny; + Client *c; + Monitor *m; + XEvent ev; ++ int horizcorner, vertcorner; ++ int di; ++ unsigned int dui; ++ Window dummy; + Time lasttime = 0; + + if (!(c = selmon->sel)) +@@ -1303,10 +1308,18 @@ + restack(selmon); + ocx = c->x; + ocy = c->y; ++ ocx2 = c->x + c->w; ++ ocy2 = c->y + c->h; + if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, + None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess) + return; +- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); ++ if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui)) ++ return; ++ horizcorner = nx < c->w / 2; ++ vertcorner = ny < c->h / 2; ++ XWarpPointer (dpy, None, c->win, 0, 0, 0, 0, ++ horizcorner ? (-c->bw) : (c->w + c->bw -1), ++ vertcorner ? (-c->bw) : (c->h + c->bw -1)); + do { + XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); + switch(ev.type) { +@@ -1322,6 +1335,11 @@ + + nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); + nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); ++ nx = horizcorner ? ev.xmotion.x : c->x; ++ ny = vertcorner ? ev.xmotion.y : c->y; ++ nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1); ++ nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1); ++ + if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww + && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh) + { +@@ -1330,11 +1348,13 @@ + togglefloating(NULL); + } + if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) +- resize(c, c->x, c->y, nw, nh, 1); ++ resize(c, nx, ny, nw, nh, 1); + break; + } + } while (ev.type != ButtonRelease); +- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); ++ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, ++ horizcorner ? (-c->bw) : (c->w + c->bw - 1), ++ vertcorner ? (-c->bw) : (c->h + c->bw - 1)); + XUngrabPointer(dpy, CurrentTime); + while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); + if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { diff --git a/selfrestart.c b/selfrestart.c new file mode 100644 index 0000000..d695d48 --- /dev/null +++ b/selfrestart.c @@ -0,0 +1,65 @@ +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <stdio.h> +#include <stdlib.h> + +/** + * Magically finds the current's executable path + * + * I'm doing the do{}while(); trick because Linux (what I'm running) is not + * POSIX compilant and so lstat() cannot be trusted on /proc entries + * + * @return char* the path of the current executable + */ +char *get_dwm_path(){ + struct stat s; + int r, length, rate = 42; + char *path = NULL; + + if(lstat("/proc/self/exe", &s) == -1){ + perror("lstat:"); + return NULL; + } + + length = s.st_size + 1 - rate; + + do{ + length+=rate; + + free(path); + path = malloc(sizeof(char) * length); + + if(path == NULL){ + perror("malloc:"); + return NULL; + } + + r = readlink("/proc/self/exe", path, length); + + if(r == -1){ + perror("readlink:"); + return NULL; + } + }while(r >= length); + + path[r] = '\0'; + + return path; +} + +/** + * self-restart + * + * Initially inspired by: Yu-Jie Lin + * https://sites.google.com/site/yjlnotes/notes/dwm + */ +void self_restart(const Arg *arg) { + char *const argv[] = {get_dwm_path(), NULL}; + + if(argv[0] == NULL){ + return; + } + + execv(argv[0], argv); +} |