8049533: SwingUtilities.convertMouseEvent misses MouseWheelEvent.preciseWheelRotation
authoralexsch
Fri, 08 Aug 2014 16:13:15 +0400
changeset 26032 a60a06edaf4e
parent 26031 812d3082ba6f
child 26033 3f7c9aad7cc0
8049533: SwingUtilities.convertMouseEvent misses MouseWheelEvent.preciseWheelRotation Reviewed-by: serb, pchelko
jdk/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java
jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java
jdk/src/share/classes/javax/swing/SwingUtilities.java
jdk/test/javax/swing/SwingUtilities/8049533/bug8049533.java
--- a/jdk/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java	Fri Aug 08 16:05:52 2014 +0400
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaInternalFrameUI.java	Fri Aug 08 16:13:15 2014 +0400
@@ -938,7 +938,11 @@
             final Point pt = new Point();
             final Component c = getComponentToForwardTo(e, pt);
             if (c == null) return;
-            c.dispatchEvent(new MouseWheelEvent(c, e.getID(), e.getWhen(), e.getModifiers(), pt.x, pt.y, e.getClickCount(), e.isPopupTrigger(), e.getScrollType(), e.getScrollAmount(), e.getWheelRotation()));
+            c.dispatchEvent(new MouseWheelEvent(c, e.getID(), e.getWhen(),
+                    e.getModifiers(), pt.x, pt.y, e.getXOnScreen(), e.getYOnScreen(),
+                    e.getClickCount(), e.isPopupTrigger(), e.getScrollType(),
+                    e.getScrollAmount(), e.getWheelRotation(),
+                    e.getPreciseWheelRotation()));
         }
 
         public void componentResized(final ComponentEvent e) {
--- a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Fri Aug 08 16:05:52 2014 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Fri Aug 08 16:13:15 2014 +0400
@@ -1233,11 +1233,13 @@
                     delegate, me.getID(), me.getWhen(),
                     me.getModifiers(),
                     me.getX(), me.getY(),
+                    me.getXOnScreen(), me.getYOnScreen(),
                     me.getClickCount(),
                     me.isPopupTrigger(),
                     me.getScrollType(),
                     me.getScrollAmount(),
-                    me.getWheelRotation());
+                    me.getWheelRotation(),
+                    me.getPreciseWheelRotation());
         } else if (e instanceof MouseEvent) {
             MouseEvent me = (MouseEvent) e;
 
--- a/jdk/src/share/classes/javax/swing/SwingUtilities.java	Fri Aug 08 16:05:52 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/SwingUtilities.java	Fri Aug 08 16:13:15 2014 +0400
@@ -374,7 +374,8 @@
                                            sourceWheelEvent.isPopupTrigger(),
                                            sourceWheelEvent.getScrollType(),
                                            sourceWheelEvent.getScrollAmount(),
-                                           sourceWheelEvent.getWheelRotation());
+                                           sourceWheelEvent.getWheelRotation(),
+                                           sourceWheelEvent.getPreciseWheelRotation());
         }
         else if (sourceEvent instanceof MenuDragMouseEvent) {
             MenuDragMouseEvent sourceMenuDragEvent = (MenuDragMouseEvent)sourceEvent;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/SwingUtilities/8049533/bug8049533.java	Fri Aug 08 16:13:15 2014 +0400
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Frame;
+import java.awt.Panel;
+import java.awt.event.MouseWheelEvent;
+import javax.swing.SwingUtilities;
+
+/**
+ * @test
+ * @bug 8049533
+ * @summary SwingUtilities.convertMouseEvent misses
+ *      MouseWheelEvent.preciseWheelRotation
+ * @run main bug8049533
+ */
+public class bug8049533 {
+
+    private static final double PRECISE_WHEEL_ROTATION = 3.14;
+
+    public static void main(String[] args) {
+        Frame frame = new Frame();
+        Panel panel = new Panel();
+        frame.add(panel);
+
+        MouseWheelEvent event = new MouseWheelEvent(panel,
+                0, 0, 0, 0, 0, 0, 0, 0, false, 0, 0,
+                2, // wheelRotation
+                PRECISE_WHEEL_ROTATION); // preciseWheelRotation
+
+        MouseWheelEvent convertedEvent = (MouseWheelEvent) SwingUtilities.
+                convertMouseEvent(event.getComponent(), event, null);
+
+        if (convertedEvent.getPreciseWheelRotation() != PRECISE_WHEEL_ROTATION) {
+            throw new RuntimeException("PreciseWheelRotation field is not copied!");
+        }
+    }
+}