aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-11-11 15:55:15 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-11-11 15:55:15 +0100
commit6ae365f99616dfe1084e6b70c78fe790e1bec038 (patch)
treea89a0d87733f5b428bf1d0cabcb112aa122e506f
parentRemoved swallow patch (diff)
downloaddwm-6ae365f99616dfe1084e6b70c78fe790e1bec038.tar.gz
dwm-6ae365f99616dfe1084e6b70c78fe790e1bec038.tar.bz2
dwm-6ae365f99616dfe1084e6b70c78fe790e1bec038.tar.xz
dwm-6ae365f99616dfe1084e6b70c78fe790e1bec038.tar.zst
dwm-6ae365f99616dfe1084e6b70c78fe790e1bec038.zip
Added patches nmaster and tagothermon
Diffstat (limited to '')
-rw-r--r--README56
-rw-r--r--README.org4
-rw-r--r--config.h30
-rw-r--r--dwm.c100
-rw-r--r--nmaster.c122
5 files changed, 244 insertions, 68 deletions
diff --git a/README b/README
index a679513..383235a 100644
--- a/README
+++ b/README
@@ -31,37 +31,39 @@ To use it as a default WM, if you are using xinit, add this to your .xinitrc:
Bindings
--------
Some of the main key bindings:
-- switch to workspace 1-12 with super+{F1-F12}
-- move selected stack to workspace 1-12 with super+shift+{F1-F12}
-- fire up st terminal with super+return
-- kill selected stack with super+q
-- cycle through stacks down/up with super+j/k
-- move selected stack down/up with super+shift+j/k
-- resize master stack to left/right with super+h/l
-- invoke dmenu_run application launcher with super+p
-- toggle better tiled mode with super+s
-- toggle alternative tiled mode with super+shift+s
-- toggle normal tiled mode with super+t
-- toggle fullscreen mode on selected stack with super+f
-- toggle floating mode on selected stack with super+space
-- toggle top bar with super+b. Hidden by default
-- restart dwm with super+shift+r
-- exit dwm with super+shift+e
+ - switch to workspace 1-12 with super+{F1-F12}
+ - move selected stack to workspace 1-12 with super+shift+{F1-F12}
+ - fire up st terminal with super+return
+ - kill selected stack with super+q
+ - cycle through stacks down/up with super+j/k
+ - move selected stack down/up with super+shift+j/k
+ - resize master stack to left/right with super+h/l
+ - invoke dmenu_run application launcher with super+p
+ - toggle better tiled mode with super+s
+ - toggle alternative tiled mode with super+shift+s
+ - toggle normal tiled mode with super+t
+ - toggle fullscreen mode on selected stack with super+f
+ - toggle floating mode on selected stack with super+space
+ - toggle top bar with super+b. Hidden by default
+ - restart dwm with super+shift+r
+ - exit dwm with super+shift+e
Patches
-------
List of patches in use:
-- actualfullscreen
-- alwayscenter
-- attachaside
-- cool-autostart
-- fibonacci
-- focusonclick
-- moveresize
-- movestack
-- noborder
-- pertag
-- restartsig
+ - actualfullscreen
+ - alwayscenter
+ - attachasideandbelow
+ - cool-autostart
+ - fibonacci
+ - focusonclick
+ - nmaster
+ - moveresize
+ - movestack
+ - noborder
+ - pertag
+ - restartsig
+ - tagothermon
My own autostart script can be found under my dotfiles-bsd repository:
https://git.jozanleclerc.xyz/jozan/dotfiles-bsd/files.html
diff --git a/README.org b/README.org
index 3a39ff3..67a92a8 100644
--- a/README.org
+++ b/README.org
@@ -50,15 +50,17 @@ Some of the main key bindings:
List of patches in use:
- /actualfullscreen/
- /alwayscenter/
-- /attachaside/
+- /attachasideandbelow/
- /cool-autostart/
- /fibonacci/
- /focusonclick/
+- /nmaster/
- /moveresize/
- /movestack/
- /noborder/
- /pertag/
- /restartsig/
+- /tagothermon/
My own autostart script can be found under my
[[https://git.jozanleclerc.xyz/jozan/dotfiles-bsd/files.html][dotfiles-bsd]] repository. It should
diff --git a/config.h b/config.h
index 1e3c4c4..21afd10 100644
--- a/config.h
+++ b/config.h
@@ -46,12 +46,16 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95]
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */
+#include "nmaster.c"
#include "fibonacci.c"
+
static const Layout layouts[] = {
/* symbol arrange function */
{ "[\\]", dwindle },
{ "[@]", spiral },
{ "[]=", tile }, /* first entry is default */
+ { "-|=", ntile },
+ { "-|-", nbstack },
{ "[M]", monocle },
{ "><>", NULL }, /* no layout function means floating behavior */
};
@@ -59,10 +63,12 @@ static const Layout layouts[] = {
/* key definitions */
#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
- { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
- { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
- { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
+ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
+ { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
+ { MODKEY|ControlMask, KEY, tagnextmon, {.ui = 1 << TAG} }, \
+ { MODKEY|ControlMask|ShiftMask, KEY, tagprevmon, {.ui = 1 << TAG} },
+ /* { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ */
+ /* { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, \ */
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/usr/local/bin/dash", "-c", cmd, NULL } }
@@ -103,8 +109,8 @@ static Key keys[] = {
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
- { MODKEY, XK_i, incnmaster, {.i = +1 } },
- { MODKEY, XK_d, incnmaster, {.i = -1 } },
+ { MODKEY, XK_a, incnmaster, {.i = +1 } },
+ { MODKEY, XK_x, incnmaster, {.i = -1 } },
{ MODKEY|ShiftMask, XK_h, setmfact, {.f = -0.025} },
{ MODKEY|ShiftMask, XK_l, setmfact, {.f = +0.025} },
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
@@ -112,11 +118,13 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY, XK_q, killclient, {0} },
- { MODKEY, XK_s, setlayout, {.v = &layouts[0]} },
- { MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[1]} },
- { MODKEY, XK_t, setlayout, {.v = &layouts[2]} },
- { MODKEY, XK_m, setlayout, {.v = &layouts[3]} },
- { MODKEY, XK_n, setlayout, {.v = &layouts[4]} },
+ { MODKEY, XK_s, setlayout, {.v = &layouts[0]} }, /* dwindle */
+ { MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[1]} }, /* spiral */
+ { MODKEY, XK_v, setlayout, {.v = &layouts[2]} }, /* tile */
+ { MODKEY, XK_t, setlayout, {.v = &layouts[3]} }, /* nbtile */
+ { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[4]} }, /* nbstack */
+ { MODKEY, XK_m, setlayout, {.v = &layouts[5]} }, /* monocle */
+ { MODKEY, XK_n, setlayout, {.v = &layouts[6]} }, /* floating */
{ MODKEY|ShiftMask, XK_space, setlayout, {0} },
{ MODKEY, XK_space, togglefloating, {0} },
{ MODKEY, XK_f, togglefullscr, {0} },
diff --git a/dwm.c b/dwm.c
index cea59a3..f623f20 100644
--- a/dwm.c
+++ b/dwm.c
@@ -150,7 +150,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
static void arrange(Monitor *m);
static void arrangemon(Monitor *m);
static void attach(Client *c);
-static void attachaside(Client *c);
+static void attachBelow(Client *c);
static void attachstack(Client *c);
static void buttonpress(XEvent *e);
static void checkotherwm(void);
@@ -216,6 +216,9 @@ static void sigterm(int unused);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
+static void tagnextmon(const Arg *arg);
+static void tagprevmon(const Arg *arg);
+static void tagothermon(const Arg *arg, int dir);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
@@ -450,18 +453,27 @@ attach(Client *c)
c->next = c->mon->clients;
c->mon->clients = c;
}
-
void
-attachaside(Client *c) {
- Client *at = nexttagged(c);
- if(!at) {
- attach(c);
+attachBelow(Client *c)
+{
+ //If there is nothing on the monitor or the selected client is floating, attach as normal
+ if(c->mon->sel == NULL || c->mon->sel->isfloating) {
+ Client *at = nexttagged(c);
+ if(!at) {
+ attach(c);
+ return;
+ }
+ c->next = at->next;
+ at->next = c;
return;
- }
- c->next = at->next;
- at->next = c;
-}
+ }
+
+ //Set the new client's next property to the same as the currently selected clients next
+ c->next = c->mon->sel->next;
+ //Set the currently selected clients next property to the new client
+ c->mon->sel->next = c;
+}
void
attachstack(Client *c)
@@ -1018,12 +1030,12 @@ grabkeys(void)
}
}
-void
-incnmaster(const Arg *arg)
-{
- selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
- arrange(selmon);
-}
+/* void */
+/* incnmaster(const Arg *arg) */
+/* { */
+/* selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0); */
+/* arrange(selmon); */
+/* } */
#ifdef XINERAMA
static int
@@ -1119,7 +1131,7 @@ manage(Window w, XWindowAttributes *wa)
c->isfloating = c->oldstate = trans != None || c->isfixed;
if (c->isfloating)
XRaiseWindow(dpy, c->win);
- attachaside(c);
+ attachBelow(c);
attachstack(c);
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
(unsigned char *) &(c->win), 1);
@@ -1232,16 +1244,6 @@ movemouse(const Arg *arg)
}
}
- Client *
-nexttagged(Client *c) {
- Client *walked = c->mon->clients;
- for(;
- walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags));
- walked = walked->next
- );
- return walked;
-}
-
void
moveresize(const Arg *arg) {
/* only floating windows can be moved */
@@ -1389,6 +1391,16 @@ moveresizeedge(const Arg *arg) {
}
}
+ Client *
+nexttagged(Client *c) {
+ Client *walked = c->mon->clients;
+ for(;
+ walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags));
+ walked = walked->next
+ );
+ return walked;
+}
+
Client *
nexttiled(Client *c)
{
@@ -1632,7 +1644,7 @@ sendmon(Client *c, Monitor *m)
detachstack(c);
c->mon = m;
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
- attachaside(c);
+ attachBelow(c);
attachstack(c);
focus(NULL);
arrange(NULL);
@@ -1922,6 +1934,36 @@ tagmon(const Arg *arg)
}
void
+tagnextmon(const Arg *arg)
+{
+ tagothermon(arg, 1);
+}
+
+void
+tagprevmon(const Arg *arg)
+{
+ tagothermon(arg, -1);
+}
+
+void
+tagothermon(const Arg *arg, int dir)
+{
+ Client *sel;
+ Monitor *newmon;
+
+ if (!selmon->sel || !mons->next)
+ return;
+ sel = selmon->sel;
+ newmon = dirtomon(dir);
+ sendmon(sel, newmon);
+ if (arg->ui & TAGMASK) {
+ sel->tags = arg->ui & TAGMASK;
+ focus(NULL);
+ arrange(newmon);
+ }
+}
+
+void
tile(Monitor *m)
{
unsigned int i, n, h, mw, my, ty;
@@ -2176,7 +2218,7 @@ updategeom(void)
detachstack(c);
c->mon = mons;
attach(c);
- attachaside(c);
+ attachBelow(c);
attachstack(c);
}
if (m == selmon)
diff --git a/nmaster.c b/nmaster.c
new file mode 100644
index 0000000..10bfed1
--- /dev/null
+++ b/nmaster.c
@@ -0,0 +1,122 @@
+enum {MaxMon = 8};
+static int nmasters[MaxMon];
+static int initnm = 0;
+
+static void
+initnmaster(void) {
+ int i;
+
+ if(initnm)
+ return;
+ for(i = 0; i < MaxMon; i++)
+ nmasters[i] = nmaster;
+ initnm = 1;
+}
+
+static void
+incnmaster(const Arg *arg) {
+ if(!arg || !selmon->lt[selmon->sellt]->arrange || selmon->num >= MaxMon)
+ return;
+ nmasters[selmon->num] += arg->i;
+ if(nmasters[selmon->num] < 0)
+ nmasters[selmon->num] = 0;
+ arrange(selmon);
+}
+
+/* static void */
+/* setnmaster(const Arg *arg) { */
+/* if(!arg || !selmon->lt[selmon->sellt]->arrange || selmon->num >= MaxMon) */
+/* return; */
+/* nmasters[selmon->num] = arg->i > 0 ? arg->i : 0; */
+/* arrange(selmon); */
+/* } */
+
+static void
+ntile(Monitor *m) {
+ int x, y, h, w, mw, nm;
+ unsigned int i, n;
+ Client *c;
+
+ initnmaster();
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ c = nexttiled(m->clients);
+ nm = m->num < MaxMon ? nmasters[m->num] : nmaster;
+ if(nm > n)
+ nm = n;
+ /* master */
+ if(nm > 0) {
+ mw = m->mfact * m->ww;
+ h = m->wh / nm;
+ if(h < bh)
+ h = m->wh;
+ y = m->wy;
+ for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
+ resize(c, m->wx, y, (n == nm ? m->ww : mw) - 2 * c->bw,
+ ((i + 1 == nm) ? m->wy + m->wh - y : h) - 2 * c->bw, False);
+ if(h != m->wh)
+ y = c->y + HEIGHT(c);
+ }
+ n -= nm;
+ } else
+ mw = 0;
+ if(n == 0)
+ return;
+ /* tile stack */
+ x = m->wx + mw;
+ y = m->wy;
+ w = m->ww - mw;
+ h = m->wh / n;
+ if(h < bh)
+ h = m->wh;
+ for(i = 0; c; c = nexttiled(c->next), i++) {
+ resize(c, x, y, w - 2 * c->bw,
+ ((i + 1 == n) ? m->wy + m->wh - y : h) - 2 * c->bw, False);
+ if(h != m->wh)
+ y = c->y + HEIGHT(c);
+ }
+}
+
+static void
+nbstack(Monitor *m) {
+ int x, y, h, w, mh, nm;
+ unsigned int i, n;
+ Client *c;
+
+ initnmaster();
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ c = nexttiled(m->clients);
+ nm = m->num < MaxMon ? nmasters[m->num] : nmaster;
+ if(nm > n)
+ nm = n;
+ /* master */
+ if(nm > 0) {
+ mh = m->mfact * m->wh;
+ w = m->ww / nm;
+ if(w < bh)
+ w = m->ww;
+ x = m->wx;
+ for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
+ resize(c, x, m->wy, ((i + 1 == nm) ? m->wx + m->ww - x : w) - 2 * c->bw,
+ (n == nm ? m->wh : mh) - 2 * c->bw, False);
+ if(w != m->ww)
+ x = c->x + WIDTH(c);
+ }
+ n -= nm;
+ } else
+ mh = 0;
+ if(n == 0)
+ return;
+ /* tile stack */
+ x = m->wx;
+ y = m->wy + mh;
+ w = m->ww / n;
+ h = m->wh - mh;
+ if(w < bh)
+ w = m->ww;
+ for(i = 0; c; c = nexttiled(c->next), i++) {
+ resize(c, x, y, ((i + 1 == n) ? m->wx + m->ww - x : w) - 2 * c->bw,
+ h - 2 * c->bw, False);
+ if(w != m->ww)
+ x = c->x + WIDTH(c);
+ }
+}