mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-10-26 17:54:17 +00:00
bar: fix bug (updatebardims)
This commit is contained in:
parent
cfac8fab2a
commit
deee415bb4
122
bar/bar.patch
122
bar/bar.patch
@ -1,14 +1,14 @@
|
||||
From a298e753fecd8ff20879ee8946be9fb44bf7d60b Mon Sep 17 00:00:00 2001
|
||||
From 3c759e99541c396af94286459e60e91637b747ab Mon Sep 17 00:00:00 2001
|
||||
From: sewn <sewn@disroot.org>
|
||||
Date: Fri, 1 Mar 2024 18:46:25 +0300
|
||||
Date: Mon, 25 Mar 2024 00:13:43 +0300
|
||||
Subject: [PATCH] Implement dwm bar clone
|
||||
|
||||
---
|
||||
Makefile | 2 +-
|
||||
config.def.h | 29 +++-
|
||||
dwl.c | 430 +++++++++++++++++++++++++++++++++++++++++++--------
|
||||
dwl.c | 449 ++++++++++++++++++++++++++++++++++++++++++---------
|
||||
utf8.h | 55 +++++++
|
||||
4 files changed, 444 insertions(+), 72 deletions(-)
|
||||
4 files changed, 453 insertions(+), 82 deletions(-)
|
||||
create mode 100644 utf8.h
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
@ -84,7 +84,7 @@ index 9009517..bd008c9 100644
|
||||
+ { ClkTagBar, MODKEY, BTN_RIGHT, toggletag, {0} },
|
||||
};
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 5867b0c..8341134 100644
|
||||
index 5867b0c..976fefb 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -4,6 +4,7 @@
|
||||
@ -216,7 +216,15 @@ index 5867b0c..8341134 100644
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
@@ -405,6 +431,18 @@ static struct wlr_box sgeom;
|
||||
@@ -338,6 +364,7 @@ static void unlocksession(struct wl_listener *listener, void *data);
|
||||
static void unmaplayersurfacenotify(struct wl_listener *listener, void *data);
|
||||
static void unmapnotify(struct wl_listener *listener, void *data);
|
||||
static void updatemons(struct wl_listener *listener, void *data);
|
||||
+static void updatebardims(Monitor *m);
|
||||
static void updatetitle(struct wl_listener *listener, void *data);
|
||||
static void urgent(struct wl_listener *listener, void *data);
|
||||
static void view(const Arg *arg);
|
||||
@@ -405,6 +432,18 @@ static struct wlr_box sgeom;
|
||||
static struct wl_list mons;
|
||||
static Monitor *selmon;
|
||||
|
||||
@ -235,7 +243,7 @@ index 5867b0c..8341134 100644
|
||||
#ifdef XWAYLAND
|
||||
static void activatex11(struct wl_listener *listener, void *data);
|
||||
static void associatex11(struct wl_listener *listener, void *data);
|
||||
@@ -531,6 +569,11 @@ arrangelayers(Monitor *m)
|
||||
@@ -531,6 +570,11 @@ arrangelayers(Monitor *m)
|
||||
if (!m->wlr_output->enabled)
|
||||
return;
|
||||
|
||||
@ -247,7 +255,7 @@ index 5867b0c..8341134 100644
|
||||
/* Arrange exclusive surfaces from top->bottom */
|
||||
for (i = 3; i >= 0; i--)
|
||||
arrangelayer(m, &m->layers[i], &usable_area, 1);
|
||||
@@ -573,17 +616,77 @@ axisnotify(struct wl_listener *listener, void *data)
|
||||
@@ -573,17 +617,77 @@ axisnotify(struct wl_listener *listener, void *data)
|
||||
event->delta_discrete, event->source);
|
||||
}
|
||||
|
||||
@ -325,7 +333,7 @@ index 5867b0c..8341134 100644
|
||||
switch (event->state) {
|
||||
case WLR_BUTTON_PRESSED:
|
||||
cursor_mode = CurPressed;
|
||||
@@ -592,16 +695,14 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
@@ -592,16 +696,14 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
break;
|
||||
|
||||
/* Change focus if the button was _pressed_ over a client */
|
||||
@ -345,7 +353,7 @@ index 5867b0c..8341134 100644
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -675,6 +776,9 @@ cleanup(void)
|
||||
@@ -675,6 +777,9 @@ cleanup(void)
|
||||
/* Destroy after the wayland display (when the monitors are already destroyed)
|
||||
to avoid destroying them with an invalid scene output. */
|
||||
wlr_scene_node_destroy(&scene->tree.node);
|
||||
@ -355,7 +363,7 @@ index 5867b0c..8341134 100644
|
||||
}
|
||||
|
||||
void
|
||||
@@ -726,7 +830,7 @@ closemon(Monitor *m)
|
||||
@@ -726,7 +831,7 @@ closemon(Monitor *m)
|
||||
setmon(c, selmon, c->tags);
|
||||
}
|
||||
focusclient(focustop(selmon), 1);
|
||||
@ -364,15 +372,14 @@ index 5867b0c..8341134 100644
|
||||
}
|
||||
|
||||
void
|
||||
@@ -912,8 +1016,14 @@ createmon(struct wl_listener *listener, void *data)
|
||||
@@ -912,8 +1017,13 @@ createmon(struct wl_listener *listener, void *data)
|
||||
wlr_output_commit_state(wlr_output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
||||
+ m->scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL);
|
||||
+ m->scene_buffer->point_accepts_input = bar_accepts_input;
|
||||
+ m->b.width = m->wlr_output->width;
|
||||
+ m->b.height = bh;
|
||||
+ m->showbar = showbar;
|
||||
+ updatebardims(m);
|
||||
+
|
||||
wl_list_insert(&mons, &m->link);
|
||||
- printstatus();
|
||||
@ -625,16 +632,32 @@ index 5867b0c..8341134 100644
|
||||
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
@@ -2090,7 +2333,7 @@ run(char *startup_cmd)
|
||||
close(piperw[1]);
|
||||
close(piperw[0]);
|
||||
@@ -2074,23 +2317,14 @@ run(char *startup_cmd)
|
||||
|
||||
/* Now that the socket exists and the backend is started, run the startup command */
|
||||
if (startup_cmd) {
|
||||
- int piperw[2];
|
||||
- if (pipe(piperw) < 0)
|
||||
- die("startup: pipe:");
|
||||
if ((child_pid = fork()) < 0)
|
||||
die("startup: fork:");
|
||||
if (child_pid == 0) {
|
||||
- dup2(piperw[0], STDIN_FILENO);
|
||||
- close(piperw[0]);
|
||||
- close(piperw[1]);
|
||||
execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL);
|
||||
die("startup: execl:");
|
||||
}
|
||||
- dup2(piperw[1], STDOUT_FILENO);
|
||||
- close(piperw[1]);
|
||||
- close(piperw[0]);
|
||||
}
|
||||
- printstatus();
|
||||
+ drawbars();
|
||||
|
||||
/* At this point the outputs are initialized, choose initial selmon based on
|
||||
* cursor position, and set default cursor image */
|
||||
@@ -2155,7 +2398,7 @@ setfloating(Client *c, int floating)
|
||||
@@ -2155,7 +2389,7 @@ setfloating(Client *c, int floating)
|
||||
(p && p->isfullscreen) ? LyrFS
|
||||
: c->isfloating ? LyrFloat : LyrTile]);
|
||||
arrange(c->mon);
|
||||
@ -643,7 +666,7 @@ index 5867b0c..8341134 100644
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2178,7 +2421,7 @@ setfullscreen(Client *c, int fullscreen)
|
||||
@@ -2178,7 +2412,7 @@ setfullscreen(Client *c, int fullscreen)
|
||||
resize(c, c->prev, 0);
|
||||
}
|
||||
arrange(c->mon);
|
||||
@ -652,7 +675,7 @@ index 5867b0c..8341134 100644
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2203,7 +2446,7 @@ setlayout(const Arg *arg)
|
||||
@@ -2203,7 +2437,7 @@ setlayout(const Arg *arg)
|
||||
selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, LENGTH(selmon->ltsymbol));
|
||||
arrange(selmon);
|
||||
@ -661,7 +684,16 @@ index 5867b0c..8341134 100644
|
||||
}
|
||||
|
||||
/* arg > 1.0 will set mfact absolutely */
|
||||
@@ -2506,6 +2749,17 @@ setup(void)
|
||||
@@ -2272,7 +2506,7 @@ setup(void)
|
||||
struct xkb_context *context;
|
||||
struct xkb_keymap *keymap;
|
||||
|
||||
- int i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};
|
||||
+ int i, sig[] = {SIGCHLD, SIGINT, SIGTERM};
|
||||
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig};
|
||||
sigemptyset(&sa.sa_mask);
|
||||
|
||||
@@ -2506,6 +2740,17 @@ setup(void)
|
||||
|
||||
wlr_scene_set_presentation(scene, wlr_presentation_create(dpy, backend));
|
||||
|
||||
@ -679,7 +711,7 @@ index 5867b0c..8341134 100644
|
||||
/* Make sure XWayland clients don't connect to the parent X server,
|
||||
* e.g when running in the x11 backend or the wayland backend and the
|
||||
* compositor has Xwayland support */
|
||||
@@ -2548,6 +2802,30 @@ startdrag(struct wl_listener *listener, void *data)
|
||||
@@ -2548,6 +2793,30 @@ startdrag(struct wl_listener *listener, void *data)
|
||||
LISTEN_STATIC(&drag->icon->events.destroy, destroydragicon);
|
||||
}
|
||||
|
||||
@ -710,7 +742,7 @@ index 5867b0c..8341134 100644
|
||||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
@@ -2558,7 +2836,7 @@ tag(const Arg *arg)
|
||||
@@ -2558,7 +2827,7 @@ tag(const Arg *arg)
|
||||
sel->tags = arg->ui & TAGMASK;
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
@ -719,7 +751,7 @@ index 5867b0c..8341134 100644
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2603,6 +2881,14 @@ tile(Monitor *m)
|
||||
@@ -2603,6 +2872,14 @@ tile(Monitor *m)
|
||||
}
|
||||
}
|
||||
|
||||
@ -734,7 +766,7 @@ index 5867b0c..8341134 100644
|
||||
void
|
||||
togglefloating(const Arg *arg)
|
||||
{
|
||||
@@ -2631,7 +2917,7 @@ toggletag(const Arg *arg)
|
||||
@@ -2631,7 +2908,7 @@ toggletag(const Arg *arg)
|
||||
sel->tags = newtags;
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
@ -743,7 +775,7 @@ index 5867b0c..8341134 100644
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2644,7 +2930,7 @@ toggleview(const Arg *arg)
|
||||
@@ -2644,7 +2921,7 @@ toggleview(const Arg *arg)
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
@ -752,7 +784,7 @@ index 5867b0c..8341134 100644
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2692,7 +2978,7 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
@@ -2692,7 +2969,7 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
}
|
||||
|
||||
wlr_scene_node_destroy(&c->scene->node);
|
||||
@ -761,7 +793,7 @@ index 5867b0c..8341134 100644
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -2728,6 +3014,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
@@ -2728,6 +3005,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
if (m->wlr_output->enabled
|
||||
&& !wlr_output_layout_get(output_layout, m->wlr_output))
|
||||
wlr_output_layout_add_auto(output_layout, m->wlr_output);
|
||||
@ -769,21 +801,34 @@ index 5867b0c..8341134 100644
|
||||
}
|
||||
|
||||
/* Now that we update the output layout we can get its box */
|
||||
@@ -2788,6 +3075,13 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
@@ -2788,6 +3066,12 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
+ /* Update bar */
|
||||
+ wl_list_for_each(m, &mons, link) {
|
||||
+ m->b.width = m->wlr_output->width;
|
||||
+ m->b.height = bh;
|
||||
+ updatebardims(m);
|
||||
+ drawbar(m);
|
||||
+ }
|
||||
+
|
||||
/* FIXME: figure out why the cursor image is at 0,0 after turning all
|
||||
* the monitors on.
|
||||
* Move the cursor image where it used to be. It does not generate a
|
||||
@@ -2803,7 +3097,7 @@ updatetitle(struct wl_listener *listener, void *data)
|
||||
@@ -2798,12 +3082,21 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
wlr_output_manager_v1_set_configuration(output_mgr, config);
|
||||
}
|
||||
|
||||
+void
|
||||
+updatebardims(Monitor *m)
|
||||
+{
|
||||
+ int rw, rh;
|
||||
+ wlr_output_transformed_resolution(m->wlr_output, &rw, &rh);
|
||||
+ m->b.width = rw;
|
||||
+ m->b.height = bh;
|
||||
+}
|
||||
+
|
||||
void
|
||||
updatetitle(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, set_title);
|
||||
if (c == focustop(c->mon))
|
||||
@ -792,7 +837,7 @@ index 5867b0c..8341134 100644
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2816,7 +3110,7 @@ urgent(struct wl_listener *listener, void *data)
|
||||
@@ -2816,7 +3109,7 @@ urgent(struct wl_listener *listener, void *data)
|
||||
return;
|
||||
|
||||
c->isurgent = 1;
|
||||
@ -801,7 +846,7 @@ index 5867b0c..8341134 100644
|
||||
|
||||
if (client_surface(c)->mapped)
|
||||
client_set_border_color(c, urgentcolor);
|
||||
@@ -2832,7 +3126,7 @@ view(const Arg *arg)
|
||||
@@ -2832,7 +3125,7 @@ view(const Arg *arg)
|
||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
@ -810,7 +855,7 @@ index 5867b0c..8341134 100644
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2871,6 +3165,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
@@ -2871,6 +3164,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
{
|
||||
struct wlr_scene_node *node, *pnode;
|
||||
struct wlr_surface *surface = NULL;
|
||||
@ -818,7 +863,7 @@ index 5867b0c..8341134 100644
|
||||
Client *c = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
int layer;
|
||||
@@ -2879,9 +3174,12 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
@@ -2879,9 +3173,12 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
if (!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny)))
|
||||
continue;
|
||||
|
||||
@ -834,7 +879,7 @@ index 5867b0c..8341134 100644
|
||||
/* Walk the tree to find a node that knows the client */
|
||||
for (pnode = node; pnode && !c; pnode = &pnode->parent->node)
|
||||
c = pnode->data;
|
||||
@@ -3020,7 +3318,7 @@ sethints(struct wl_listener *listener, void *data)
|
||||
@@ -3020,7 +3317,7 @@ sethints(struct wl_listener *listener, void *data)
|
||||
return;
|
||||
|
||||
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
|
||||
@ -904,3 +949,6 @@ index 0000000..c7db188
|
||||
+ *state = utf8d[256 + *state*16 + type];
|
||||
+ return *state;
|
||||
+}
|
||||
--
|
||||
2.44.0
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
From 213d041523e36b7e4f8f2f527eb044bc2d3e9d3d Mon Sep 17 00:00:00 2001
|
||||
From 537bd7c485c1fb370d7a73f979ee140dab9c078e Mon Sep 17 00:00:00 2001
|
||||
From: sewn <sewn@disroot.org>
|
||||
Date: Tue, 19 Mar 2024 00:19:39 +0300
|
||||
Date: Mon, 25 Mar 2024 00:15:01 +0300
|
||||
Subject: [PATCH] port barpadding patch to bar for dwl
|
||||
|
||||
---
|
||||
config.def.h | 3 +++
|
||||
dwl.c | 16 ++++++++++------
|
||||
2 files changed, 13 insertions(+), 6 deletions(-)
|
||||
dwl.c | 14 +++++++++-----
|
||||
2 files changed, 12 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index bd008c9..a2cf167 100644
|
||||
@ -30,10 +30,10 @@ index bd008c9..a2cf167 100644
|
||||
static const char *fontattrs = "dpi=96";
|
||||
static pixman_color_t normbarfg = { 0xbbbb, 0xbbbb, 0xbbbb, 0xffff };
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 8341134..51ce9f0 100644
|
||||
index 976fefb..6650fdc 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -433,6 +433,8 @@ static Monitor *selmon;
|
||||
@@ -434,6 +434,8 @@ static Monitor *selmon;
|
||||
|
||||
static struct fcft_font *font;
|
||||
static int bh;
|
||||
@ -42,7 +42,7 @@ index 8341134..51ce9f0 100644
|
||||
static int lrpad;
|
||||
static char stext[256];
|
||||
static struct wl_event_source *status_event_source;
|
||||
@@ -570,8 +572,8 @@ arrangelayers(Monitor *m)
|
||||
@@ -571,8 +573,8 @@ arrangelayers(Monitor *m)
|
||||
return;
|
||||
|
||||
if (m->showbar) {
|
||||
@ -53,15 +53,6 @@ index 8341134..51ce9f0 100644
|
||||
}
|
||||
|
||||
/* Arrange exclusive surfaces from top->bottom */
|
||||
@@ -1018,7 +1020,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
|
||||
m->scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL);
|
||||
m->scene_buffer->point_accepts_input = bar_accepts_input;
|
||||
- m->b.width = m->wlr_output->width;
|
||||
+ m->b.width = m->wlr_output->width - 2 * sp;
|
||||
m->b.height = bh;
|
||||
m->showbar = showbar;
|
||||
|
||||
@@ -1501,8 +1503,8 @@ drawbar(Monitor *mon)
|
||||
}
|
||||
|
||||
@ -73,7 +64,7 @@ index 8341134..51ce9f0 100644
|
||||
wlr_scene_buffer_set_buffer(mon->scene_buffer, &buf->base);
|
||||
wlr_buffer_drop(&buf->base);
|
||||
}
|
||||
@@ -2756,6 +2758,8 @@ setup(void)
|
||||
@@ -2747,6 +2749,8 @@ setup(void)
|
||||
|
||||
lrpad = font->height;
|
||||
bh = font->height + 2;
|
||||
@ -82,15 +73,15 @@ index 8341134..51ce9f0 100644
|
||||
|
||||
status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy),
|
||||
STDIN_FILENO, WL_EVENT_READABLE, status_in, NULL);
|
||||
@@ -3077,7 +3081,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/* Update bar */
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
- m->b.width = m->wlr_output->width;
|
||||
+ m->b.width = m->wlr_output->width - 2 * sp;
|
||||
m->b.height = bh;
|
||||
drawbar(m);
|
||||
}
|
||||
--
|
||||
2.44.0
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user