libdraw: avoid moving cursor if we dont have to for menuhit

depending on the font, poping the menu would move your cursor
one pixel down each time (due to division). this is annoying
when using a trackpoint and trying to repeat some operation
over 9000 times.

the cursor should only be moved when the menu is repositioned
to contain it on the screen.
This commit is contained in:
cinap_lenrek 2013-06-18 23:23:41 +02:00
parent d7c7c7e4b3
commit b5659c0977
2 changed files with 4 additions and 2 deletions

View file

@ -230,7 +230,8 @@ emenuhit(int but, Mouse *m, Menu *menu)
border(screen, menur, Blackborder, bord, ZP);
save = allocimage(display, menurect(textr, 0), screen->chan, 0, -1);
r = menurect(textr, lasti);
emoveto(divpt(addpt(r.min, r.max), 2));
if(pt.x || pt.y)
emoveto(divpt(addpt(r.min, r.max), 2));
menupaint(menu, textr, off, nitemdrawn);
if(scrolling)
menuscrollpaint(scrollr, off, nitem, nitemdrawn);

View file

@ -234,7 +234,8 @@ menuhit(int but, Mousectl *mc, Menu *menu, Screen *scr)
border(b, menur, Blackborder, bord, ZP);
save = allocimage(display, menurect(textr, 0), screen->chan, 0, -1);
r = menurect(textr, lasti);
moveto(mc, divpt(addpt(r.min, r.max), 2));
if(pt.x || pt.y)
moveto(mc, divpt(addpt(r.min, r.max), 2));
menupaint(b, menu, textr, off, nitemdrawn);
if(scrolling)
menuscrollpaint(b, scrollr, off, nitem, nitemdrawn);