summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Down <chris@chrisdown.name>2021-12-18 16:58:23 +0000
committerHiltjo Posthuma <hiltjo@codemadness.org>2021-12-19 16:16:30 +0100
commit8657affa2a61e85ca8df76b62e43cb02897d1d80 (patch)
tree278fac042ed0989747aea5a80b8f1f5e92db4efa
parentRevert "Improve speed of drw_text when provided with large strings" (diff)
downloaddwm-8657affa2a61e85ca8df76b62e43cb02897d1d80.tar.gz
dwm-8657affa2a61e85ca8df76b62e43cb02897d1d80.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().
-rw-r--r--dwm.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index 5e4d494..a96f33c 100644
--- a/dwm.c
+++ b/dwm.c
@@ -702,6 +702,9 @@ drawbar(Monitor *m)
702 unsigned int i, occ = 0, urg = 0; 702 unsigned int i, occ = 0, urg = 0;
703 Client *c; 703 Client *c;
704 704
705 if (!m->showbar)
706 return;
707
705 /* draw status first so it can be overdrawn by tags later */ 708 /* draw status first so it can be overdrawn by tags later */
706 if (m == selmon) { /* status is only drawn on selected monitor */ 709 if (m == selmon) { /* status is only drawn on selected monitor */
707 drw_setscheme(drw, scheme[SchemeNorm]); 710 drw_setscheme(drw, scheme[SchemeNorm]);