src/solaris/classes/sun/awt/X11/XlibUtil.java

Print this page

        

@@ -98,20 +98,49 @@
 
         return root == rootCandidate;
     }
 
     /**
-     * Returns the bounds of the given window, in absolute coordinates
+     * Returns the bounds of the given window relative to its parent.
      */
-    static Rectangle getWindowGeometry(long window)
+    public static Rectangle getWindowGeometry(long window) {
+        XToolkit.awtLock();
+        try {
+            return getWindowGeometry(window, XlibWrapper.larg1);
+        } finally {
+            XToolkit.awtUnlock();
+        }
+    }
+
+    /**
+     * Returns the bounds of the given window relative to its parent.
+     * The unsafe memory pointed to by the rootWindowBuffer will
+     * contain the root window of the given window.
+     * WARNING: DO NOT USE XlibWrapper.larg[2..7] as the rootWindowBuffer!
+     * Only larg1 or larg8 can be used, or some other allocated memory block.
+     *
+     * @throws IllegalArgumentException if the rootWindowBuffer refers to
+     * unsupported values.
+     */
+    public static Rectangle getWindowGeometry(long window, long rootWindowBuffer)
     {
+        if (rootWindowBuffer == XlibWrapper.larg2 ||
+            rootWindowBuffer == XlibWrapper.larg3 ||
+            rootWindowBuffer == XlibWrapper.larg4 ||
+            rootWindowBuffer == XlibWrapper.larg5 ||
+            rootWindowBuffer == XlibWrapper.larg6 ||
+            rootWindowBuffer == XlibWrapper.larg7)
+        {
+            throw new IllegalArgumentException(
+                    "The rootWindowBuffer should not refer to XlibWrapper.larg[2..7]");
+        }
         XToolkit.awtLock();
         try
         {
             int res = XlibWrapper.XGetGeometry(XToolkit.getDisplay(),
                                                window,
-                                               XlibWrapper.larg1, // root_return
+                                               rootWindowBuffer, // root_return
                                                XlibWrapper.larg2, // x_return
                                                XlibWrapper.larg3, // y_return
                                                XlibWrapper.larg4, // width_return
                                                XlibWrapper.larg5, // height_return
                                                XlibWrapper.larg6, // border_width_return

@@ -208,11 +237,11 @@
             XQueryTree qt = new XQueryTree(window);
             try
             {
                 if (qt.execute() == 0)
                 {
-                    return 0;
+                    return XConstants.None;
                 }
                 else
                 {
                     return qt.get_parent();
                 }