Update cfact patch

This commit is contained in:
Palanix 2024-02-15 18:19:24 +01:00
parent dc57f8e43f
commit bde90ec194
No known key found for this signature in database
GPG Key ID: 439CD6BD9905FAC5
2 changed files with 12 additions and 32 deletions

View File

@ -1,20 +0,0 @@
### Description
A port of the [dwm cfacts patch](https://dwm.suckless.org/patches/cfacts/) (with the limits removed)
Clients with higher weight are allocated more space!
```
+---------------------+
| | 0.5 |
| 1.0 +----------+
+----------+ |
| | 1.0 |
| +----------+
| 2.0 | |
| | 1.0 |
+----------+----------+`
```
### Download
- [2023-07-22](https://github.com/djpohly/dwl/compare/main...PalanixYT:cfact.patch)
### Authors
- [Palanix](https://github.com/PalanixYT)

View File

@ -1,4 +1,4 @@
From 1c22458b124148f48808edfbfed13af3f0e7973c Mon Sep 17 00:00:00 2001 From 98fe302cd240b519c28c886250273854844ab2c7 Mon Sep 17 00:00:00 2001
From: Palanix <palanixyt@gmail.com> From: Palanix <palanixyt@gmail.com>
Date: Fri, 24 Nov 2023 21:16:56 +0100 Date: Fri, 24 Nov 2023 21:16:56 +0100
Subject: [PATCH] cweights to allow different size clients in normal layouts Subject: [PATCH] cweights to allow different size clients in normal layouts
@ -9,7 +9,7 @@ Subject: [PATCH] cweights to allow different size clients in normal layouts
2 files changed, 33 insertions(+), 2 deletions(-) 2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h diff --git a/config.def.h b/config.def.h
index 9009517..4690567 100644 index 9009517..27ff521 100644
--- a/config.def.h --- a/config.def.h
+++ b/config.def.h +++ b/config.def.h
@@ -128,6 +128,9 @@ static const Key keys[] = { @@ -128,6 +128,9 @@ static const Key keys[] = {
@ -18,12 +18,12 @@ index 9009517..4690567 100644
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} }, { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_H, setcfact, {.f = +0.25f} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_H, setcfact, {.f = +0.25f} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_L, setcfact, {.f = -0.25f} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_L, setcfact, {.f = -0.25f} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, setcfact, {.f = 0f} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, setcfact, {.f = 0.0f} },
{ MODKEY, XKB_KEY_Return, zoom, {0} }, { MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY, XKB_KEY_Tab, view, {0} }, { MODKEY, XKB_KEY_Tab, view, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
diff --git a/dwl.c b/dwl.c diff --git a/dwl.c b/dwl.c
index c8283b7..b548a42 100644 index fa76db2..9bdb438 100644
--- a/dwl.c --- a/dwl.c
+++ b/dwl.c +++ b/dwl.c
@@ -136,6 +136,7 @@ typedef struct { @@ -136,6 +136,7 @@ typedef struct {
@ -50,7 +50,7 @@ index c8283b7..b548a42 100644
wlr_xdg_toplevel_set_wm_capabilities(xdg_surface->toplevel, wlr_xdg_toplevel_set_wm_capabilities(xdg_surface->toplevel,
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN); WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
@@ -2007,6 +2010,19 @@ run(char *startup_cmd) @@ -2009,6 +2012,19 @@ run(char *startup_cmd)
wl_display_run(dpy); wl_display_run(dpy);
} }
@ -61,7 +61,7 @@ index c8283b7..b548a42 100644
+ +
+ if(!arg || !sel || !selmon->lt[selmon->sellt]->arrange) + if(!arg || !sel || !selmon->lt[selmon->sellt]->arrange)
+ return; + return;
+ sel->cweight = arg->f ? sel->cweight + arg->f : 1.0; + sel->cweight = (float) (arg->f ? sel->cweight + arg->f : 1.0);
+ if (sel->cweight < 0) + if (sel->cweight < 0)
+ sel->cweight = 0; + sel->cweight = 0;
+ arrange(selmon); + arrange(selmon);
@ -70,7 +70,7 @@ index c8283b7..b548a42 100644
void void
setcursor(struct wl_listener *listener, void *data) setcursor(struct wl_listener *listener, void *data)
{ {
@@ -2464,6 +2480,7 @@ tile(Monitor *m) @@ -2468,6 +2484,7 @@ tile(Monitor *m)
{ {
unsigned int mw, my, ty; unsigned int mw, my, ty;
int i, n = 0; int i, n = 0;
@ -78,7 +78,7 @@ index c8283b7..b548a42 100644
Client *c; Client *c;
wl_list_for_each(c, &clients, link) wl_list_for_each(c, &clients, link)
@@ -2476,17 +2493,27 @@ tile(Monitor *m) @@ -2480,17 +2497,27 @@ tile(Monitor *m)
mw = m->nmaster ? ROUND(m->w.width * m->mfact) : 0; mw = m->nmaster ? ROUND(m->w.width * m->mfact) : 0;
else else
mw = m->w.width; mw = m->w.width;
@ -99,16 +99,16 @@ index c8283b7..b548a42 100644
if (i < m->nmaster) { if (i < m->nmaster) {
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw, resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
- .height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0); - .height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
+ .height = ((c->cweight / mweight) * m->w.height)}, 0); + .height = (int) ((c->cweight / mweight) * m->w.height)}, 0);
my += c->geom.height; my += c->geom.height;
} else { } else {
resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty, resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
- .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0); - .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
+ .width = m->w.width - mw, .height = ((c->cweight / tweight) * m->w.height) }, 0); + .width = m->w.width - mw, .height = (int) ((c->cweight / tweight) * m->w.height) }, 0);
ty += c->geom.height; ty += c->geom.height;
} }
i++; i++;
@@ -2868,6 +2895,7 @@ createnotifyx11(struct wl_listener *listener, void *data) @@ -2872,6 +2899,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
c->surface.xwayland = xsurface; c->surface.xwayland = xsurface;
c->type = X11; c->type = X11;
c->bw = borderpx; c->bw = borderpx;
@ -117,5 +117,5 @@ index c8283b7..b548a42 100644
/* Listen to the various events it can emit */ /* Listen to the various events it can emit */
LISTEN(&xsurface->events.associate, &c->associate, associatex11); LISTEN(&xsurface->events.associate, &c->associate, associatex11);
-- --
2.43.0 2.43.1