summaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
authorSuleyman Farajli <suleyman@farajli.net>2024-08-17 13:39:03 +0400
committerSuleyman Farajli <suleyman@farajli.net>2024-08-17 13:39:03 +0400
commit2952485fce60f3be60b784bc665107609a48efc8 (patch)
tree2313ce2996533eccf51d0547c0c905d83e89b72c /dwm.c
parentacabd59afb742821f2d1ca535e3d4efce0632f20 (diff)
setborderpx patched and keybinds added
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/dwm.c b/dwm.c
index e843487..3f613e6 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 */
+ 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 };