aboutsummaryrefslogtreecommitdiff
path: root/src/library_glut.js
diff options
context:
space:
mode:
authorPierre Renaux <pierre@talansoft.com>2012-04-06 12:45:09 +0800
committerPierre Renaux <pierre@talansoft.com>2012-04-06 12:45:09 +0800
commit096b56b5c5432d022e7e1a011609c727de12e591 (patch)
treef235ef099b400a33d093bd039684e8435e4c0733 /src/library_glut.js
parent7576b2ae14865d3df282411c92d72033d0c336c4 (diff)
[src/library_glut.js]: Call motion callbacks only if motion position changed ;
Diffstat (limited to 'src/library_glut.js')
-rw-r--r--src/library_glut.js9
1 files changed, 9 insertions, 0 deletions
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();