Esempio n. 1
0
 public Dimension getSize() {
   return dimensions.getSize();
 }
Esempio n. 2
0
  // Coordinates are that of the target
  // Called only on Toolkit thread
  public void reshape(WindowDimensions newDimensions, int op, boolean userReshape) {
    if (insLog.isLoggable(Level.FINE)) {
      insLog.fine(
          "Reshaping "
              + this
              + " to "
              + newDimensions
              + " op "
              + op
              + " user reshape "
              + userReshape);
    }
    if (userReshape) {
      // We handle only userReshape == true cases. It means that
      // if the window manager or any other part of the windowing
      // system sets inappropriate size for this window, we can
      // do nothing but accept it.
      Rectangle reqBounds = newDimensions.getBounds();
      Rectangle newBounds =
          constrainBounds(reqBounds.x, reqBounds.y, reqBounds.width, reqBounds.height);
      Insets insets = newDimensions.getInsets();
      Rectangle clientBounds =
          new Rectangle(
              newBounds.x,
              newBounds.y,
              newBounds.width - insets.left - insets.right,
              newBounds.height - insets.top - insets.bottom);
      newDimensions =
          new WindowDimensions(
              newDimensions.isClientSizeSet() ? clientBounds : newBounds,
              insets,
              newDimensions.isClientSizeSet());
    }
    XToolkit.awtLock();
    try {
      if (!isReparented() || !isVisible()) {
        insLog.log(
            Level.FINE,
            "- not reparented({0}) or not visible({1}), default reshape",
            new Object[] {Boolean.valueOf(isReparented()), Boolean.valueOf(visible)});

        // Fix for 6323293.
        // This actually is needed to preserve compatibility with previous releases -
        // some of licensees are expecting componentMoved event on invisible one while
        // its location changes.
        Point oldLocation = getLocation();

        Point newLocation =
            new Point(
                ComponentAccessor.getX((Component) target),
                ComponentAccessor.getY((Component) target));

        if (!newLocation.equals(oldLocation)) {
          handleMoved(newDimensions);
        }

        dimensions = new WindowDimensions(newDimensions);
        updateSizeHints(dimensions);
        Rectangle client = dimensions.getClientRect();
        checkShellRect(client);
        setShellBounds(client);
        if (content != null && !content.getSize().equals(newDimensions.getSize())) {
          reconfigureContentWindow(newDimensions);
        }
        return;
      }

      int wm = XWM.getWMID();
      updateChildrenSizes();
      applyGuessedInsets();

      Rectangle shellRect = newDimensions.getClientRect();

      if (gravityBug()) {
        Insets in = newDimensions.getInsets();
        shellRect.translate(in.left, in.top);
      }

      if ((op & NO_EMBEDDED_CHECK) == 0 && isEmbedded()) {
        shellRect.setLocation(0, 0);
      }

      checkShellRectSize(shellRect);
      if (!isEmbedded()) {
        checkShellRectPos(shellRect);
      }

      op = op & ~NO_EMBEDDED_CHECK;

      if (op == SET_LOCATION) {
        setShellPosition(shellRect);
      } else if (isResizable()) {
        if (op == SET_BOUNDS) {
          setShellBounds(shellRect);
        } else {
          setShellSize(shellRect);
        }
      } else {
        XWM.setShellNotResizable(this, newDimensions, shellRect, true);
        if (op == SET_BOUNDS) {
          setShellPosition(shellRect);
        }
      }

      reconfigureContentWindow(newDimensions);
    } finally {
      XToolkit.awtUnlock();
    }
  }