From be5021d224fc80319134e4a7c2fd13e1e1eead06 Mon Sep 17 00:00:00 2001 From: Anthony Petrov Date: Wed, 25 Mar 2009 13:37:08 +0300 Subject: [PATCH] 6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux Added the system property sun.awt.disablegrab Reviewed-by: art, dcherepanov --- .../classes/sun/awt/X11/XBaseWindow.java | 54 +++++++++++-------- .../solaris/classes/sun/awt/X11/XToolkit.java | 9 ++++ 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java b/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java index ace8b583077..46491e04c1d 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java @@ -842,27 +842,35 @@ public class XBaseWindow { | XConstants.ButtonMotionMask); final int ownerEvents = 1; - int ptrGrab = XlibWrapper.XGrabPointer(XToolkit.getDisplay(), - getContentWindow(), ownerEvents, eventMask, XConstants.GrabModeAsync, - XConstants.GrabModeAsync, XConstants.None, (XWM.isMotif() ? XToolkit.arrowCursor : XConstants.None), - XConstants.CurrentTime); - // Check grab results to be consistent with X server grab - if (ptrGrab != XConstants.GrabSuccess) { - XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime); - XAwtState.setGrabWindow(null); - grabLog.fine(" Grab Failure - mouse"); - return false; - } - int keyGrab = XlibWrapper.XGrabKeyboard(XToolkit.getDisplay(), - getContentWindow(), ownerEvents, XConstants.GrabModeAsync, XConstants.GrabModeAsync, - XConstants.CurrentTime); - if (keyGrab != XConstants.GrabSuccess) { - XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime); - XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), XConstants.CurrentTime); - XAwtState.setGrabWindow(null); - grabLog.fine(" Grab Failure - keyboard"); - return false; + //6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs + //process on Linux + //The user must pass the sun.awt.disablegrab property to disable + //taking grabs. This prevents hanging of the GUI when a breakpoint + //is hit while a popup window taking the grab is open. + if (!XToolkit.getSunAwtDisableGrab()) { + int ptrGrab = XlibWrapper.XGrabPointer(XToolkit.getDisplay(), + getContentWindow(), ownerEvents, eventMask, XConstants.GrabModeAsync, + XConstants.GrabModeAsync, XConstants.None, (XWM.isMotif() ? XToolkit.arrowCursor : XConstants.None), + XConstants.CurrentTime); + // Check grab results to be consistent with X server grab + if (ptrGrab != XConstants.GrabSuccess) { + XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime); + XAwtState.setGrabWindow(null); + grabLog.fine(" Grab Failure - mouse"); + return false; + } + + int keyGrab = XlibWrapper.XGrabKeyboard(XToolkit.getDisplay(), + getContentWindow(), ownerEvents, XConstants.GrabModeAsync, XConstants.GrabModeAsync, + XConstants.CurrentTime); + if (keyGrab != XConstants.GrabSuccess) { + XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime); + XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), XConstants.CurrentTime); + XAwtState.setGrabWindow(null); + grabLog.fine(" Grab Failure - keyboard"); + return false; + } } if (prevGrabWindow != null) { prevGrabWindow.ungrabInputImpl(); @@ -882,8 +890,10 @@ public class XBaseWindow { grabLog.log(Level.FINE, "UnGrab input on {0}", new Object[] {grabWindow}); if (grabWindow != null) { grabWindow.ungrabInputImpl(); - XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime); - XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), XConstants.CurrentTime); + if (!XToolkit.getSunAwtDisableGrab()) { + XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime); + XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), XConstants.CurrentTime); + } XAwtState.setGrabWindow(null); // we need to call XFlush() here to force ungrab // see 6384219 for details diff --git a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java index 65324290213..8667008d576 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -54,6 +54,7 @@ import sun.awt.*; import sun.font.FontManager; import sun.misc.PerformanceLogger; import sun.print.PrintJob2D; +import sun.security.action.GetBooleanAction; public final class XToolkit extends UNIXToolkit implements Runnable { private static Logger log = Logger.getLogger("sun.awt.X11.XToolkit"); @@ -2305,4 +2306,12 @@ public final class XToolkit extends UNIXToolkit implements Runnable { } return ((X11GraphicsConfig)gc).isTranslucencyCapable(); } + + /** + * Returns the value of "sun.awt.disablegrab" property. Default + * value is {@code false}. + */ + public static boolean getSunAwtDisableGrab() { + return AccessController.doPrivileged(new GetBooleanAction("sun.awt.disablegrab")); + } }