Пример #1
0
  Rectangle getClientBounds() {
    XToolkit.awtLock();
    try {
      XWindowAttributes wattr = new XWindowAttributes();
      try {
        XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
        int status =
            XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), xembed.handle, wattr.pData);

        XToolkit.RESTORE_XERROR_HANDLER();

        if (status == 0
            || (XToolkit.saved_error != null
                && XToolkit.saved_error.get_error_code() != XConstants.Success)) {
          return null;
        }

        return new Rectangle(wattr.get_x(), wattr.get_y(), wattr.get_width(), wattr.get_height());
      } finally {
        wattr.dispose();
      }
    } finally {
      XToolkit.awtUnlock();
    }
  }
Пример #2
0
  static int getWindowMapState(long window) {
    XToolkit.awtLock();
    XWindowAttributes wattr = new XWindowAttributes();
    try {
      XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
      int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), window, wattr.pData);
      XToolkit.RESTORE_XERROR_HANDLER();
      if ((status != 0)
          && ((XToolkit.saved_error == null)
              || (XToolkit.saved_error.get_error_code() == XConstants.Success))) {
        return wattr.get_map_state();
      }
    } finally {
      wattr.dispose();
      XToolkit.awtUnlock();
    }

    return XConstants.IsUnmapped;
  }
Пример #3
0
  /**
   * Translates the given point from one window to another. Returns null if the translation is
   * failed
   */
  static Point translateCoordinates(long src, long dst, Point p) {
    Point translated = null;

    XToolkit.awtLock();
    try {
      XTranslateCoordinates xtc = new XTranslateCoordinates(src, dst, p.x, p.y);
      try {
        int status = xtc.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
        if ((status != 0)
            && ((XToolkit.saved_error == null)
                || (XToolkit.saved_error.get_error_code() == XConstants.Success))) {
          translated = new Point(xtc.get_dest_x(), xtc.get_dest_y());
        }
      } finally {
        xtc.dispose();
      }
    } finally {
      XToolkit.awtUnlock();
    }

    return translated;
  }
Пример #4
0
  /** NOTICE: Right now returns only decorated top-levels (not Window) */
  static boolean isToplevelWindow(long window) {
    if (XToolkit.windowToXWindow(window) instanceof XDecoratedPeer) {
      return true;
    }

    XToolkit.awtLock();
    try {
      WindowPropertyGetter wpg =
          new WindowPropertyGetter(window, XWM.XA_WM_STATE, 0, 1, false, XWM.XA_WM_STATE);
      try {
        wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
        if (wpg.getActualType() == XWM.XA_WM_STATE.getAtom()) {
          return true;
        }
      } finally {
        wpg.dispose();
      }

      return false;
    } finally {
      XToolkit.awtUnlock();
    }
  }