dwm

[fork] dynamic window manager
Log | Files | Refs | README | LICENSE

commit 27628f828f6df61a35aee214ad05202264f7e224
parent 384317e87e9c0f3676bec5af5e916de3765eb5c3
Author: Hayden Hamilton <hayden@haydenvh.com>
Date:   Mon,  2 Mar 2020 17:10:54 +0000

fixed fibonacci layouts

Diffstat:
Mconfig.h | 1-
Mdwm.c | 85+++++++++++++++++--------------------------------------------------------------
2 files changed, 18 insertions(+), 68 deletions(-)

diff --git a/config.h b/config.h @@ -108,7 +108,6 @@ static Key keys[] = { { MODKEY, XK_q, killclient, {0} }, { MODKEY|ShiftMask, XK_q, quit, {0} }, { MODKEY|ControlMask, XK_q, spawn, {.v = rfeh_left } }, - { MODKEY|ShiftMask, XK_r, self_restart, {0} }, { MODKEY, XK_s, spawn, {.v = dpass_ } }, { MODKEY|ShiftMask, XK_s, spawn, {.v = maim_ } }, { MODKEY, XK_w, spawn, {.v = rfeh_ } }, diff --git a/dwm.c b/dwm.c @@ -246,8 +246,6 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); static void centeredmaster(Monitor *m); static void centeredfloatingmaster(Monitor *m); -static void self_restart(const Arg *arg); -static char *get_dwm_path(void); static void spiral(Monitor *mon); static void dwindle(Monitor *mon); static void fibonacci(Monitor *mon, int s); @@ -2139,7 +2137,7 @@ fibonacci(Monitor *mon, int s) { nx = mon->wx; ny = 0; nw = mon->ww; - nh = mon->wh; + nh = mon->wh - gappx; for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) { if((i % 2 && nh / 2 > 2 * c->bw) @@ -2177,10 +2175,10 @@ fibonacci(Monitor *mon, int s) { ny = mon->wy; } else if(i == 1) - nw = mon->ww - nw; + nw = mon->ww - nw - gappx; i++; } - resize(c, nx + mon->gappx, ny + mon->gappx, nw - (2 * c->bw) - 2*mon->gappx, nh - 2*c->bw - 2*mon->gappx, False); + resize(c, nx + mon->gappx, ny + mon->gappx, nw - (2 * c->bw) - mon->gappx, nh - 2*c->bw - mon->gappx, False); } } @@ -2194,54 +2192,6 @@ spiral(Monitor *mon) { fibonacci(mon, 0); } -static char -*get_dwm_path(void){ - 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; -} - -static void -self_restart(const Arg *arg) { - char *const argv[] = {get_dwm_path(), NULL}; - - if(argv[0] == NULL){ - return; - } - - execv(argv[0], argv); -} - void centeredmaster(Monitor *m) { @@ -2278,20 +2228,20 @@ centeredmaster(Monitor *m) /* nmaster clients are stacked vertically, in the center * of the screen */ h = (m->wh - my) / (MIN(n, m->nmaster) - i); - resize(c, m->wx + mx, m->wy + my, mw - (2*c->bw), - h - (2*c->bw), 0); + resize(c, m->wx + mx + gappx, m->wy + my + gappx, (mw - (2*c->bw)) - 2*gappx, + (h - (2*c->bw)) - 2*gappx, 0); my += HEIGHT(c); } else { /* stack clients are stacked vertically */ if ((i - m->nmaster) % 2 ) { h = (m->wh - ety) / ( (1 + n - i) / 2); - resize(c, m->wx, m->wy + ety, tw - (2*c->bw), - h - (2*c->bw), 0); + resize(c, m->wx + gappx, m->wy + ety + gappx, tw - (2*c->bw) - gappx, + (h - (2*c->bw)) - 2*gappx, 0); ety += HEIGHT(c); } else { h = (m->wh - oty) / ((1 + n - i) / 2); - resize(c, m->wx + mx + mw, m->wy + oty, - tw - (2*c->bw), h - (2*c->bw), 0); + resize(c, m->wx + mx + mw, m->wy + oty + gappx, + tw - (2*c->bw) - gappx, (h - (2*c->bw)) - 2*gappx, 0); oty += HEIGHT(c); } } @@ -2322,10 +2272,10 @@ centeredfloatingmaster(Monitor *m) my = myo = (m->wh - mh) / 2; } else { /* go fullscreen if all clients are in the master area */ - mh = m->wh; - mw = m->ww; - mx = mxo = 0; - my = myo = 0; + mh = m->wh - 2*gappx; + mw = m->ww - 2*gappx; + mx = mxo = 0 + gappx; + my = myo = 0 + gappx; } for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) @@ -2335,12 +2285,13 @@ centeredfloatingmaster(Monitor *m) w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i); resize(c, m->wx + mx, m->wy + my, w - (2*c->bw), mh - (2*c->bw), 0); - mx += WIDTH(c); + mx += WIDTH(c) + gappx; } else { /* stack clients are stacked horizontally */ w = (m->ww - tx) / (n - i); - resize(c, m->wx + tx, m->wy, w - (2*c->bw), - m->wh - (2*c->bw), 0); - tx += WIDTH(c); + resize(c, m->wx + tx + gappx, m->wy + gappx, w - (2*c->bw) - 2*gappx, + m->wh - (2*c->bw) - 2*gappx, 0); + tx += WIDTH(c) + gappx; } + /* XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, PropModeReplace, (unsigned char *)&netatom[NetWMFullscreen], 1); */ }