6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux

Added the system property sun.awt.disablegrab

Reviewed-by: art, dcherepanov
This commit is contained in:
Anthony Petrov 2009-03-25 13:37:08 +03:00
parent 1a0a9da570
commit be5021d224
2 changed files with 41 additions and 22 deletions

View File

@ -842,27 +842,35 @@ public class XBaseWindow {
| XConstants.ButtonMotionMask); | XConstants.ButtonMotionMask);
final int ownerEvents = 1; 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(), //6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs
getContentWindow(), ownerEvents, XConstants.GrabModeAsync, XConstants.GrabModeAsync, //process on Linux
XConstants.CurrentTime); //The user must pass the sun.awt.disablegrab property to disable
if (keyGrab != XConstants.GrabSuccess) { //taking grabs. This prevents hanging of the GUI when a breakpoint
XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime); //is hit while a popup window taking the grab is open.
XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), XConstants.CurrentTime); if (!XToolkit.getSunAwtDisableGrab()) {
XAwtState.setGrabWindow(null); int ptrGrab = XlibWrapper.XGrabPointer(XToolkit.getDisplay(),
grabLog.fine(" Grab Failure - keyboard"); getContentWindow(), ownerEvents, eventMask, XConstants.GrabModeAsync,
return false; 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) { if (prevGrabWindow != null) {
prevGrabWindow.ungrabInputImpl(); prevGrabWindow.ungrabInputImpl();
@ -882,8 +890,10 @@ public class XBaseWindow {
grabLog.log(Level.FINE, "UnGrab input on {0}", new Object[] {grabWindow}); grabLog.log(Level.FINE, "UnGrab input on {0}", new Object[] {grabWindow});
if (grabWindow != null) { if (grabWindow != null) {
grabWindow.ungrabInputImpl(); grabWindow.ungrabInputImpl();
XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime); if (!XToolkit.getSunAwtDisableGrab()) {
XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), XConstants.CurrentTime); XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), XConstants.CurrentTime);
XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), XConstants.CurrentTime);
}
XAwtState.setGrabWindow(null); XAwtState.setGrabWindow(null);
// we need to call XFlush() here to force ungrab // we need to call XFlush() here to force ungrab
// see 6384219 for details // see 6384219 for details

View File

@ -54,6 +54,7 @@ import sun.awt.*;
import sun.font.FontManager; import sun.font.FontManager;
import sun.misc.PerformanceLogger; import sun.misc.PerformanceLogger;
import sun.print.PrintJob2D; import sun.print.PrintJob2D;
import sun.security.action.GetBooleanAction;
public final class XToolkit extends UNIXToolkit implements Runnable { public final class XToolkit extends UNIXToolkit implements Runnable {
private static Logger log = Logger.getLogger("sun.awt.X11.XToolkit"); 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(); 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"));
}
} }