Details
-
Bug
-
Resolution: Fixed
-
P3
-
None
-
b24
Description
We are using XGrabPointer to get mouse input and dismiss popup menus on mouse click.
Obviously, it does not work when we are trying to mouse click outside of area controlled by XWayland(window's title, desktop, wayland native apss).
prototype of not perfect workaround
diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XPopupMenuPeer.java b/src/java.desktop/unix/classes/sun/awt/X11/XPopupMenuPeer.java
index a19f56249ae..db88ef49f37 100644
--- a/src/java.desktop/unix/classes/sun/awt/X11/XPopupMenuPeer.java
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XPopupMenuPeer.java
@@ -111,6 +111,16 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer {
// Get menus from the target.
Vector<MenuItem> targetItemVector = getMenuTargetItems();
if (targetItemVector != null) {
+ //TODO: add focus listener only for XWayland
+ target.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ target.removeFocusListener(this);
+ if (isShowing()) {
+ hide();
+ }
+ }
+ });
reloadItems(targetItemVector);
//Fix for 6287092: JCK15a: api/java_awt/interactive/event/EventTests.html#EventTest0015 fails, mustang
For a first look this workaround seems to work reliably except only one case:
clicking on window's title containing origin component does not lead to focus change, thus we don't hiding popup.
Obviously, it does not work when we are trying to mouse click outside of area controlled by XWayland(window's title, desktop, wayland native apss).
prototype of not perfect workaround
diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XPopupMenuPeer.java b/src/java.desktop/unix/classes/sun/awt/X11/XPopupMenuPeer.java
index a19f56249ae..db88ef49f37 100644
--- a/src/java.desktop/unix/classes/sun/awt/X11/XPopupMenuPeer.java
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XPopupMenuPeer.java
@@ -111,6 +111,16 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer {
// Get menus from the target.
Vector<MenuItem> targetItemVector = getMenuTargetItems();
if (targetItemVector != null) {
+ //TODO: add focus listener only for XWayland
+ target.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ target.removeFocusListener(this);
+ if (isShowing()) {
+ hide();
+ }
+ }
+ });
reloadItems(targetItemVector);
//Fix for 6287092: JCK15a: api/java_awt/interactive/event/EventTests.html#EventTest0015 fails, mustang
For a first look this workaround seems to work reliably except only one case:
clicking on window's title containing origin component does not lead to focus change, thus we don't hiding popup.
Attachments
Issue Links
- csr for
-
JDK-8307529 [XWayland] Popup is not closed on click outside of area controlled by XWayland
- Closed
- relates to
-
JDK-8319103 Popups that request focus are not shown on Linux with Wayland
- Resolved