shithub: riscv

Download patch

ref: 6d97f77c2d95abcdf13593e8530c1f9f7ae1cd87
parent: e5dc3ade08ce91785ff889341941460ce72ba03f
author: cinap_lenrek <[email protected]>
date: Fri Oct 21 20:04:21 EDT 2016

libdraw: avoid dropping queued button change mouse events in emouse()

--- a/sys/src/libdraw/event.c
+++ b/sys/src/libdraw/event.c
@@ -380,7 +380,7 @@
 {
 	Mouse m;
 	Ebuf *eb;
-	static but[2];
+	static int lastb;
 	int b;
 
 	if(Smouse < 0)
@@ -387,14 +387,15 @@
 		drawerror(display, "events: mouse not initialized");
 	for(;;){
 		eb = ebread(&eslave[Smouse]);
-		if(!ecanmouse())
+		b = atoi((char*)eb->buf+1+2*12);
+		if(b != lastb || !ecanmouse())
 			break;
 		free(eb);	/* drop queued mouse events */
 	}
+	lastb = b;
+	m.buttons = b;
 	m.xy.x = atoi((char*)eb->buf+1+0*12);
 	m.xy.y = atoi((char*)eb->buf+1+1*12);
-	b = atoi((char*)eb->buf+1+2*12);
-	m.buttons = b;
 	m.msec = atoi((char*)eb->buf+1+3*12);
 	if (logfid)
 		fprint(logfid, "b: %d xy: %P\n", m.buttons, m.xy);