bar: 2024-06-26

This commit is contained in:
sewn 2024-06-26 10:06:11 +03:00
parent f92c23c607
commit 5ce3fdc2ed
No known key found for this signature in database
8 changed files with 506 additions and 343 deletions

View File

@ -14,7 +14,7 @@ slstatus -s | dwl
### Download
- [git branch](https://codeberg.org/sewn/dwl/src/branch/bar)
- [2024-06-10](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/bar/bar.patch)
- [2024-06-26](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/bar/bar.patch)
Below is a preview of the patch.

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,8 @@
Add a border around the [bar](https://codeberg.org/dwl/dwl-patches/wiki/bar) similar to how a client is given a border.
### Download
- [2024-06-10](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/barborder/barborder.patch) (bar 2024-06-10)
- [git branch](https://codeberg.org/sewn/dwl/src/branch/barborder)
- [2024-06-26](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/barborder/barborder.patch) (bar 2024-06-26)
### Authors
- [sewn](https://codeberg.org/sewn)

View File

@ -1,15 +1,15 @@
From 1589ba9e16216e13dcc77e08b638f86ba41d47eb Mon Sep 17 00:00:00 2001
From 7fbc305cacfba68568caed79b73603dae5389328 Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org>
Date: Mon, 10 Jun 2024 14:59:12 +0300
Subject: [PATCH] add border to bar
---
config.def.h | 3 ++-
dwl.c | 27 ++++++++++++++++-----------
2 files changed, 18 insertions(+), 12 deletions(-)
dwl.c | 31 +++++++++++++++++++------------
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/config.def.h b/config.def.h
index d0bb5bc..9387dea 100644
index 6024b7e..86c07d6 100644
--- a/config.def.h
+++ b/config.def.h
@@ -6,7 +6,7 @@
@ -18,111 +18,115 @@ index d0bb5bc..9387dea 100644
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 unsigned int borderpx = 1; /* border pixel of windows & bar */
static const float rootcolor[] = COLOR(0x000000ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
@@ -18,6 +18,7 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = {"monospace:size=10"};
+static pixman_color_t borderbar = { 0x5555, 0x7777, 0x0000, 0xffff };
static pixman_color_t normbarfg = { 0xbbbb, 0xbbbb, 0xbbbb, 0xffff };
static pixman_color_t normbarbg = { 0x2222, 0x2222, 0x2222, 0xffff };
static pixman_color_t selbarfg = { 0xeeee, 0xeeee, 0xeeee, 0xffff };
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = {"monospace:size=10"};
@@ -18,6 +18,7 @@ static uint32_t colors[][3] = {
[SchemeNorm] = { 0xbbbbbbff, 0x222222ff, 0x444444ff },
[SchemeSel] = { 0xeeeeeeff, 0x005577ff, 0x005577ff },
[SchemeUrg] = { 0, 0, 0x770000ff },
+ [SchemeBar] = { 0, 0, 0x557700ff },
};
/* tagging - TAGCOUNT must be no greater than 31 */
diff --git a/dwl.c b/dwl.c
index cd484bd..679409f 100644
index 72b4abb..1f40d5e 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1349,7 +1349,8 @@ dirtomon(enum wlr_direction dir)
@@ -85,7 +85,7 @@
#define TEXTW(mon, text) (drwl_font_getwidth(mon->drw, text) + mon->lrpad)
/* enums */
-enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
+enum { SchemeNorm, SchemeSel, SchemeUrg, SchemeBar }; /* color schemes */
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11 }; /* client types */
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
@@ -1426,7 +1426,8 @@ dirtomon(enum wlr_direction dir)
void
drawbar(Monitor *m)
{
- int x, w, tw = 0;
+ int x, y = borderpx, w, tw = 0;
+ int mh, mw;
int sel;
int boxs = m->font->height / 9;
int boxw = m->font->height / 6 + 2;
@@ -1362,6 +1363,8 @@ drawbar(Monitor *m)
int boxs = m->drw->font->height / 9;
int boxw = m->drw->font->height / 6 + 2;
uint32_t i, occ = 0, urg = 0;
@@ -1437,6 +1438,8 @@ drawbar(Monitor *m)
if (!m->showbar)
return;
+ mh = m->b.height - borderpx * 2;
+ mw = m->b.width - borderpx * 2;
stride = m->b.width * 4;
stride = drwl_stride(m->b.width);
size = stride * m->b.height;
@@ -1372,12 +1375,14 @@ drawbar(Monitor *m)
pix = pixman_image_create_bits(
PIXMAN_a8r8g8b8, m->b.width, m->b.height, buf->data, stride);
@@ -1446,11 +1449,15 @@ drawbar(Monitor *m)
+ drwl_rect(pix, 0, 0, m->b.width, m->b.height, 1, &borderbar);
drwl_prepare_drawing(m->drw, m->b.width, m->b.height, buf->data, stride);
+ drwl_setscheme(m->drw, colors[SchemeBar]);
+ drwl_rect(m->drw, 0, 0, m->b.width, m->b.height, 1, 1);
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) {
if (stext[0] == '\0')
strncpy(stext, "dwl-"VERSION, sizeof(stext));
tw = TEXTW(m, stext) - m->lrpad;
- drwl_text(pix, m->font, m->b.width - tw, 0, tw, m->b.height, 0,
+ drwl_text(pix, m->font, borderpx + mw - tw, y, tw, mh, 0,
stext, &normbarfg, &normbarbg);
if (m == selmon) { /* status is only drawn on selected monitor */
drwl_setscheme(m->drw, colors[SchemeNorm]);
tw = TEXTW(m, stext) - m->lrpad + 2; /* 2px right padding */
- drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0);
+ drwl_text(m->drw, borderpx + mw - tw, y, tw, mh, 0, stext, 0);
}
@@ -1388,37 +1393,37 @@ drawbar(Monitor *m)
wl_list_for_each(c, &clients, link) {
@@ -1460,31 +1467,31 @@ drawbar(Monitor *m)
if (c->isurgent)
urg |= c->tags;
}
- x = 0;
+ x = borderpx;
c = focustop(m);
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(m, tags[i]);
sel = m->tagset[m->seltags] & 1 << i;
- drwl_text(pix, m->font, x, 0, w, m->b.height, m->lrpad / 2, tags[i],
+ drwl_text(pix, m->font, x, y, w, mh, m->lrpad / 2, tags[i],
urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg),
urg & 1 << i ? &selbarfg : (sel ? &selbarbg : &normbarbg));
drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
- drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, tags[i], urg & 1 << i);
+ drwl_text(m->drw, x, y, w, mh, m->lrpad / 2, tags[i], urg & 1 << i);
if (occ & 1 << i)
- drwl_rect(pix, x + boxs, boxs, boxw, boxw, sel,
+ drwl_rect(pix, x + boxs, y + boxs, boxw, boxw, sel,
urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg));
- drwl_rect(m->drw, x + boxs, boxs, boxw, boxw,
+ drwl_rect(m->drw, x + boxs, y + boxs, boxw, boxw,
m == selmon && c && c->tags & 1 << i,
urg & 1 << i);
x += w;
}
w = TEXTW(m, m->ltsymbol);
- x = drwl_text(pix, m->font, x, 0, w, m->b.height, m->lrpad / 2,
+ x = drwl_text(pix, m->font, x, y, w, mh, m->lrpad / 2,
m->ltsymbol, &normbarfg, &normbarbg);
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, y, w, mh, m->lrpad / 2, m->ltsymbol, 0);
- if ((w = m->b.width - tw - x) > m->b.height) {
+ if ((w = mw - tw - x + borderpx) > mh) {
if ((c = focustop(m)) != NULL) {
- drwl_text(pix, m->font, x, 0, w, m->b.height, m->lrpad / 2,
+ drwl_text(pix, m->font, x, y, w, mh, m->lrpad / 2,
client_get_title(c),
m == selmon ? &selbarfg : &normbarfg,
(m == selmon && c) ? &selbarbg : &normbarbg);
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);
+ drwl_text(m->drw, x, y, w, mh, m->lrpad / 2, client_get_title(c), 0);
if (c && c->isfloating)
- drwl_rect(pix, x + boxs, boxs, boxw, boxw, 0,
+ drwl_rect(pix, x + boxs, y + boxs, boxw, boxw, 0,
m == selmon ? &selbarfg : &normbarfg);
} else
- drwl_rect(pix, x, 0, w, m->b.height, 1, &normbarbg);
+ drwl_rect(pix, x, y, w, mh, 1, &normbarbg);
- drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0);
+ drwl_rect(m->drw, x + boxs, y + boxs, boxw, boxw, 0, 0);
} else {
drwl_setscheme(m->drw, colors[SchemeNorm]);
- drwl_rect(m->drw, x, 0, w, m->b.height, 1, 1);
+ drwl_rect(m->drw, x, y, w, mh, 1, 1);
}
}
pixman_image_unref(pix);
@@ -3020,7 +3025,7 @@ updatebar(Monitor *m)
@@ -3080,7 +3087,7 @@ updatebar(Monitor *m)
m->b.scale = m->wlr_output->scale;
m->lrpad = m->font->height;
- m->b.height = m->font->height + 2;
+ m->b.height = m->font->height + 2 + borderpx * 2;
m->lrpad = m->drw->font->height;
- m->b.height = m->drw->font->height + 2;
+ m->b.height = m->drw->font->height + 2 + borderpx * 2;
m->b.real_height = (int)((float)m->b.height / m->wlr_output->scale);
}
--
2.45.0
2.45.2

View File

@ -3,7 +3,8 @@
Add vertical and horizontal space between the [bar](https://codeberg.org/dwl/dwl-patches/wiki/bar) and the edge of the screen.
### Download
- [2024-06-10](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/barpadding/barpadding.patch) (bar 2024-06-10)
- [git branch](https://codeberg.org/sewn/dwl/src/branch/barborder)
- [2024-06-26](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/barpadding/barpadding.patch) (bar 2024-06-26)
### Authors
- [sewn](https://codeberg.org/sewn)

View File

@ -1,4 +1,4 @@
From 69af490e9ad6213463c043db736547bffddd77d2 Mon Sep 17 00:00:00 2001
From 504fb68dc63072b7184273c658f572bca1688996 Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org>
Date: Mon, 10 Jun 2024 16:33:52 +0300
Subject: [PATCH] add vertical and horizontal spacing to bar
@ -10,23 +10,23 @@ https://dwm.suckless.org/patches/barpadding/
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/config.def.h b/config.def.h
index d0bb5bc..8dc2e85 100644
index 6024b7e..4d438ab 100644
--- a/config.def.h
+++ b/config.def.h
@@ -17,6 +17,8 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* bar */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
+static const int vertpad = 10; /* vertical padding of bar */
+static const int sidepad = 10; /* horizontal padding of bar */
static const char *fonts[] = {"monospace:size=10"};
static pixman_color_t normbarfg = { 0xbbbb, 0xbbbb, 0xbbbb, 0xffff };
static pixman_color_t normbarbg = { 0x2222, 0x2222, 0x2222, 0xffff };
@@ -9,6 +9,8 @@ static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will
static const unsigned int borderpx = 1; /* border pixel of windows */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
+static const int vertpad = 10; /* vertical padding of bar */
+static const int sidepad = 10; /* horizontal padding of bar */
static const char *fonts[] = {"monospace:size=10"};
static const float rootcolor[] = COLOR(0x000000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
diff --git a/dwl.c b/dwl.c
index cd484bd..eec0dd7 100644
index 72b4abb..b26cb9c 100644
--- a/dwl.c
+++ b/dwl.c
@@ -572,8 +572,8 @@ arrangelayers(Monitor *m)
@@ -591,8 +591,8 @@ arrangelayers(Monitor *m)
return;
if (m->showbar) {
@ -37,8 +37,8 @@ index cd484bd..eec0dd7 100644
}
/* Arrange exclusive surfaces from top->bottom */
@@ -1424,8 +1424,8 @@ drawbar(Monitor *m)
pixman_image_unref(pix);
@@ -1491,8 +1491,8 @@ drawbar(Monitor *m)
drwl_finish_drawing(m->drw);
wlr_scene_buffer_set_dest_size(m->scene_buffer,
m->b.real_width, m->b.real_height);
- wlr_scene_node_set_position(&m->scene_buffer->node, m->m.x,
@ -48,7 +48,7 @@ index cd484bd..eec0dd7 100644
wlr_scene_buffer_set_buffer(m->scene_buffer, &buf->base);
wlr_buffer_drop(&buf->base);
}
@@ -3007,7 +3007,7 @@ updatebar(Monitor *m)
@@ -3067,7 +3067,7 @@ updatebar(Monitor *m)
char fontattrs[12];
wlr_output_transformed_resolution(m->wlr_output, &rw, &rh);
@ -56,7 +56,7 @@ index cd484bd..eec0dd7 100644
+ m->b.width = rw - 2 * sidepad;
m->b.real_width = (int)((float)m->b.width / m->wlr_output->scale);
if (m->b.scale == m->wlr_output->scale && m->font)
if (m->b.scale == m->wlr_output->scale && m->drw)
--
2.45.0
2.45.2

View File

@ -4,7 +4,8 @@ Prevent [bar](https://codeberg.org/dwl/dwl-patches/wiki/bar) from drawing tags w
It also stops drawing empty rectangles on the bar for non-vacant tags as there is no need anymore to distinguish vacant tags and it offers a more visible contrast than if there were filled/empty rectangles.
### Download
- [2024-06-10](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/hide_vacant_tags/hide_vacant_tags.patch) (bar 2024-06-10)
- [git branch](https://codeberg.org/sewn/dwl/src/branch/hide_vacant_tags)
- [2024-06-26](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/hide_vacant_tags/hide_vacant_tags.patch) (bar 2024-06-26)
### Authors
- [sewn](https://codeberg.org/sewn)

View File

@ -1,18 +1,18 @@
From be3ef9ff5373e004cd8ed564a9671cd190e1db40 Mon Sep 17 00:00:00 2001
From fcf10002eb978d724bc2e53f3a88409eb4422b7e Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org>
Date: Mon, 10 Jun 2024 14:50:07 +0300
Subject: [PATCH] hide vacant tags
https://dwm.suckless.org/patches/hide_vacant_tags/
---
dwl.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
dwl.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/dwl.c b/dwl.c
index cd484bd..de474a6 100644
index 72b4abb..63cf7b7 100644
--- a/dwl.c
+++ b/dwl.c
@@ -654,7 +654,7 @@ void buffer_end_data_ptr_access(struct wlr_buffer *buffer) {
@@ -675,7 +675,7 @@ buffer_end_data_ptr_access(struct wlr_buffer *buffer)
void
buttonpress(struct wl_listener *listener, void *data)
{
@ -21,9 +21,9 @@ index cd484bd..de474a6 100644
unsigned int click;
struct wlr_pointer_button_event *event = data;
struct wlr_keyboard *keyboard;
@@ -675,9 +675,16 @@ buttonpress(struct wl_listener *listener, void *data)
if (!c && (node = wlr_scene_node_at(&layers[LyrBottom]->node, cursor->x, cursor->y, NULL, NULL)) &&
(buffer = wlr_scene_buffer_from_node(node)) && buffer == selmon->scene_buffer) {
@@ -699,9 +699,16 @@ buttonpress(struct wl_listener *listener, void *data)
cursor->x *= selmon->wlr_output->scale;
cursor->y *= selmon->wlr_output->scale;
x = selmon->m.x;
- do
+ wl_list_for_each(c, &clients, link) {
@ -40,7 +40,7 @@ index cd484bd..de474a6 100644
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
@@ -1384,23 +1391,21 @@ drawbar(Monitor *m)
@@ -1456,13 +1463,15 @@ drawbar(Monitor *m)
wl_list_for_each(c, &clients, link) {
if (c->mon != m)
continue;
@ -50,24 +50,13 @@ index cd484bd..de474a6 100644
urg |= c->tags;
}
x = 0;
c = focustop(m);
for (i = 0; i < LENGTH(tags); i++) {
- w = TEXTW(m, tags[i]);
sel = m->tagset[m->seltags] & 1 << i;
+ if(!(occ & 1 << i || sel))
+ if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
+ continue;
+ w = TEXTW(m, tags[i]);
drwl_text(pix, m->font, x, 0, w, m->b.height, m->lrpad / 2, tags[i],
urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg),
urg & 1 << i ? &selbarfg : (sel ? &selbarbg : &normbarbg));
- if (occ & 1 << i)
- drwl_rect(pix, x + boxs, boxs, boxw, boxw, sel,
- urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg));
-
x += w;
}
w = TEXTW(m, tags[i]);
drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, tags[i], urg & 1 << i);
--
2.45.0
2.45.2