1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
From ce0eb92fb100801f343fbe9b76639847a9e39160 Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Fri, 5 Jul 2024 11:22:57 -0500
Subject: [PATCH] implement minimalborders
---
config.def.h | 1 +
dwl.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 72 insertions(+), 6 deletions(-)
diff --git a/config.def.h b/config.def.h
index 22d2171..0322dbf 100644
--- a/config.def.h
+++ b/config.def.h
@@ -7,6 +7,7 @@
static const int sloppyfocus = 1; /* focus follows mouse */
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
static const unsigned int borderpx = 1; /* border pixel of windows */
+static const int draw_minimal_borders = 1; /* merge adjacent borders */
static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
diff --git a/dwl.c b/dwl.c
index dc0437e..198061b 100644
--- a/dwl.c
+++ b/dwl.c
@@ -106,6 +106,7 @@ typedef struct Monitor Monitor;
typedef struct {
/* Must keep these three elements in this order */
unsigned int type; /* XDGShell or X11* */
+ int interact;
struct wlr_box geom; /* layout-relative, includes border */
Monitor *mon;
struct wlr_scene_tree *scene;
@@ -316,7 +317,8 @@ static void rendermon(struct wl_listener *listener, void *data);
static void requestdecorationmode(struct wl_listener *listener, void *data);
static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(struct wl_listener *listener, void *data);
-static void resize(Client *c, struct wlr_box geo, int interact);
+static void resizeapply(Client *c, struct wlr_box geo, int interact);
+static void resizenoapply(Client *c, struct wlr_box geo, int interact);
static void run(char *startup_cmd);
static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data);
@@ -408,6 +410,8 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static void (*resize)(Client *c, struct wlr_box geo, int interact) = resizeapply;
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -476,6 +480,35 @@ applyrules(Client *c)
setmon(c, mon, newtags);
}
+void
+applyminimalborders(Client *c, Monitor *m)
+{
+ struct wlr_box geom = c->geom;
+
+ geom.x -= borderpx;
+ geom.width += borderpx;
+ geom.y -= borderpx;
+ geom.height += borderpx;
+
+ if (geom.x < m->w.x) {
+ geom.x += borderpx;
+ geom.width -= borderpx;
+ }
+ if (geom.x + geom.width > m->w.width - (int)borderpx) {
+ geom.width -= borderpx;
+ }
+
+ if (geom.y < m->w.y) {
+ geom.y += borderpx;
+ geom.height -= borderpx;
+ }
+ if (geom.y + geom.height > m->w.height - (int)borderpx) {
+ geom.height -= borderpx;
+ }
+
+ resize(c, geom, 0);
+}
+
void
arrange(Monitor *m)
{
@@ -510,8 +543,28 @@ arrange(Monitor *m)
: c->scene->node.parent);
}
- if (m->lt[m->sellt]->arrange)
- m->lt[m->sellt]->arrange(m);
+ if (m->lt[m->sellt]->arrange) {
+ if (draw_minimal_borders) {
+ int save_width = m->w.width;
+ int save_height = m->w.height;
+ m->w.width += borderpx;
+ m->w.height += borderpx;
+ resize = resizenoapply;
+ m->lt[m->sellt]->arrange(m);
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+ if (draw_minimal_borders)
+ applyminimalborders(c, m);
+ resizeapply(c, c->geom, c->interact);
+ }
+ m->w.width = save_width;
+ m->w.height = save_height;
+ resize = resizeapply;
+ } else {
+ m->lt[m->sellt]->arrange(m);
+ }
+ }
motionnotify(0, NULL, 0, 0, 0, 0);
checkidleinhibitor(NULL);
}
@@ -1962,8 +2015,13 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
struct timespec now;
if (surface != seat->pointer_state.focused_surface &&
- sloppyfocus && time && c && !client_is_unmanaged(c))
- focusclient(c, 0);
+ sloppyfocus && time && c && !client_is_unmanaged(c)) {
+ if (c->isfloating || c->isfullscreen) {
+ focusclient(c, 0);
+ } else {
+ focusclient(c, 1);
+ }
+ }
/* If surface is NULL, clear pointer focus */
if (!surface) {
@@ -2128,7 +2186,7 @@ requestmonstate(struct wl_listener *listener, void *data)
}
void
-resize(Client *c, struct wlr_box geo, int interact)
+resizeapply(Client *c, struct wlr_box geo, int interact)
{
struct wlr_box *bbox;
struct wlr_box clip;
@@ -2160,6 +2218,13 @@ resize(Client *c, struct wlr_box geo, int interact)
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
}
+void
+resizenoapply(Client *c, struct wlr_box geo, int interact)
+{
+ c->geom = geo;
+ c->interact = interact;
+}
+
void
run(char *startup_cmd)
{
--
2.45.1
|