diff options
author | rodri <rgl@antares-labs.eu> | 2023-10-01 12:16:12 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-10-01 12:16:12 +0000 |
commit | a6de25225e1f8958e9efab47ecd1134263d661b3 (patch) | |
tree | b682b21b45e8eed2e3e8fec84c3157c4ca2ed9f8 /menulist.c | |
parent | 44a3faf02ec337da6377fa9a00e4ea7cb7d4e913 (diff) | |
download | battleship-a6de25225e1f8958e9efab47ecd1134263d661b3.tar.gz battleship-a6de25225e1f8958e9efab47ecd1134263d661b3.tar.bz2 battleship-a6de25225e1f8958e9efab47ecd1134263d661b3.zip |
fixed a Menulist.update bug where it would return 0 when there were no entries.
Diffstat (limited to 'menulist.c')
-rw-r--r-- | menulist.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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); |