That ellipsis_w guard makes sense to add.

You are right in that it is simpler to call drw_text. If we make another
call to XftDrawStringUtf8 then we also need to recalculate ty.



On Sun, Mar 27, 2022 at 8:52 PM NRK <[email protected]> wrote:

> On Sat, Mar 26, 2022 at 12:02:12AM +0100, Stein Gunnar Bakkeby wrote:
> > for the first patch, what was the incentive for making a call to drw_text
> > to draw the ellipsis rather than making another call to
> XftDrawStringUtf8?
>
> Was simpler to just call drw_text.
>
> > As-is, and I am primarily thinking of the bar in dwm in this case, if you
> > were to have limited space and there is only enough space to write one or
> > two characters then you have a situation where the ellipsis would never
> > fit, but the text will overflow.
> >
> > In this situation the ellipsis_w variable will remain 0 and drw_text is
> > called again with a width of 0 to draw the ellipsis. I believe it might
> > crash with that.
>
> Hmm, how about this:
>
> diff --git a/drw.c b/drw.c
> index 4cccf47..411bcdd 100644
> --- a/drw.c
> +++ b/drw.c
> @@ -336,7 +336,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w,
> unsigned int h, unsigned int lp
>                         x += ew;
>                         w -= ew;
>                 }
> -               if (render && overflow)
> +               if (render && overflow && ellipsis_w)
>                         drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0,
> "...", invert);
>
>                 if (!*text || overflow) {
>
>
> - NRK
>
>

-- 
Stein Gunnar Bakkeby
OpenBet Developer
[email protected]

Reply via email to