Re: [hackers] [dwm][PATCH] drawbar: Don't expend effort drawing bar if it is occluded

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun, 19 Dec 2021 16:17:13 +0100

On Sat, Dec 18, 2021 at 04:58:23PM +0000, Chris Down wrote:
> 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().
> ---
> dwm.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/dwm.c b/dwm.c
> index 5e4d494..a96f33c 100644
> --- a/dwm.c
> +++ b/dwm.c
> _AT_@ -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]);
> --
> 2.34.1
>
>

Hi Chris,

Applied, thank you.

-- 
Kind regards,
Hiltjo
Received on Sun Dec 19 2021 - 16:17:13 CET

This archive was generated by hypermail 2.3.0 : Sun Dec 19 2021 - 16:24:31 CET