[Spice-devel] [PATCH spice-html5] Use WheelEvent instead of MouseWheelEvent

Pavel Grunt pgrunt at redhat.com
Wed Jan 14 09:42:59 PST 2015


MouseWheelEvent is deprecated and not working in Firefox.
---
 display.js | 4 ++--
 inputs.js  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/display.js b/display.js
index 2aa5985..814ada6 100644
--- a/display.js
+++ b/display.js
@@ -691,7 +691,7 @@ SpiceDisplayConn.prototype.hook_events = function()
         canvas.addEventListener('keyup', handle_keyup);
         canvas.addEventListener('mouseout', handle_mouseout);
         canvas.addEventListener('mouseover', handle_mouseover);
-        canvas.addEventListener('mousewheel', handle_mousewheel);
+        canvas.addEventListener('wheel', handle_mousewheel);
         canvas.focus();
     }
 }
@@ -709,7 +709,7 @@ SpiceDisplayConn.prototype.unhook_events = function()
         canvas.removeEventListener('keyup', handle_keyup);
         canvas.removeEventListener('mouseout', handle_mouseout);
         canvas.removeEventListener('mouseover', handle_mouseover);
-        canvas.removeEventListener('mousewheel', handle_mousewheel);
+        canvas.removeEventListener('wheel', handle_mousewheel);
     }
 }
 
diff --git a/inputs.js b/inputs.js
index c904eda..29f4970 100644
--- a/inputs.js
+++ b/inputs.js
@@ -141,7 +141,7 @@ function handle_mousewheel(e)
 {
     var press = new SpiceMsgcMousePress;
     var release = new SpiceMsgcMouseRelease;
-    if (e.wheelDelta > 0)
+    if (e.deltaY < 0)
         press.button = release.button = SPICE_MOUSE_BUTTON_UP;
     else
         press.button = release.button = SPICE_MOUSE_BUTTON_DOWN;
-- 
1.9.3



More information about the Spice-devel mailing list