dwl-patches overhaul

Eliminated wiki.
Individual patches have a README.md explanation in their own subdirectory.
Simplified submission of new patches and maintenance of existing patches.
Instructions page (README.md autodisplayed) is now at https://codeberg.org/dwl/dwl-patches/
This commit is contained in:
A Frederick Christensen
2024-04-24 20:20:07 -05:00
parent d6b051f5b8
commit 9c5d5d85f3
183 changed files with 1434 additions and 4 deletions
+33
View File
@@ -0,0 +1,33 @@
### Description
Dynamically adjusts the borders between adjacent windows to make them visually merge
**NOTE:** to disable minimalborders after applying this patch, set `draw_minimal_borders` to `0`
```c
static const int draw_minimal_borders = 0; /* disable minimalborders */
```
<details>
<summary>Preview:</summary>
<pre>
with:
```c
static const unsigned int borderpx = 10; /* border pixel of windows */
```
Before applying the patch
<img src="https://i.imgur.com/VQfXCjp.png"/>
After applying the patch
<img src="https://i.imgur.com/I7s0Xkv.png"/>
</pre>
</details>
### Download
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.5/minimalborders)
- [2024-04-11](https://codeberg.org/dwl/dwl-patches/raw/commit/7a5c3420822074c544fa102e030b7c30aa6b6be8/minimalborders/minimalborders.patch)
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/be3735bc6a5c64ff76c200a8679453bd179be456/minimalborders/minimalborders.patch)
### Authors
- [wochap](https://codeberg.org/wochap)
+162
View File
@@ -0,0 +1,162 @@
From 225fcc26d1b0fd696a90817c996b670ced8964f2 Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Thu, 11 Apr 2024 14:34:45 -0500
Subject: [PATCH] apply minimal borders
dynamically adjusts the borders between adjacent clients to make them visually merge
---
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 8847e58..55d8796 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 bf763df..d581f31 100644
--- a/dwl.c
+++ b/dwl.c
@@ -105,6 +105,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;
@@ -312,7 +313,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);
@@ -405,6 +407,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);
@@ -473,6 +477,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)
{
@@ -493,8 +526,28 @@ arrange(Monitor *m)
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
- 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);
}
@@ -1883,8 +1936,13 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
struct timespec now;
if ((!active_constraint || active_constraint->surface != 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) {
@@ -2032,7 +2090,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 = interact ? &sgeom : &c->mon->w;
struct wlr_box clip;
@@ -2058,6 +2116,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.43.2