diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2024-08-17 13:39:03 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2024-08-17 13:39:03 +0400 |
commit | 2952485fce60f3be60b784bc665107609a48efc8 (patch) | |
tree | 2313ce2996533eccf51d0547c0c905d83e89b72c | |
parent | acabd59afb742821f2d1ca535e3d4efce0632f20 (diff) |
setborderpx patched and keybinds added
-rw-r--r-- | config.h | 3 | ||||
-rw-r--r-- | dwm.c | 40 |
2 files changed, 42 insertions, 1 deletions
@@ -116,6 +116,9 @@ static const Key keys[] = { { 0 , XF86XK_AudioRaiseVolume, spawn , {.v = vol_up}}, { 0 , XF86XK_AudioMute, spawn , {.v = vol_toggle}}, + { MODKEY|ShiftMask, XK_minus, setborderpx, {.i = -1 } }, + { MODKEY|ShiftMask, XK_equal, setborderpx, {.i = +1 } }, + { Mod4Mask, XK_j, moveresize, {.v = (int []){ 0, 25, 0, 0 }}}, { Mod4Mask, XK_k, moveresize, {.v = (int []){ 0, -25, 0, 0 }}}, { Mod4Mask, XK_l, moveresize, {.v = (int []){ 25, 0, 0, 0 }}}, @@ -119,6 +119,7 @@ struct Monitor { int by; /* bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ + unsigned int borderpx; int gappx; /* gaps between windows */ unsigned int seltags; unsigned int sellt; @@ -198,6 +199,7 @@ static void run(void); static void scan(void); static int sendevent(Client *c, Atom proto); static void sendmon(Client *c, Monitor *m); +static void setborderpx(const Arg *arg); static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); @@ -663,6 +665,7 @@ createmon(void) m->nmaster = nmaster; m->showbar = showbar; m->topbar = topbar; + m->borderpx = borderpx; m->gappx = gappx; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; @@ -1073,7 +1076,8 @@ manage(Window w, XWindowAttributes *wa) c->y = c->mon->wy + c->mon->wh - HEIGHT(c); c->x = MAX(c->x, c->mon->wx); c->y = MAX(c->y, c->mon->wy); - c->bw = borderpx; + c->bw = c->mon->borderpx; + selmon->tagset[selmon->seltags] &= ~scratchtag; if (!strcmp(c->name, scratchpadname)) { @@ -1441,6 +1445,40 @@ sendmon(Client *c, Monitor *m) } void +setborderpx(const Arg *arg) +{ + Client *c; + int prev_borderpx = selmon->borderpx; + + if (arg->i == 0) + selmon->borderpx = borderpx; + else if (selmon->borderpx + arg->i < 0) + selmon->borderpx = 0; + else + selmon->borderpx += arg->i; + + for (c = selmon->clients; c; c = c->next) + { + if (c->bw + arg->i < 0) + c->bw = selmon->borderpx = 0; + else + c->bw = selmon->borderpx; + if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) + { + if (arg->i != 0 && prev_borderpx + arg->i >= 0) + resize(c, c->x, c->y, c->w-(arg->i*2), c->h-(arg->i*2), 0); + else if (arg->i != 0) + resizeclient(c, c->x, c->y, c->w, c->h); + else if (prev_borderpx > borderpx) + resize(c, c->x, c->y, c->w + 2*(prev_borderpx - borderpx), c->h + 2*(prev_borderpx - borderpx), 0); + else if (prev_borderpx < borderpx) + resize(c, c->x, c->y, c->w-2*(borderpx - prev_borderpx), c->h-2*(borderpx - prev_borderpx), 0); + } + } + arrange(selmon); +} + +void setclientstate(Client *c, long state) { long data[] = { state, None }; |