dwm-unfocusednoborders-floating-6.5.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-unfocusednoborders-floating-6.5.diff (3311B)
---
1 From ccf3a9fa8391deabc463db6cd3846794828111d6 Mon Sep 17 00:00:00 2001
2 From: Jakub Skowron <jakubskowron676@gmail.com>
3 Date: Thu, 26 Jun 2025 21:00:08 +0200
4 Subject: [PATCH] remove/add borders around floating windows
5
6 ---
7 dwm.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
8 1 file changed, 50 insertions(+), 9 deletions(-)
9
10 diff --git a/dwm.c b/dwm.c
11 index 7b2bc88..8377d2b 100644
12 --- a/dwm.c
13 +++ b/dwm.c
14 @@ -141,6 +141,7 @@ typedef struct {
15 } Rule;
16
17 /* function declarations */
18 +static void addborders(Client *c);
19 static void applyrules(Client *c);
20 static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
21 static void arrange(Monitor *m);
22 @@ -188,6 +189,7 @@ static void pop(Client *c);
23 static void propertynotify(XEvent *e);
24 static void quit(const Arg *arg);
25 static Monitor *recttomon(int x, int y, int w, int h);
26 +static void removeborders(Client *c);
27 static void resize(Client *c, int x, int y, int w, int h, int interact);
28 static void resizeclient(Client *c, int x, int y, int w, int h);
29 static void resizemouse(const Arg *arg);
30 @@ -274,6 +276,30 @@ static Window root, wmcheckwin;
31 struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
32
33 /* function implementations */
34 +void
35 +addborders(Client *c)
36 +{
37 + if (!c->isfullscreen && (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL)) {
38 + XWindowChanges wc;
39 +
40 + wc.width = c->oldw;
41 + wc.height = c->oldh;
42 + wc.border_width = borderpx;
43 +
44 + c->w = wc.width += c->bw * 2;
45 + c->h = wc.height += c->bw * 2;
46 +
47 + XConfigureWindow(dpy, c->win, CWWidth | CWHeight | CWBorderWidth, &wc);
48 + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
49 + configure(c);
50 + XSync(dpy, False);
51 + } else {
52 + c->bw = borderpx;
53 + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
54 + arrange(c->mon);
55 + }
56 +}
57 +
58 void
59 applyrules(Client *c)
60 {
61 @@ -800,11 +826,7 @@ focus(Client *c)
62 detachstack(c);
63 attachstack(c);
64 grabbuttons(c, 1);
65 -
66 - c->bw = borderpx;
67 - XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
68 - arrange(c->mon);
69 -
70 + addborders(c);
71 setfocus(c);
72 } else {
73 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
74 @@ -1278,6 +1300,28 @@ recttomon(int x, int y, int w, int h)
75 return r;
76 }
77
78 +void
79 +removeborders(Client *c)
80 +{
81 + if (!c->isfullscreen && (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL)) {
82 + XWindowChanges wc;
83 +
84 + wc.width = c->w;
85 + wc.height = c->h;
86 + wc.border_width = 0;
87 +
88 + c->w = wc.width += c->bw * 2;
89 + c->h = wc.height += c->bw * 2;
90 +
91 + XConfigureWindow(dpy, c->win, CWWidth | CWHeight | CWBorderWidth, &wc);
92 + configure(c);
93 + XSync(dpy, False);
94 + } else {
95 + c->bw = 0;
96 + arrange(c->mon);
97 + }
98 +}
99 +
100 void
101 resize(Client *c, int x, int y, int w, int h, int interact)
102 {
103 @@ -1771,10 +1815,7 @@ unfocus(Client *c, int setfocus)
104 if (!c)
105 return;
106 grabbuttons(c, 0);
107 -
108 - c->bw = 0;
109 - arrange(c->mon);
110 -
111 + removeborders(c);
112 if (setfocus) {
113 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
114 XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
115 --
116 2.50.0
117