Merge branch 'main' into monchange

This commit is contained in:
Benjamin Chausse 2024-08-10 18:16:06 +00:00
commit 5988158902
3 changed files with 181 additions and 5 deletions

View File

@ -40,11 +40,12 @@ If you target the unstable `main` branch, specify that in the `Download` link on
### Download
- [git branch](/USERNAME/dwl/src/branch/PATCHNAME)
^ OPTIONAL: Patchers are no longer obligated to maintain public `dwl` branches devoted to their patches
- [dwl-branchname (like "0.7")](/dwl/dwl-patches/raw/branch/main/patches/PATCHNAME/PATCHNAME.patch)
USE THE ^raw^ PATCH LINK HERE
^^^^^^^^^^ OPTIONAL: Patchers are no longer obligated to maintain public `dwl` branches devoted to their patches
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/PATCHNAME/PATCHNAME.patch)
Use the ^RAW^ patch link here
^^^ "0.7" is an example. Use the release that your patch targets
- [main YYYY-MM-DD](/dwl/dwl-patches/raw/branch/main/patches/PATCHNAME/PATCHNAME.patch)
^ For patches targeting the unstable "main" branch, include a YYYY-MM-DD indicator
^^^^^^^^^^ Patches targeting the unstable "main" branch include a YYYY-MM-DD indicator
### Authors - latest at top [Codeberg nick is mandatory; other contact methods optional]
- [YOUR_NICK](https://codeberg.org/USERNAME)
your_email@if_you_wish_to.share.it
@ -58,7 +59,7 @@ If you target the unstable `main` branch, specify that in the `Download` link on
## Updating/Modifying Existing Patches
- If the existing patch is already being maintained by another author, do not make modifications to it without permission.
- Create an issue at [issues] @mentioning the current maintainer
- If you receive no reply for seven days, you may adopt the patch. If you are adopting the patch, you need to maintain a `dwl` branch in your Codeberg repository.
- If you receive no reply for seven days, you may adopt the patch.
- Modify the `README.md` with new links for your raw patch and for your git branch.
- **LEAVE PREVIOUS AUTHOR(S)' NICKS/LINKS INTACT UNDER THE "Authors" HEADING!**
- Add your own nick/link to the top of the "Authors" list.

View File

@ -0,0 +1,15 @@
### Description
Adds support for the [gaps patch](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/gaps)
to the [snail layout patch](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/snail).
Install the [gaps patch](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/gaps)
and the [snail patch](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/snail) first.
### Download
- [main 2024-08-08](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/snail-gaps/snail-gaps.patch)
### Authors
- [JoaoCostaIFG](https://codeberg.org/JoaoCostaIFG) ([joaocosta@posteo.net](mailto:joaocosta@posteo.net))

View File

@ -0,0 +1,160 @@
From 804e69ca4bf586bcec46e018630f94c1c4e0b7e7 Mon Sep 17 00:00:00 2001
From: JoaoCostaIFG <joaocosta.work@posteo.net>
Date: Thu, 8 Aug 2024 00:05:27 +0100
Subject: [PATCH 2/2] Add gaps support to snail layout
---
dwl.c | 105 +++++++++++++++++++++++++++++++++-------------------------
1 file changed, 59 insertions(+), 46 deletions(-)
diff --git a/dwl.c b/dwl.c
index 46bdca1..a158dd6 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2659,8 +2659,8 @@ void
snail(Monitor *m)
{
int i = 0, n = 0;
- unsigned int mw = m->w.width;
- Client *c, *prev;
+ unsigned int mw = m->w.width, e = m->gaps, w = 0, h = 0, egappx = 0;
+ Client *c, *prev = NULL;
enum wlr_direction dir = WLR_DIRECTION_RIGHT;
wl_list_for_each(c, &clients, link)
@@ -2668,9 +2668,12 @@ snail(Monitor *m)
n++;
if (n == 0)
return;
+ if (smartgaps == n)
+ e = 0;
+ egappx = e * gappx;
if (n > m->nmaster)
- mw = m->nmaster ? ROUND(m->w.width * m->mfact) : 0;
+ mw = m->nmaster ? (unsigned int)round((m->w.width + egappx) * m->mfact) : 0;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
@@ -2681,8 +2684,8 @@ snail(Monitor *m)
* master area with this window
*/
if (mw > 0 && i == 0) {
- c->geom = (struct wlr_box){.x = m->w.x, .y = m->w.y,
- .width = mw, .height = m->w.height};
+ c->geom = (struct wlr_box){.x = m->w.x + egappx, .y = m->w.y + egappx,
+ .width = mw - 2*egappx, .height = m->w.height - 2*egappx};
/*
* If the first window in the master area is wide, split it
* horizontally and put next one on its right; otherwise, split it
@@ -2694,55 +2697,65 @@ snail(Monitor *m)
* m->nmaster-th window
*/
} else if (i == m->nmaster) {
- c->geom = (struct wlr_box){.x = m->w.x + mw, .y = m->w.y,
- .width = m->w.width - mw, .height = m->w.height};
+ c->geom = (struct wlr_box){.x = m->w.x + mw + egappx, .y = m->w.y + egappx,
+ .width = m->w.width - mw - 2*egappx, .height = m->w.height - 2*egappx};
/*
* If the first window in the stack is wide, split it horizontally
* and put next one on its right; otherwise, split it vertically and
* put the next one below it
*/
dir = c->geom.width > m->w.height ? WLR_DIRECTION_RIGHT : WLR_DIRECTION_DOWN;
- /*
- * Split the previous horizontally and put the current window on the right
- */
- } else if (dir == WLR_DIRECTION_RIGHT) {
- c->geom = (struct wlr_box){.x = prev->geom.x + prev->geom.width / 2, .y = prev->geom.y,
- .width = prev->geom.width / 2, .height = prev->geom.height};
- prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
- .width = prev->geom.width / 2, .height = prev->geom.height};
+ } else if (prev) {
/*
- * If it's a stack window or the first narrow window in the master
- * area, put the next one below it
+ * Split the previous horizontally and put the current window on the right
*/
- if (i >= m->nmaster || c->geom.width < m->w.height)
- dir = WLR_DIRECTION_DOWN;
- /*
- * Split the previous vertically and put the current window below it
- */
- } else if (dir == WLR_DIRECTION_DOWN) {
- c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y + prev->geom.height / 2,
- .width = prev->geom.width, .height = prev->geom.height / 2};
- prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
- .width = prev->geom.width, .height = prev->geom.height / 2};
- dir = WLR_DIRECTION_LEFT;
- /*
- * Split the previous horizontally and put the current window on the left
- */
- } else if (dir == WLR_DIRECTION_LEFT) {
- c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
- .width = prev->geom.width / 2, .height = prev->geom.height};
- prev->geom = (struct wlr_box){.x = prev->geom.x + prev->geom.width / 2, .y = prev->geom.y,
- .width = prev->geom.width / 2, .height = prev->geom.height};
- dir = WLR_DIRECTION_UP;
- /*
- * Split the previous vertically and put the current window above it
- */
- } else {
- c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
- .width = prev->geom.width, .height = prev->geom.height / 2};
- prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y + prev->geom.height / 2,
- .width = prev->geom.width, .height = prev->geom.height / 2};
- dir = WLR_DIRECTION_RIGHT;
+ if (dir == WLR_DIRECTION_RIGHT) {
+ w = prev->geom.width / 2 - egappx;
+ h = prev->geom.height;
+ c->geom = (struct wlr_box){.x = prev->geom.x + prev->geom.width / 2 + egappx, .y = prev->geom.y,
+ .width = w, .height = h};
+ prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
+ .width = w, .height = h};
+ /*
+ * If it's a stack window or the first narrow window in the master
+ * area, put the next one below it
+ */
+ if (i >= m->nmaster || c->geom.width < m->w.height)
+ dir = WLR_DIRECTION_DOWN;
+ /*
+ * Split the previous vertically and put the current window below it
+ */
+ } else if (dir == WLR_DIRECTION_DOWN) {
+ w = prev->geom.width;
+ h = prev->geom.height / 2 - egappx;
+ c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y + prev->geom.height / 2 + egappx,
+ .width = w, .height = h};
+ prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
+ .width = w, .height = h};
+ dir = WLR_DIRECTION_LEFT;
+ /*
+ * Split the previous horizontally and put the current window on the left
+ */
+ } else if (dir == WLR_DIRECTION_LEFT) {
+ w = prev->geom.width / 2 - egappx;
+ h = prev->geom.height;
+ c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
+ .width = w, .height = h};
+ prev->geom = (struct wlr_box){.x = prev->geom.x + prev->geom.width / 2 + egappx, .y = prev->geom.y,
+ .width = w, .height = h};
+ dir = WLR_DIRECTION_UP;
+ /*
+ * Split the previous vertically and put the current window above it
+ */
+ } else {
+ w = prev->geom.width;
+ h = prev->geom.height / 2 - egappx;
+ c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
+ .width = w, .height = h};
+ prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y + prev->geom.height / 2 + egappx,
+ .width = w, .height = h};
+ dir = WLR_DIRECTION_RIGHT;
+ }
}
i++;
prev = c;
--
2.46.0