Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
drawbar: Don't expend effort drawing bar if it is occluded
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
cdown authored and hiltjo committed Dec 19, 2021
1 parent a786211 commit 8657aff
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ drawbar(Monitor *m)
unsigned int i, occ = 0, urg = 0;
Client *c;

if (!m->showbar)
return;

/* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
drw_setscheme(drw, scheme[SchemeNorm]);
Expand Down

0 comments on commit 8657aff

Please sign in to comment.