From: jsimomaa Date: Tue, 19 Feb 2019 12:04:45 +0000 (+0200) Subject: Duplicate MouseWheelMovedEvent was not actually fixed X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F96%2F2696%2F1;p=simantics%2Fplatform.git Duplicate MouseWheelMovedEvent was not actually fixed gitlab #64 Change-Id: I4989c4f57e0a1f44a3366640c6e756ad2c93c4ad (cherry picked from commit 162f92e52a7efa9fd0067666be6e9dfd28ec1e51) --- diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/event/adapter/SWTMouseEventAdapter.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/event/adapter/SWTMouseEventAdapter.java index 924c7c252..1da7fe647 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/event/adapter/SWTMouseEventAdapter.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/event/adapter/SWTMouseEventAdapter.java @@ -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 )); } diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/EventQueue.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/EventQueue.java index 9b0980600..d3ab61355 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/EventQueue.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/EventQueue.java @@ -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; } diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/MouseEvent.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/MouseEvent.java index 92c97b787..8070ae358 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/MouseEvent.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/MouseEvent.java @@ -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)