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

Two fingers tap generates wrong mouse modifiers on M2 MacBooks

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 20
    • 11, 17, 19, 20
    • client-libs
    • b20
    • os_x

    Backports

      Description

        Tapping (not pressing) on Apple M2 MacBooks with two fingers on a trackpad generates wrong mouse modifiers (which are returned by MouseEvent.getModifiersEx).

        Steps to reproduce
        1. Enable System Preferences -> Trackpad -> Tap to click
        2. Tap with two fingers in the following app:
        import javax.swing.*;
        import java.awt.event.MouseAdapter;
        import java.awt.event.MouseEvent;

        class MouseWindow {
            final JFrame frame;

            MouseWindow() {
                frame = new JFrame();
                frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

                frame.setTitle("Mouse window");

                frame.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mousePressed(MouseEvent e) {
                        System.out.println(e);
                    }
                });

                frame.pack();

                frame.setSize(300, 300);

                frame.setVisible(true);
            }

            public static void main(String[] args) {
                SwingUtilities.invokeLater(MouseWindow::new);
            }
        }

        Expected

        Printed mouse event has modifiersEx is 4096 (which is InputEvent.BUTTON3_DOWN_MASK)

        Actual

        Printed mouse event has modifiersEx is 4352 (which is InputEvent.BUTTON3_DOWN_MASK | InputEvent.META_DOWN_MASK)

        The bug is 100% reproducible on M2 MacBooks (at least under macOS 12.5). It's also reproducible on M1 MacBooks, but much more rarely (about 10-15% of reproducibility).

        Attachments

          Issue Links

            Activity

              People

                mkartashev Maxim Kartashev
                mkartashev Maxim Kartashev
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: