mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2026-03-22 17:01:31 +00:00
bar-modes: show status text when space permits
Try to truncate title before hiding status, with longer modes labels.
This commit is contained in:
parent
000aa7d15c
commit
ee54a3413c
@ -1,4 +1,4 @@
|
|||||||
From 4f2c8a99720d90a551bf38f2c8d25ad239346eef Mon Sep 17 00:00:00 2001
|
From 04b37902e0098fb69250fd25b5afbc610a284529 Mon Sep 17 00:00:00 2001
|
||||||
From: nate zhou <gnuunixchad@outlook.com>
|
From: nate zhou <gnuunixchad@outlook.com>
|
||||||
Date: Mon, 2 Mar 2026 21:54:03 +0800
|
Date: Mon, 2 Mar 2026 21:54:03 +0800
|
||||||
Subject: [PATCH] Patch: bar-modes for 0.8
|
Subject: [PATCH] Patch: bar-modes for 0.8
|
||||||
@ -6,19 +6,22 @@ Subject: [PATCH] Patch: bar-modes for 0.8
|
|||||||
Add modes_labels indicator to bar, which behaves like river-classic's
|
Add modes_labels indicator to bar, which behaves like river-classic's
|
||||||
dam bar. This patch has to be applied after the bar and modes patch.
|
dam bar. This patch has to be applied after the bar and modes patch.
|
||||||
---
|
---
|
||||||
dwl.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++----------
|
dwl.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
|
||||||
1 file changed, 59 insertions(+), 11 deletions(-)
|
1 file changed, 72 insertions(+), 15 deletions(-)
|
||||||
|
|
||||||
diff --git a/dwl.c b/dwl.c
|
diff --git a/dwl.c b/dwl.c
|
||||||
index ae290ad..df525d3 100644
|
index ae290ad..7229034 100644
|
||||||
--- a/dwl.c
|
--- a/dwl.c
|
||||||
+++ b/dwl.c
|
+++ b/dwl.c
|
||||||
@@ -1585,19 +1585,26 @@ drawbar(Monitor *m)
|
@@ -1585,19 +1585,29 @@ drawbar(Monitor *m)
|
||||||
uint32_t i, occ = 0, urg = 0;
|
uint32_t i, occ = 0, urg = 0;
|
||||||
Client *c;
|
Client *c;
|
||||||
Buffer *buf;
|
Buffer *buf;
|
||||||
+ char mode_text[256] = "";
|
+ char mode_text[256] = "";
|
||||||
+ int mode_width = 0;
|
+ int mode_width = 0;
|
||||||
|
+ int title_width;
|
||||||
|
+ int remaining;
|
||||||
|
+ int status_shown = 0;
|
||||||
|
|
||||||
if (!m->scene_buffer->node.enabled)
|
if (!m->scene_buffer->node.enabled)
|
||||||
return;
|
return;
|
||||||
@ -45,7 +48,7 @@ index ae290ad..df525d3 100644
|
|||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (c->mon != m)
|
if (c->mon != m)
|
||||||
continue;
|
continue;
|
||||||
@@ -1607,6 +1614,8 @@ drawbar(Monitor *m)
|
@@ -1607,6 +1617,8 @@ drawbar(Monitor *m)
|
||||||
}
|
}
|
||||||
x = 0;
|
x = 0;
|
||||||
c = focustop(m);
|
c = focustop(m);
|
||||||
@ -54,7 +57,7 @@ index ae290ad..df525d3 100644
|
|||||||
for (i = 0; i < LENGTH(tags); i++) {
|
for (i = 0; i < LENGTH(tags); i++) {
|
||||||
w = TEXTW(m, tags[i]);
|
w = TEXTW(m, tags[i]);
|
||||||
drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||||
@@ -1617,19 +1626,57 @@ drawbar(Monitor *m)
|
@@ -1617,19 +1629,63 @@ drawbar(Monitor *m)
|
||||||
urg & 1 << i);
|
urg & 1 << i);
|
||||||
x += w;
|
x += w;
|
||||||
}
|
}
|
||||||
@ -70,30 +73,40 @@ index ae290ad..df525d3 100644
|
|||||||
w = TEXTW(m, m->ltsymbol);
|
w = TEXTW(m, m->ltsymbol);
|
||||||
drwl_setscheme(m->drw, colors[SchemeNorm]);
|
drwl_setscheme(m->drw, colors[SchemeNorm]);
|
||||||
- x = drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
|
- x = drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
|
||||||
|
-
|
||||||
|
- if ((w = m->b.width - tw - x) > m->b.height) {
|
||||||
|
- if (c) {
|
||||||
|
- drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
|
||||||
|
- drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, client_get_title(c), 0);
|
||||||
|
- if (c && c->isfloating)
|
||||||
|
- drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0);
|
||||||
|
- } else {
|
||||||
+ drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
|
+ drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
|
||||||
+ x += w;
|
+ x += w;
|
||||||
+
|
+
|
||||||
+ int remaining = m->b.width - x;
|
+ remaining = m->b.width - x;
|
||||||
|
|
||||||
- if ((w = m->b.width - tw - x) > m->b.height) {
|
|
||||||
- if (c) {
|
|
||||||
+ if (mode_text[0]) {
|
|
||||||
+ int title_width = remaining;
|
|
||||||
+
|
+
|
||||||
+ if (title_width > m->b.height && c) {
|
+ if (mode_text[0] && remaining >= tw) {
|
||||||
drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
|
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
|
||||||
- drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, client_get_title(c), 0);
|
+ drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0);
|
||||||
+ drwl_text(m->drw, x, 0, title_width, m->b.height, m->lrpad / 2,
|
+ remaining -= tw;
|
||||||
+ client_get_title(c), 0);
|
+ status_shown = 1;
|
||||||
if (c && c->isfloating)
|
+ }
|
||||||
drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0);
|
+
|
||||||
- } else {
|
+ title_width = remaining;
|
||||||
+ } else if (title_width > 0) {
|
+
|
||||||
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
|
+ if (c && title_width > m->b.height) {
|
||||||
+ drwl_rect(m->drw, x, 0, title_width, m->b.height, 1, 1);
|
+ drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
|
||||||
+ }
|
+ drwl_text(m->drw, x, 0, title_width, m->b.height, m->lrpad / 2,
|
||||||
+ /* no status text when in a mode - completely omitted */
|
+ client_get_title(c), 0);
|
||||||
+ } else {
|
+ if (c && c->isfloating)
|
||||||
|
+ drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0);
|
||||||
|
+ } else if (title_width > 0) {
|
||||||
|
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
|
||||||
|
+ drwl_rect(m->drw, x, 0, title_width, m->b.height, 1, 1);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!mode_text[0]) {
|
||||||
+ /* not in a mode - normal behavior with status */
|
+ /* not in a mode - normal behavior with status */
|
||||||
+ if (remaining >= tw) {
|
+ if (remaining >= tw) {
|
||||||
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
|
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
|
||||||
@ -118,7 +131,7 @@ index ae290ad..df525d3 100644
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3437,6 +3484,7 @@ entermode(const Arg *arg)
|
@@ -3437,6 +3493,7 @@ entermode(const Arg *arg)
|
||||||
{
|
{
|
||||||
active_mode_index = arg->i;
|
active_mode_index = arg->i;
|
||||||
printstatus();
|
printstatus();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user