git: 9front

Download patch

ref: aba471da9b56ca4573a4cde49797dbbe5768b1e0
parent: 1e6334b12ded6f28ed91c372f1d3e6d7c41a9a99
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Tue Jun 18 19:23:41 EDT 2013

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.

--- a/sys/src/libdraw/emenuhit.c
+++ b/sys/src/libdraw/emenuhit.c
@@ -230,7 +230,8 @@
 	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);
--- a/sys/src/libdraw/menuhit.c
+++ b/sys/src/libdraw/menuhit.c
@@ -234,7 +234,8 @@
 	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);
--