bar: split sub-patches

This commit is contained in:
sewn
2024-04-05 14:19:08 +03:00
parent aa61f857b3
commit ff2881f32a
3 changed files with 0 additions and 0 deletions
-87
View File
@@ -1,87 +0,0 @@
From 537bd7c485c1fb370d7a73f979ee140dab9c078e Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org>
Date: Mon, 25 Mar 2024 00:15:01 +0300
Subject: [PATCH] port barpadding patch to bar for dwl
---
config.def.h | 3 +++
dwl.c | 14 +++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/config.def.h b/config.def.h
index bd008c9..a2cf167 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 float rootcolor[] = COLOR(0x000000ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
@@ -17,6 +18,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 const char *fontattrs = "dpi=96";
static pixman_color_t normbarfg = { 0xbbbb, 0xbbbb, 0xbbbb, 0xffff };
diff --git a/dwl.c b/dwl.c
index 976fefb..6650fdc 100644
--- a/dwl.c
+++ b/dwl.c
@@ -434,6 +434,8 @@ static Monitor *selmon;
static struct fcft_font *font;
static int bh;
+static int vp;
+static int sp;
static int lrpad;
static char stext[256];
static struct wl_event_source *status_event_source;
@@ -571,8 +573,8 @@ arrangelayers(Monitor *m)
return;
if (m->showbar) {
- usable_area.height -= m->b.height;
- usable_area.y += topbar ? m->b.height : 0;
+ usable_area.height = usable_area.height - vertpad - m->b.height;
+ usable_area.y = topbar ? usable_area.y + m->b.height + vp : usable_area.y;
}
/* Arrange exclusive surfaces from top->bottom */
@@ -1501,8 +1503,8 @@ drawbar(Monitor *mon)
}
pixman_image_unref(pix);
- wlr_scene_node_set_position(&mon->scene_buffer->node, mon->m.x,
- mon->m.y + (topbar ? 0 : mon->m.height - mon->b.height));
+ wlr_scene_node_set_position(&mon->scene_buffer->node, mon->m.x + sp,
+ mon->m.y + vp + (topbar ? 0 : mon->m.height - mon->b.height));
wlr_scene_buffer_set_buffer(mon->scene_buffer, &buf->base);
wlr_buffer_drop(&buf->base);
}
@@ -2747,6 +2749,8 @@ setup(void)
lrpad = font->height;
bh = font->height + 2;
+ sp = sidepad;
+ vp = (topbar == 1) ? vertpad : - vertpad;
status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy),
STDIN_FILENO, WL_EVENT_READABLE, status_in, NULL);
@@ -3087,7 +3091,7 @@ updatebardims(Monitor *m)
{
int rw, rh;
wlr_output_transformed_resolution(m->wlr_output, &rw, &rh);
- m->b.width = rw;
+ m->b.width = rw - 2 * sp;
m->b.height = bh;
}
--
2.44.0
-120
View File
@@ -1,120 +0,0 @@
From a6c7531d67e7cfd82c519f5b1eb1eb0659bbb2d4 Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org>
Date: Sat, 23 Mar 2024 14:09:57 +0300
Subject: [PATCH] add border to bar
---
config.def.h | 1 +
dwl.c | 33 +++++++++++++++++++--------------
2 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/config.def.h b/config.def.h
index bd008c9..a51ebe7 100644
--- a/config.def.h
+++ b/config.def.h
@@ -19,6 +19,7 @@ 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 const char *fontattrs = "dpi=96";
+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 };
diff --git a/dwl.c b/dwl.c
index 8341134..9f0b9d2 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1428,7 +1428,8 @@ draw_rect(pixman_image_t *pix,
void
drawbar(Monitor *mon)
{
- int x, w, tw = 0;
+ int x, y = borderpx, w, tw = 0;
+ int mh, mw;
int sel;
int boxs = font->height / 9;
int boxw = font->height / 6 + 2;
@@ -1442,6 +1443,8 @@ drawbar(Monitor *mon)
if (!mon || !mon->showbar)
return;
+ mh = mon->b.height - borderpx * 2;
+ mw = mon->b.width - borderpx * 2;
stride = mon->b.width * 4;
size = stride * mon->b.height;
@@ -1452,13 +1455,15 @@ drawbar(Monitor *mon)
pix = pixman_image_create_bits(
PIXMAN_a8r8g8b8, mon->b.width, mon->b.height, buf->data, stride);
+ draw_rect(pix, 0, 0, mon->b.width, mon->b.height, 1, &borderbar);
+
/* draw status first so it can be overdrawn by tags later */
if (mon == selmon) {
if (stext[0] == '\0')
strncpy(stext, "dwl-"VERSION, sizeof(stext));
- draw_rect(pix, 0, 0, mon->b.width, mon->b.height, 1, &normbarbg);
+ draw_rect(pix, borderpx, y, mw, mh, 1, &normbarbg);
tw = TEXTW(stext) - lrpad + 2;
- draw_text(pix, mon->b.width - tw, 0, tw, mon->b.height, 0, stext, &normbarfg);
+ draw_text(pix, borderpx + mw - tw, y, tw + borderpx, mh, 0, stext, &normbarfg);
}
wl_list_for_each(c, &clients, link) {
@@ -1469,34 +1474,34 @@ drawbar(Monitor *mon)
urg |= c->tags;
}
c = focustop(mon);
- x = 0;
+ x = borderpx;
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(tags[i]);
sel = mon->tagset[mon->seltags] & 1 << i;
- draw_rect(pix, x, 0, w, mon->b.height, 1,
+ draw_rect(pix, x, y, w, mh, 1,
urg & 1 << i ? &selbarfg : (sel ? &selbarbg : &normbarbg));
- draw_text(pix, x, 0, w, mon->b.height, lrpad / 2, tags[i],
+ draw_text(pix, x, y, w, mh, lrpad / 2, tags[i],
urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg));
if (occ & 1 << i)
- draw_rect(pix, x + boxs, boxs, boxw, boxw,
+ draw_rect(pix, x + boxs, y + boxs, boxw, boxw,
sel, urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg));
x += w;
}
w = TEXTW(mon->ltsymbol);
- draw_rect(pix, x, 0, w, mon->b.height, 1, &normbarbg);
- x = draw_text(pix, x, 0, w, mon->b.height, lrpad / 2, mon->ltsymbol, &normbarfg);
+ draw_rect(pix, x, y, w, mh, 1, &normbarbg);
+ x = draw_text(pix, x, y, w, mh, lrpad / 2, mon->ltsymbol, &normbarfg);
- if ((w = mon->b.width - tw - x) > mon->b.height) {
+ if ((w = mw - tw - x) > mh) {
title = c ? client_get_title(c) : NULL;
- draw_rect(pix, x, 0, w, mon->b.height, 1,
+ draw_rect(pix, x, y, w, mh, 1,
(mon == selmon && title) ? &selbarbg : &normbarbg);
- draw_text(pix, x, 0, w, mon->b.height, lrpad / 2, title,
+ draw_text(pix, x, y, w, mh, lrpad / 2, title,
mon == selmon ? &selbarfg : &normbarfg);
if (c && c->isfloating)
- draw_rect(pix, x + boxs, boxs, boxw, boxw, 0,
+ draw_rect(pix, x + boxs, y + boxs, boxw, boxw, 0,
mon == selmon ? &selbarfg : &normbarfg);
}
@@ -2755,7 +2760,7 @@ setup(void)
die("Could not load font");
lrpad = font->height;
- bh = font->height + 2;
+ bh = font->height + 2 + borderpx * 2;
status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy),
STDIN_FILENO, WL_EVENT_READABLE, status_in, NULL);
--
2.44.0
-76
View File
@@ -1,76 +0,0 @@
From 7350bdb548ba4b50a666a6e7fdc71d26c6e7e191 Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org>
Date: Sun, 24 Mar 2024 23:07:11 +0300
Subject: [PATCH] port hide vacant tags patch
---
dwl.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/dwl.c b/dwl.c
index 8341134..3332c69 100644
--- a/dwl.c
+++ b/dwl.c
@@ -652,7 +652,7 @@ void buffer_end_data_ptr_access(struct wlr_buffer *buffer) {
void
buttonpress(struct wl_listener *listener, void *data)
{
- unsigned int i = 0, x = 0;
+ unsigned int i = 0, x = 0, occ = 0;
unsigned int click;
struct wlr_pointer_button_event *event = data;
struct wlr_keyboard *keyboard;
@@ -673,9 +673,18 @@ buttonpress(struct wl_listener *listener, void *data)
if ((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) {
x = selmon->m.x;
- do
- x += TEXTW(tags[i]);
- while (cursor->x >= x && ++i < LENGTH(tags));
+
+ wl_list_for_each(c, &clients, link) {
+ if (c->mon != selmon)
+ continue;
+ occ |= c->tags == TAGMASK ? 0 : c->tags;
+ }
+ do {
+ /* Do not reserve space for vacant tags */
+ if (!(occ & 1 << i || selmon->tagset[selmon->seltags] & 1 << i))
+ continue;
+ x += TEXTW(tags[i]);
+ } while (cursor->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
@@ -1464,13 +1473,16 @@ drawbar(Monitor *mon)
wl_list_for_each(c, &clients, link) {
if (c->mon != mon)
continue;
- occ |= c->tags;
+ occ |= c->tags == TAGMASK ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
}
c = focustop(mon);
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
+ /* Do not draw vacant tags */
+ if(!(occ & 1 << i || mon->tagset[mon->seltags] & 1 << i))
+ continue;
w = TEXTW(tags[i]);
sel = mon->tagset[mon->seltags] & 1 << i;
@@ -1479,10 +1491,6 @@ drawbar(Monitor *mon)
draw_text(pix, x, 0, w, mon->b.height, lrpad / 2, tags[i],
urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg));
- if (occ & 1 << i)
- draw_rect(pix, x + boxs, boxs, boxw, boxw,
- sel, urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg));
-
x += w;
}
w = TEXTW(mon->ltsymbol);
--
2.44.0