-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Conversation
👋 Welcome back azvegint! A progress list of the required criteria for merging this PR into |
Webrevs
|
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
* @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. | ||
* |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
@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:
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
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 |
/integrate |
Going to push as commit 3d550f7.
Your commit was automatically rebased without conflicts. |
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-8307529Progress
Issues
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