shithub: riscv

Download patch

ref: 7295fa71a42de4a5bb4f2449005d71251899d062
parent: 4041ea394ba19b45122ed8f661478ef9b562e138
author: cinap_lenrek <[email protected]>
date: Mon Jan 7 22:45:49 EST 2013

libdraw: fix wrong menusel() calculation for menuhit() (noticable with small fonts)

the text for a menu entry is drawn from:

y = textr.min.y + i*(font->height+Vspacing);

but we calculated the item from:

r = insetrect(textr);
i = (p.y - r.min.y) / (font->height+Vspacing);

the insetrect is wrong.

--- a/sys/src/libdraw/emenuhit.c
+++ b/sys/src/libdraw/emenuhit.c
@@ -68,7 +68,6 @@
 static int
 menusel(Rectangle r, Point p)
 {
-	r = insetrect(r, Margin);
 	if(!ptinrect(p, r))
 		return -1;
 	return (p.y-r.min.y)/(font->height+Vspacing);
--- a/sys/src/libdraw/menuhit.c
+++ b/sys/src/libdraw/menuhit.c
@@ -69,7 +69,6 @@
 static int
 menusel(Rectangle r, Point p)
 {
-	r = insetrect(r, Margin);
 	if(!ptinrect(p, r))
 		return -1;
 	return (p.y-r.min.y)/(font->height+Vspacing);