Duplicate MouseWheelMovedEvent was not actually fixed 59/2659/2
authorjsimomaa <jani.simomaa@gmail.com>
Tue, 19 Feb 2019 12:04:45 +0000 (14:04 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Tue, 19 Feb 2019 17:05:59 +0000 (17:05 +0000)
gitlab #64

Change-Id: I4989c4f57e0a1f44a3366640c6e756ad2c93c4ad

bundles/org.simantics.g2d/src/org/simantics/g2d/event/adapter/SWTMouseEventAdapter.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/EventQueue.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/MouseEvent.java

index 924c7c252b47a929183cfcb4403784486d5f1615..1da7fe6472ee78af0900d84d64f85ba3a9e5d312 100644 (file)
@@ -166,8 +166,8 @@ public class SWTMouseEventAdapter extends AbstractEventAdapter implements MouseL
                                sender, e.time & 0xffffffff, MOUSE_ID, buttonStatus, 
                                getStateMask(e),
                                getControlPosition(e), getScreenPosition(e), 
-                               MouseWheelMovedEvent.WHEEL_UNIT_SCROLL, 
-                               0, 
+                               MouseWheelMovedEvent.WHEEL_UNIT_SCROLL,
+                               MouseWheelMovedEvent.SCROLL_AMOUNT_ZERO,
                                e.count
                                ));
        }
index 9b0980600990695e785e2d1040c58ae6e13f4a16..d3ab613557cc874858b40c36d76d4cf6555e57c3 100644 (file)
@@ -42,20 +42,19 @@ public class EventQueue implements IEventQueue, IEventHandler {
         return EventTypes.AnyMask;
     }
 
-    /**
-     * 
-     */
-    private MouseWheelMovedEvent lastMouseWheelMovedEvent;
-    
     private static final String DISABLE_DUPLICATE_REMOVAL = "org.simantics.scenegraph.g2d.events.disableDuplicateMouseWheelEvent";
     private static final boolean IGNORE_DUPLICATE = !Boolean.parseBoolean(System.getProperty(DISABLE_DUPLICATE_REMOVAL));
     
     private boolean ignoreDuplicateMouseWheelMovedEvent(Event e) {
         if (IGNORE_DUPLICATE && e instanceof MouseWheelMovedEvent) {
-            if (e.time > 0 && (lastMouseWheelMovedEvent != null && lastMouseWheelMovedEvent.time < 0)) {
+            MouseWheelMovedEvent event = (MouseWheelMovedEvent) e;
+            // if (e.time > 0 && (lastMouseWheelMovedEvent != null && lastMouseWheelMovedEvent.time < 0)) {
+            // apparently this is a better way to distinguish between SWT & AWT events
+            // SWT based event constructs the scrollAmount to = 0
+            // See org.simantics.g2d.event.adapter.SWTMouseEventAdapter.mouseScrolled(MouseEvent) L171
+            if (event.scrollAmount != MouseWheelMovedEvent.SCROLL_AMOUNT_ZERO) {
                 return true;
             }
-            lastMouseWheelMovedEvent = (MouseWheelMovedEvent) e;
         }
         return false;
     }
index 92c97b78766c2548f9ea10a3d334a1e4fa6b6972..8070ae35821de1999da64ef0638a9081764c1827 100644 (file)
@@ -154,6 +154,8 @@ public abstract class MouseEvent extends Event {
 
         private static final long serialVersionUID = -7896477913481842708L;
 
+        public static final int SCROLL_AMOUNT_ZERO = 0;
+
         /**
          * Constant representing scrolling by "units" (like scrolling with the
          * arrow keys)