JBR-1740 Menu remains open when application loses focus

(cherry picked from commit f987d22cd2)
This commit is contained in:
Dmitry Batrak
2022-05-17 16:51:15 +03:00
committed by jbrbot
parent 6369f2d7f6
commit e858203a4f
2 changed files with 15 additions and 0 deletions

View File

@@ -501,6 +501,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
private static XMouseInfoPeer xPeer;
private static Boolean isXWayland;
static {
initSecurityWarning();
if (GraphicsEnvironment.isHeadless()) {
@@ -2913,6 +2915,13 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
return AccessController.doPrivileged(new GetBooleanAction("sun.awt.disablegrab"));
}
static synchronized boolean isXWayland() {
if (isXWayland == null) {
isXWayland = getEnv("WAYLAND_DISPLAY") != null;
}
return isXWayland;
}
@SuppressWarnings("removal")
private static final boolean useCachedInsets = Boolean.parseBoolean(AccessController.doPrivileged(
new GetPropertyAction("x11.cache.screen.insets", "true")));

View File

@@ -911,6 +911,12 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
}
handleWindowFocusOut(oppositeWindow, xfe.get_serial());
}
if (XToolkit.isXWayland() && XAwtState.getGrabWindow() != null) {
// under XWayland, pointer grab doesn't give us ability to receive button events for native Wayland
// windows, so the logic in handleButtonPressRelease method won't work, and we need this workaround
// to cancel the grab on switching to another application
postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource()));
}
}
}
}