git: 9front

Download patch

ref: 1201f3f8bfa95490b4e9dea2a053260a2b36ed26
parent: c9d4c3bd83310c8ea6cac3b6e7d989cdb19c9331
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Tue Sep 17 21:54:22 EDT 2013

libevent: drop queued mouse events

the changeset r541ead66e8af:

"libdraw: make ebread() return buffer immidiately if available"

makes mouse sluggish when the program cant keep up as mouse
events queue up. this more or less restores the original
behaviour but only for mouse events.

--- a/sys/src/libdraw/event.c
+++ b/sys/src/libdraw/event.c
@@ -385,7 +385,12 @@
 
 	if(Smouse < 0)
 		drawerror(display, "events: mouse not initialized");
-	eb = ebread(&eslave[Smouse]);
+	for(;;){
+		eb = ebread(&eslave[Smouse]);
+		if(!ecanmouse())
+			break;
+		free(eb);	/* drop queued mouse events */
+	}
 	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);
--