From 096b56b5c5432d022e7e1a011609c727de12e591 Mon Sep 17 00:00:00 2001 From: Pierre Renaux Date: Fri, 6 Apr 2012 12:45:09 +0800 Subject: [src/library_glut.js]: Call motion callbacks only if motion position changed ; --- src/library_glut.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/library_glut.js') diff --git a/src/library_glut.js b/src/library_glut.js index cdbb347b..f1a3f00e 100644 --- a/src/library_glut.js +++ b/src/library_glut.js @@ -36,6 +36,15 @@ var LibraryGLUT = { }, onMousemove: function(event) { + /* Pierre: Send motion event only if the motion changed, prevents + * spamming our app with uncessary callback call. It does happen in + * Chrome on Windows. + */ + var newX = event['clientX'] - Module['canvas'].offsetLeft; + var newY = event['clientY'] - Module['canvas'].offsetTop; + if (newX == GLUT['lastX'] && newY == GLUT['lastY']) + return; + GLUT.savePosition(event); if (GLUT.buttons == 0 && event.target == Module["canvas"] && GLUT.passiveMotionFunc) { event.preventDefault(); -- cgit v1.2.3-18-g5258