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

8280993: [XWayland] Popup is not closed on click outside of area controlled by XWayland #13830

Closed

Conversation

azvegint
Copy link
Member

@azvegint azvegint commented May 5, 2023

On Linux systems, we rely on XGrabPointer (X11 API) to capture mouse input and dismiss popup menus on mouse clicks outside the popup menu.
Unfortunately, on Linux systems using the Wayland session this only works inside XWayland(Wayland's X11 server implementation).
This means if a user clicks on a part of the screen not controlled by XWayland (e.g. window decorations, other non X11 applications) the popup menu will not be hidden.

As a workaround, we can hide this menu when the parent popup menu window loses focus.
However, it does have its drawbacks, which should be described in the documentation.The focus does not change when clicking on the header of its own parent window or on non-focusable windows, .e.g., empty space in system dock, so in this case the popup menu is not hidden.

Third-party applications use a similar approach.

I also have doubts about the need to change the documentation, as I can't find where it is described that the popup menu should be hidden when clicked outside the menu.

CSR: https://bugs.openjdk.org/browse/JDK-8307529


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

Issues

  • JDK-8280993: [XWayland] Popup is not closed on click outside of area controlled by XWayland
  • JDK-8307529: [XWayland] Popup is not closed on click outside of area controlled by XWayland (CSR) (Withdrawn)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13830

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13830.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 5, 2023

👋 Welcome back azvegint! 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 csr Pull request needs approved CSR before integration rfr Pull request is ready for review labels May 5, 2023
@openjdk
Copy link

openjdk bot commented May 5, 2023

@azvegint The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label May 5, 2023
@mlbridge
Copy link

mlbridge bot commented May 5, 2023

Webrevs

@mkartashev
Copy link
Member

I also have doubts about the need to change the documentation, as I can't find where it is described that the popup menu should be hidden when clicked outside the menu.

FWIW, I agree that you only need to change the documentation if someone can actually point to where it says that popup hides when there's a mouse click outside its bounds. Otherwise the implementation notes seem to do more harm (by confusing the reader) than good.

@@ -43,6 +43,10 @@
* (e.g., you add it to a {@code MenuBar}), then you <b>cannot</b>
* call {@code show} on that {@code PopupMenu}.
*
* @implNote On Linux systems using Wayland, the popup menu may not be dismissed
Copy link
Member

Choose a reason for hiding this comment

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

I guess the XWayland is affected, but implementation of the toolkit for Wayland will not have this issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

It should, and this is another point about not changing the documentation.

Copy link
Member

Choose a reason for hiding this comment

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

Then let's not update it.

Copy link
Member Author

@azvegint azvegint May 9, 2023

Choose a reason for hiding this comment

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

Rolled back the document changes.

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label May 9, 2023
* @implNote On Linux systems using Wayland, the popup menu may not be dismissed
* by clicking on the decorations of its own parent window
* and on some system panels.
*
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I agree with others that its questionable if we need to say this at all.
It would be odd to specify the places you can click to dismiss a popup, so unless
we already do that, we don't need to start now.

@@ -758,6 +764,62 @@ public void pack() {
}
}

// We rely on the X11 input grab mechanism, but for the Wayland session
Copy link
Contributor

Choose a reason for hiding this comment

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

Whilst we need to do this, having all this code discussing Wayland here in JPopupMenu is really the wrong place.
This needs to be re-done in a way that is about the specific problem which is something like
SunToolkit.clickOutsideWillDismissPopup()
and the word "Wayland" shouldn't appear anywhere here.

IIUC this fix is needed so that a number of tests that fail now because of this problem will be able to pass, so it would be good to get it in soon so I can get a clearer picture of what remaining test issues we have.

Copy link
Member Author

@azvegint azvegint May 19, 2023

Choose a reason for hiding this comment

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

Sure, moved to toolkit.

IIUC this fix is needed so that a number of tests that fail now because of this problem will be able to pass, so it would be good to get it in soon so I can get a clearer picture of what remaining test issues we have.

This only affects manual tests, as automatic tests use the XTest API, which works correctly with X11 Input Grab.

Besides, this is a real use case that can be annoying. This change doesn't fix the problem completely (we still can't hide the menu by clicking on the title bar of our own window or on non-focusable windows such as the desktop), but it definitely makes the user experience better.

@@ -758,6 +759,16 @@ public void pack() {
}
}

private Window getMenuInvoker() {
if (invoker instanceof Window menuInvoker) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Pattern matching for instanceof is used.
Maybe we shouldn't use this if we plan to backport this change to the JDK < 16

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't worry about that.

@openjdk
Copy link

openjdk bot commented May 19, 2023

@azvegint 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:

8280993: [XWayland] Popup is not closed on click outside of area controlled by XWayland

Reviewed-by: prr

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 245 new commits pushed to the master branch:

  • 265f40b: 8308396: Fix offset_of conversion warnings in runtime code
  • a5343fa: 8281149: (fs) java/nio/file/FileStore/Basic.java fails with java.lang.RuntimeException: values differ by more than 1GB
  • 44218b1: 8308248: Revisit alignment of layout constants on 32-bit platforms
  • 80ef5c2: 8308410: broken compilation of test\jdk\tools\launcher\exeJliLaunchTest.c
  • 326d778: 8306057: False arguments calling dispatch_base for aarch64
  • 690d396: 8308408: Build failure with -Werror=maybe-uninitialized in libjli/java.c with GCC8
  • fa14314: 8303669: SelectVersion indexes past the end of the argv array
  • 25868b9: 8132995: Matcher$ImmutableMatchResult should be optimized to reduce space usage
  • 6765761: 8308118: Avoid multiarray allocations in AESCrypt.makeSessionKey
  • 97ade57: 8307609: RISC-V: Added support for Extract, Compress, Expand and other nodes for Vector API
  • ... and 235 more: https://git.openjdk.org/jdk/compare/408cec516bb5fd82fb6dcddeee934ac0c5ecffaf...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 Pull request is ready to be integrated label May 19, 2023
@azvegint
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented May 22, 2023

Going to push as commit 3d550f7.
Since your change was applied there have been 261 commits pushed to the master branch:

  • 05e99db: 7065228: To interpret case-insensitive string locale independently
  • a970519: 8306983: Do not invoke external programs when switch terminal to raw mode on selected platforms
  • 6b65e57: 8305785: Avoid redundant HashMap.containsKey call in java.util.regex
  • 8011ba7: 8308181: Generational ZGC: Remove CLDG_lock from old gen root scanning
  • 8aa5028: 8302344: Compiler Implementation for Unnamed patterns and variables (Preview)
  • b588797: 8307804: Reorganize ArrayJuggle test cases
  • 928fcf9: 8308000: add PopFrame support for virtual threads
  • 41beb44: 8308084: C2 fix idom bug in PhaseIdealLoop::create_new_if_for_predicate
  • b6a9f5c: 8307619: C2 failed: Not monotonic (AndI CastII LShiftI) in TestShiftCastAndNotification.java
  • eaa80ad: 8300543: Compiler Implementation for Pattern Matching for switch
  • ... and 251 more: https://git.openjdk.org/jdk/compare/408cec516bb5fd82fb6dcddeee934ac0c5ecffaf...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 22, 2023

@azvegint Pushed as commit 3d550f7.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants