dwm-setborderpx-6.2.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-setborderpx-6.2.diff (3359B)
---
1 diff -up a/config.def.h b/config.def.h
2 --- a/config.def.h 2020-05-12 02:17:20.070933833 +0200
3 +++ b/config.def.h 2020-05-13 03:27:51.018695798 +0200
4 @@ -84,6 +84,9 @@ static Key keys[] = {
5 { MODKEY, XK_period, focusmon, {.i = +1 } },
6 { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
7 { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
8 + { MODKEY|ShiftMask, XK_minus, setborderpx, {.i = -1 } },
9 + { MODKEY|ShiftMask, XK_plus, setborderpx, {.i = +1 } },
10 + { MODKEY|ShiftMask, XK_numbersign, setborderpx, {.i = 0 } },
11 TAGKEYS( XK_1, 0)
12 TAGKEYS( XK_2, 1)
13 TAGKEYS( XK_3, 2)
14 diff -up a/dwm.c b/dwm.c
15 --- a/dwm.c 2020-05-12 02:17:20.070933833 +0200
16 +++ b/dwm.c 2020-05-14 00:17:35.047919771 +0200
17 @@ -119,6 +119,7 @@ struct Monitor {
18 int by; /* bar geometry */
19 int mx, my, mw, mh; /* screen size */
20 int wx, wy, ww, wh; /* window area */
21 + unsigned int borderpx;
22 unsigned int seltags;
23 unsigned int sellt;
24 unsigned int tagset[2];
25 @@ -196,6 +197,7 @@ static void run(void);
26 static void scan(void);
27 static int sendevent(Client *c, Atom proto);
28 static void sendmon(Client *c, Monitor *m);
29 +static void setborderpx(const Arg *arg);
30 static void setclientstate(Client *c, long state);
31 static void setfocus(Client *c);
32 static void setfullscreen(Client *c, int fullscreen);
33 @@ -638,6 +640,7 @@ createmon(void)
34 m->nmaster = nmaster;
35 m->showbar = showbar;
36 m->topbar = topbar;
37 + m->borderpx = borderpx;
38 m->lt[0] = &layouts[0];
39 m->lt[1] = &layouts[1 % LENGTH(layouts)];
40 strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
41 @@ -1047,7 +1050,7 @@ manage(Window w, XWindowAttributes *wa)
42 /* only fix client y-offset, if the client center might cover the bar */
43 c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx)
44 && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
45 - c->bw = borderpx;
46 + c->bw = c->mon->borderpx;
47
48 wc.border_width = c->bw;
49 XConfigureWindow(dpy, w, CWBorderWidth, &wc);
50 @@ -1424,6 +1427,40 @@ sendmon(Client *c, Monitor *m)
51 }
52
53 void
54 +setborderpx(const Arg *arg)
55 +{
56 + Client *c;
57 + int prev_borderpx = selmon->borderpx;
58 +
59 + if (arg->i == 0)
60 + selmon->borderpx = borderpx;
61 + else if (selmon->borderpx + arg->i < 0)
62 + selmon->borderpx = 0;
63 + else
64 + selmon->borderpx += arg->i;
65 +
66 + for (c = selmon->clients; c; c = c->next)
67 + {
68 + if (c->bw + arg->i < 0)
69 + c->bw = selmon->borderpx = 0;
70 + else
71 + c->bw = selmon->borderpx;
72 + if (c->isfloating || !selmon->lt[selmon->sellt]->arrange)
73 + {
74 + if (arg->i != 0 && prev_borderpx + arg->i >= 0)
75 + resize(c, c->x, c->y, c->w-(arg->i*2), c->h-(arg->i*2), 0);
76 + else if (arg->i != 0)
77 + resizeclient(c, c->x, c->y, c->w, c->h);
78 + else if (prev_borderpx > borderpx)
79 + resize(c, c->x, c->y, c->w + 2*(prev_borderpx - borderpx), c->h + 2*(prev_borderpx - borderpx), 0);
80 + else if (prev_borderpx < borderpx)
81 + resize(c, c->x, c->y, c->w-2*(borderpx - prev_borderpx), c->h-2*(borderpx - prev_borderpx), 0);
82 + }
83 + }
84 + arrange(selmon);
85 +}
86 +
87 +void
88 setclientstate(Client *c, long state)
89 {
90 long data[] = { state, None };