Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8173983

[macosx] spurious MouseWheelEvents after trackpad two-finger mouse press on OS X

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      os_x

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_121"
      Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      OS X Sierra

      A DESCRIPTION OF THE PROBLEM :
      With a two-finger "right click" on a laptop trackpad, there may be several spurious MouseWheelEvents with precise rotation of -0.0. This seems to happen more consistently after a two-finger scroll.

      These events will cause popup menus to pop down, so it may become difficult to get a popup menu activated by right click to stay up using a two-finger trackpad click - it may just pop up and immediately pop down.

      This does not happen on update 111. I'm unsure about 112.

      REGRESSION. Last worked in version 8u111

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run code. Perform a two-finger trackpad scroll. Perform two-finger trackpad clicks until the problem manifests.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect each two finger click to produce MousePressed, MouseReleased, and MouseClicked events only.
      ACTUAL -
      Typically, two or more MouseWheelEvents are produced, with precise rotation of -0.0.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Typical program output once the problem manifests:

      pressed 4 at 1486152597537
      wheel event 4 amount 1 precise -0.0 at 1486152597541
      released 4 at 1486152597796
      clicked 4 at 1486152597796
      wheel event 0 amount 1 precise -0.0 at 1486152597888

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------

      import javax.swing.*;
      import java.awt.event.*;

      public class MouseWheelTest extends JFrame {

         public static void main(String[] args) {
            SwingUtilities.invokeLater(
               new Runnable() {
                  public void run() {
                     (new MouseWheelTest()).setVisible(true);
                  }
               });
         }

         public MouseWheelTest() {
            setSize(600, 600);
            JLabel label = new JLabel("test");
            getContentPane().add(label);
            
            label.addMouseListener(
               new MouseAdapter() {
                  public void mousePressed(MouseEvent e) {
                     System.out.println("pressed " + e.getModifiers()
                           + " at " + System.currentTimeMillis());
                  }
                  public void mouseClicked(MouseEvent e) {
                     System.out.println("clicked " + e.getModifiers()
                           + " at " + System.currentTimeMillis());
                  }
                  public void mouseReleased(MouseEvent e) {
                     System.out.println("released " + e.getModifiers()
                           + " at " + System.currentTimeMillis());
                  }
               });
            
            label.addMouseWheelListener(
                      new MouseWheelListener() {
                         public void mouseWheelMoved(MouseWheelEvent e) {
                            System.out.println("wheel event " + e.getModifiers()
                                 + " amount " + e.getScrollAmount()
                                 + " precise " + e.getPreciseWheelRotation()
                                 + " at " + System.currentTimeMillis());
                         }
                      });
         }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Will try filtering MouseWheelEvents with precise rotation of -0.0 in an AWTEventListener, but I don't have access to the problem system (or a similar one), so would be concerned about side effects.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: