summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2022-01-10 17:16:09 +0100
committerbakkeby <[email protected]>2022-01-10 17:16:09 +0100
commit0350db1b3917d74ac0565fff3d5537f246ab4ff0 (patch)
treeddce9d8ecc6d18a96c86ac574833443f82e5a384
parent9ea0cb6c7c6863f58c332438cc4dae1cc156db56 (diff)
downloaddwm-flexipatch-0350db1b3917d74ac0565fff3d5537f246ab4ff0.tar.gz
dwm-flexipatch-0350db1b3917d74ac0565fff3d5537f246ab4ff0.zip
drawbar: Don't expend effort drawing bar if it is occluded
I noticed that a non-trivial amount of dwm's work on my machine was from drw_text, which seemed weird, because I have the bar disabled and we only use drw_text as part of bar drawing. Looking more closely, I realised that while we use m->showbar when updating the monitor bar margins, but don't skip actually drawing the bar if it is hidden. This patch skips drawing it entirely if that is the case. On my machine, this takes 10% of dwm's on-CPU time, primarily from restack() and focus(). When the bar is toggled on again, the X server will generate an Expose event, and we'll redraw the bar as normal as part of expose(). Ref. https://git.suckless.org/dwm/commit/8657affa2a61e85ca8df76b62e43cb02897d1d80.html
-rw-r--r--dwm.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/dwm.c b/dwm.c
index 70ef5e7..99299a7 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1753,8 +1753,10 @@ void
drawbar(Monitor *m)
{
Bar *bar;
- for (bar = m->bar; bar; bar = bar->next)
- drawbarwin(bar);
+
+ if (m->showbar)
+ for (bar = m->bar; bar; bar = bar->next)
+ drawbarwin(bar);
}
void
@@ -3948,6 +3950,10 @@ togglebar(const Arg *arg)
updatebarpos(selmon);
for (bar = selmon->bar; bar; bar = bar->next)
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
+ #if BAR_SYSTRAY_PATCH
+ if (!selmon->showbar && systray)
+ XMoveWindow(dpy, systray->win, -32000, -32000);
+ #endif // BAR_SYSTRAY_PATCH
arrange(selmon);
}