Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8242419: JFXPanel: MouseEvent always reports that Primary button changed state if held #1170

Closed
wants to merge 3 commits into from

Conversation

prsadhuk
Copy link
Collaborator

@prsadhuk prsadhuk commented Jul 5, 2023

If an EventHandler or EventFilter for a mouse button is attached to a scene within a JFXPanel and the primary mouse button is held, any mouse button click will create an event such that event.getButton().name() wrongly returns PRIMARY, even if the secondary or middle button was clicked.
This is because SwingEvents.mouseButtonToEmbedMouseButton() overwrites the button name after checking the modifier value.
For mouse click with primary button mouseButtonToEmbedMouseButton is first called with BUTTON1 and modifier BUTTON1_DOWN_MASK (ie 1024) and then when secondary button(ie right button is clicked) mouseButtonToEmbedMouseButton is called with BUTTON3 and modifier BUTTON3_DOWN_MASK | BUTTON1_DOWN_MASK (ie 5120)
and when secondary button is released, mouseButtonToEmbedMouseButton is again called with BUTTON3 but with modifier BUTTON1_DOWN_MASK (1024) resulting in button being declared PRIMARY.

Fix is to make sure not to overwrite button name if a button name is already assigned.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8242419: JFXPanel: MouseEvent always reports that Primary button changed state if held (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1170/head:pull/1170
$ git checkout pull/1170

Update a local copy of the PR:
$ git checkout pull/1170
$ git pull https://git.openjdk.org/jfx.git pull/1170/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1170

View PR using the GUI difftool:
$ git pr show -t 1170

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1170.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 5, 2023

👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Jul 5, 2023
@mlbridge
Copy link

mlbridge bot commented Jul 5, 2023

Webrevs

@prsadhuk
Copy link
Collaborator Author

prsadhuk commented Jul 7, 2023

Any further comments on this @andy-goryachev-oracle ?

Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified the code test thusly:

        scene.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> System.out.println("Button clicked: " + event.getButton().name()));
        scene.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> System.out.println("Button pressed: " + event.getButton().name()));
        scene.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> System.out.println("Button released: " + event.getButton().name()));

tested with the fix (works as expected) and without the fix (fails as expected).

@openjdk
Copy link

openjdk bot commented Jul 7, 2023

@prsadhuk This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8242419: JFXPanel: MouseEvent always reports that Primary button changed state if held

Reviewed-by: angorya

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 101 new commits pushed to the master branch:

  • 5aad040: 8311127: Regression: The fix for TableView and TreeTableView menu button affects all table column headers
  • 8fd2943: 8283551: ControlAcceleratorSupport menu items listener causes memory leak
  • 8b1a446: 8310638: Filtering a TableView with a large number of items freezes the UI
  • d010d41: 8310846: Skip failing test InitialWindowSizeTest on Linux
  • d2683b9: 8302511: HitInfo.toString() throws IllegalArgumentException
  • 152a43e: 8310667: Normalize comment blocks in newly-converted package-info.java files
  • c224615: 8180066: Convert package.html files to package-info.java
  • a17a714: 8299348: Size-restricted window can be observed with incorrect dimensions
  • 77c43e0: 8304290: Some JNI calls made without checking exceptions in media
  • 0d9dcf3: 8264449: Enable reproducible builds with SOURCE_DATE_EPOCH
  • ... and 91 more: https://git.openjdk.org/jfx/compare/4051f1611646400b59ee871fb40399b933361ba2...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Ready to be integrated label Jul 7, 2023
@prsadhuk
Copy link
Collaborator Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 10, 2023

Going to push as commit 8635f81.
Since your change was applied there have been 101 commits pushed to the master branch:

  • 5aad040: 8311127: Regression: The fix for TableView and TreeTableView menu button affects all table column headers
  • 8fd2943: 8283551: ControlAcceleratorSupport menu items listener causes memory leak
  • 8b1a446: 8310638: Filtering a TableView with a large number of items freezes the UI
  • d010d41: 8310846: Skip failing test InitialWindowSizeTest on Linux
  • d2683b9: 8302511: HitInfo.toString() throws IllegalArgumentException
  • 152a43e: 8310667: Normalize comment blocks in newly-converted package-info.java files
  • c224615: 8180066: Convert package.html files to package-info.java
  • a17a714: 8299348: Size-restricted window can be observed with incorrect dimensions
  • 77c43e0: 8304290: Some JNI calls made without checking exceptions in media
  • 0d9dcf3: 8264449: Enable reproducible builds with SOURCE_DATE_EPOCH
  • ... and 91 more: https://git.openjdk.org/jfx/compare/4051f1611646400b59ee871fb40399b933361ba2...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 10, 2023
@openjdk openjdk bot closed this Jul 10, 2023
@openjdk openjdk bot removed ready Ready to be integrated rfr Ready for review labels Jul 10, 2023
@openjdk
Copy link

openjdk bot commented Jul 10, 2023

@prsadhuk Pushed as commit 8635f81.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@prsadhuk prsadhuk deleted the JDK-8242419 branch July 10, 2023 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
2 participants