changeset 1065:a702e8ff83bd

6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux Summary: Added the system property sun.awt.disablegrab Reviewed-by: art, dcherepanov
author anthony
date Wed, 25 Mar 2009 13:37:08 +0300
parents f3ed90be28fc
children 0cbcc4bdf95a
files src/solaris/classes/sun/awt/X11/XBaseWindow.java src/solaris/classes/sun/awt/X11/XToolkit.java
diffstat 2 files changed, 41 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/classes/sun/awt/X11/XBaseWindow.java	Tue Mar 24 21:57:50 2009 +0100
+++ b/src/solaris/classes/sun/awt/X11/XBaseWindow.java	Wed Mar 25 13:37:08 2009 +0300
@@ -842,27 +842,35 @@
                 | 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 @@
             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
--- a/src/solaris/classes/sun/awt/X11/XToolkit.java	Tue Mar 24 21:57:50 2009 +0100
+++ b/src/solaris/classes/sun/awt/X11/XToolkit.java	Wed Mar 25 13:37:08 2009 +0300
@@ -54,6 +54,7 @@
 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 @@
         }
         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"));
+    }
 }