From a6de25225e1f8958e9efab47ecd1134263d661b3 Mon Sep 17 00:00:00 2001 From: rodri Date: Sun, 1 Oct 2023 12:16:12 +0000 Subject: fixed a Menulist.update bug where it would return 0 when there were no entries. --- menulist.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'menulist.c') diff --git a/menulist.c b/menulist.c index 9b439fa..90eaa31 100644 --- a/menulist.c +++ b/menulist.c @@ -68,10 +68,16 @@ menulist_update(Menulist *ml, Mousectl *mc, Channel *drawchan) /* redundant from bts.c:/^mouse\(, but it's necessary to avoid overdrawing */ static Mouse oldm; static ulong lastlmbms; + Rectangle r; int selected; + if(ml->nentries < 1) + return -1; + + r = ml->nentries < Maxvisitems? ml->r: Rpt(ml->sr.min, ml->r.max); + selected = -1; - if(ptinrect(mc->xy, Rpt(ml->sr.min, ml->r.max))){ + if(ptinrect(mc->xy, r)){ if(ptinrect(mc->xy, ml->r)){ /* item highlighting and selection */ ml->high = ml->off + (mc->xy.y - ml->r.min.y)/(font->height+Vspace); -- cgit v1.2.3