示例#1
0
  /** Returns the bounds of the given window, in absolute coordinates */
  static Rectangle getWindowGeometry(long window) {
    XToolkit.awtLock();
    try {
      int res =
          XlibWrapper.XGetGeometry(
              XToolkit.getDisplay(),
              window,
              XlibWrapper.larg1, // root_return
              XlibWrapper.larg2, // x_return
              XlibWrapper.larg3, // y_return
              XlibWrapper.larg4, // width_return
              XlibWrapper.larg5, // height_return
              XlibWrapper.larg6, // border_width_return
              XlibWrapper.larg7); // depth_return
      if (res == 0) {
        return null;
      }

      int x = Native.getInt(XlibWrapper.larg2);
      int y = Native.getInt(XlibWrapper.larg3);
      long width = Native.getUInt(XlibWrapper.larg4);
      long height = Native.getUInt(XlibWrapper.larg5);

      return new Rectangle(x, y, (int) width, (int) height);
    } finally {
      XToolkit.awtUnlock();
    }
  }