示例#1
0
 XContentWindow createContent(WindowDimensions dims) {
   Rectangle rec = dims.getBounds();
   // Fix for  - set the location of the content window to the (-left inset, -top inset)
   Insets ins = dims.getInsets();
   if (ins != null) {
     rec.x = -ins.left;
     rec.y = -ins.top;
   } else {
     rec.x = 0;
     rec.y = 0;
   }
   return new XContentWindow(this, rec);
 }
示例#2
0
  void preInit(XCreateWindowParams params) {
    super.preInit(params);
    if (!resize_request.isInterned()) {
      resize_request.intern(false);
    }
    winAttr.initialFocus = true;

    currentInsets = new Insets(0, 0, 0, 0); // replacemenet for wdata->top, left, bottom, right

    applyGuessedInsets();
    Rectangle bounds = (Rectangle) params.get(BOUNDS);
    dimensions = new WindowDimensions(bounds, getRealInsets(), false);
    params.put(BOUNDS, dimensions.getClientRect());

    if (insLog.isLoggable(Level.FINE)) {
      insLog.log(Level.FINE, "Initial dimensions {0}", new Object[] {String.valueOf(dimensions)});
    }

    // Deny default processing of these events on the shell - proxy will take care of
    // them instead
    Long eventMask = (Long) params.get(EVENT_MASK);
    params.add(
        EVENT_MASK,
        Long.valueOf(eventMask.longValue() & ~(FocusChangeMask | KeyPressMask | KeyReleaseMask)));
  }
示例#3
0
 public void setResizable(boolean resizable) {
   int fs = winAttr.functions;
   if (!isResizable() && resizable) {
     insets = currentInsets = new Insets(0, 0, 0, 0);
     resetWMSetInsets();
     if (!isEmbedded()) {
       setReparented(false);
     }
     winAttr.isResizable = resizable;
     if ((fs & MWM_FUNC_ALL) != 0) {
       fs &= ~(MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE);
     } else {
       fs |= (MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE);
     }
     winAttr.functions = fs;
     XWM.setShellResizable(this);
   } else if (isResizable() && !resizable) {
     insets = currentInsets = new Insets(0, 0, 0, 0);
     resetWMSetInsets();
     if (!isEmbedded()) {
       setReparented(false);
     }
     winAttr.isResizable = resizable;
     if ((fs & MWM_FUNC_ALL) != 0) {
       fs |= (MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE);
     } else {
       fs &= ~(MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE);
     }
     winAttr.functions = fs;
     XWM.setShellNotResizable(this, dimensions, dimensions.getScreenBounds(), false);
   }
 }
示例#4
0
  protected void handleCorrectInsets(Insets correctWM) {
    XToolkit.awtLock();
    try {
      /*
       * Ok, now see if we need adjust window size because
       * initial insets were wrong (most likely they were).
       */
      Insets correction = difference(correctWM, currentInsets);
      if (insLog.isLoggable(Level.FINEST)) {
        insLog.log(Level.FINEST, "Corrention {0}", new Object[] {String.valueOf(correction)});
      }
      if (!isNull(correction)) {
        /*
         * Actual insets account for menubar/warning label,
         * so we can't assign directly but must adjust them.
         */
        add(currentInsets, correction);
        applyGuessedInsets();

        // Fix for 6318109: PIT: Min Size is not honored properly when a
        // smaller size is specified in setSize(), XToolkit
        // update minimum size hints
        updateMinSizeHints();

        /*
         * If this window has been sized by a pack() we need
         * to keep the interior geometry intact.  Since pack()
         * computed width and height with wrong insets, we
         * must adjust the target dimensions appropriately.
         */
      }
      if (insLog.isLoggable(Level.FINER)) insLog.finer("Dimensions before reparent: " + dimensions);

      dimensions.setInsets(getRealInsets());
      insets_corrected = true;

      if (isMaximized()) {
        return;
      }

      if ((getHints().get_flags() & (USPosition | PPosition)) != 0) {
        reshape(dimensions, SET_BOUNDS, false);
      } else {
        reshape(dimensions, SET_SIZE, false);
      }
    } finally {
      XToolkit.awtUnlock();
    }
  }
示例#5
0
  /** @param x, y, width, heith - dimensions of the window with insets */
  private void reshape(int x, int y, int width, int height, int operation, boolean userReshape) {
    Rectangle newRec;
    boolean setClient = false;
    WindowDimensions dims = new WindowDimensions(dimensions);
    switch (operation & (~NO_EMBEDDED_CHECK)) {
      case SET_LOCATION:
        // Set location always sets bounds location. However, until the window is mapped we
        // should use client coordinates
        dims.setLocation(x, y);
        break;
      case SET_SIZE:
        // Set size sets bounds size. However, until the window is mapped we
        // should use client coordinates
        dims.setSize(width, height);
        break;
      case SET_CLIENT_SIZE:
        {
          // Sets client rect size. Width and height contain insets.
          Insets in = currentInsets;
          width -= in.left + in.right;
          height -= in.top + in.bottom;
          dims.setClientSize(width, height);
          break;
        }
      case SET_BOUNDS:
      default:
        dims.setLocation(x, y);
        dims.setSize(width, height);
        break;
    }
    if (insLog.isLoggable(Level.FINE)) {
      insLog.log(
          Level.FINE,
          "For the operation {0} new dimensions are {1}",
          new Object[] {operationToString(operation), String.valueOf(dims)});
    }

    reshape(dims, operation, userReshape);
  }
示例#6
0
 public int getAbsoluteY() {
   // NOTE: returning this peer's location which is shell location
   return dimensions.getScreenBounds().y;
 }
示例#7
0
 public Point getLocation() {
   return dimensions.getLocation();
 }
示例#8
0
 public int getY() {
   return dimensions.getLocation().y;
 }
示例#9
0
 public int getX() {
   return dimensions.getLocation().x;
 }
示例#10
0
 public Dimension getSize() {
   return dimensions.getSize();
 }
示例#11
0
 public Rectangle getBounds() {
   return dimensions.getBounds();
 }
示例#12
0
 Rectangle getShellBounds() {
   return dimensions.getClientRect();
 }
示例#13
0
  public void handleReparentNotifyEvent(XEvent xev) {
    XReparentEvent xe = xev.get_xreparent();
    if (insLog.isLoggable(Level.FINE)) insLog.fine(xe.toString());
    reparent_serial = xe.get_serial();
    XToolkit.awtLock();
    try {
      long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());

      if (isEmbedded()) {
        setReparented(true);
        insets_corrected = true;
        return;
      }
      Component t = (Component) target;
      if (getDecorations() == winAttr.AWT_DECOR_NONE) {
        setReparented(true);
        insets_corrected = true;
        reshape(dimensions, SET_SIZE, false);
      } else if (xe.get_parent() == root) {
        configure_seen = false;
        insets_corrected = false;

        /*
         * We can be repareted to root for two reasons:
         *   . setVisible(false)
         *   . WM exited
         */
        if (isVisible()) {
            /* WM exited */
          /* Work around 4775545 */
          XWM.getWM().unshadeKludge(this);
          insLog.fine("- WM exited");
        } else {
          insLog.fine(" - reparent due to hide");
        }
      } else {
          /* reparented to WM frame, figure out our insets */
        setReparented(true);
        insets_corrected = false;

        // Check if we have insets provided by the WM
        Insets correctWM = getWMSetInsets(null);
        if (correctWM != null) {
          if (insLog.isLoggable(Level.FINER)) {
            insLog.log(
                Level.FINER, "wm-provided insets {0}", new Object[] {String.valueOf(correctWM)});
          }
          // If these insets are equal to our current insets - no actions are necessary
          Insets dimInsets = dimensions.getInsets();
          if (correctWM.equals(dimInsets)) {
            insLog.finer("Insets are the same as estimated - no additional reshapes necessary");
            no_reparent_artifacts = true;
            insets_corrected = true;
            applyGuessedInsets();
            return;
          }
        } else {
          correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent());

          if (correctWM != null) {
            if (insLog.isLoggable(Level.FINER)) {
              insLog.log(Level.FINER, "correctWM {0}", new Object[] {String.valueOf(correctWM)});
            }
          } else {
            insLog.log(
                Level.FINER, "correctWM insets are not available, waiting for configureNotify");
          }
        }

        if (correctWM != null) {
          handleCorrectInsets(correctWM);
        }
      }
    } finally {
      XToolkit.awtUnlock();
    }
  }
示例#14
0
  public void handleConfigureNotifyEvent(XEvent xev) {
    assert (SunToolkit.isAWTLockHeldByCurrentThread());
    XConfigureEvent xe = xev.get_xconfigure();
    if (insLog.isLoggable(Level.FINE)) {
      insLog.log(Level.FINE, "Configure notify {0}", new Object[] {String.valueOf(xe)});
    }

    // XXX: should really only consider synthetic events, but
    if (isReparented()) {
      configure_seen = true;
    }

    if (!isMaximized()
        && (xe.get_serial() == reparent_serial || xe.get_window() != getShell())
        && !no_reparent_artifacts) {
      insLog.fine("- reparent artifact, skipping");
      return;
    }
    no_reparent_artifacts = false;

    /**
     * When there is a WM we receive some CN before being visible and after. We should skip all CN
     * which are before being visible, because we assume the gravity is in action while it is not
     * yet.
     *
     * <p>When there is no WM we receive CN only _before_ being visible. We should process these
     * CNs.
     */
    if (!isVisible() && XWM.getWMID() != XWM.NO_WM) {
      insLog.fine(" - not visible, skipping");
      return;
    }

    /*
     * Some window managers configure before we are reparented and
     * the send event flag is set! ugh... (Enlighetenment for one,
     * possibly MWM as well).  If we haven't been reparented yet
     * this is just the WM shuffling us into position.  Ignore
     * it!!!! or we wind up in a bogus location.
     */
    int runningWM = XWM.getWMID();
    if (insLog.isLoggable(Level.FINE)) {
      insLog.log(
          Level.FINE,
          "reparented={0}, visible={1}, WM={2}, decorations={3}",
          new Object[] {isReparented(), isVisible(), runningWM, getDecorations()});
    }
    if (!isReparented()
        && isVisible()
        && runningWM != XWM.NO_WM
        && !XWM.isNonReparentingWM()
        && getDecorations() != winAttr.AWT_DECOR_NONE) {
      insLog.fine("- visible but not reparented, skipping");
      return;
    }
    // Last chance to correct insets
    if (!insets_corrected && getDecorations() != winAttr.AWT_DECOR_NONE) {
      long parent = XlibUtil.getParentWindow(window);
      Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null;
      if (insLog.isLoggable(Level.FINER)) {
        if (correctWM != null) {
          insLog.finer("Configure notify - insets : " + correctWM);
        } else {
          insLog.finer("Configure notify - insets are still not available");
        }
      }
      if (correctWM != null) {
        handleCorrectInsets(correctWM);
      } else {
        // Only one attempt to correct insets is made (to lower risk)
        // if insets are still not available we simply set the flag
        insets_corrected = true;
      }
    }

    updateChildrenSizes();

    // Bounds of the window
    Rectangle targetBounds =
        new Rectangle(
            ComponentAccessor.getX((Component) target),
            ComponentAccessor.getY((Component) target),
            ComponentAccessor.getWidth((Component) target),
            ComponentAccessor.getHeight((Component) target));

    Point newLocation = targetBounds.getLocation();
    if (xe.get_send_event() || runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) {
      // Location, Client size + insets
      newLocation = new Point(xe.get_x() - currentInsets.left, xe.get_y() - currentInsets.top);
    } else {
      // CDE/MWM/Metacity/Sawfish bug: if shell is resized using
      // top or left border, we don't receive synthetic
      // ConfigureNotify, only the one from X with zero
      // coordinates.  This is the workaround to get real
      // location, 6261336
      switch (XWM.getWMID()) {
        case XWM.CDE_WM:
        case XWM.MOTIF_WM:
        case XWM.METACITY_WM:
        case XWM.SAWFISH_WM:
          {
            Point xlocation = queryXLocation();
            if (log.isLoggable(Level.FINE)) {
              log.log(Level.FINE, "New X location: {0}", new Object[] {String.valueOf(xlocation)});
            }
            if (xlocation != null) {
              newLocation = xlocation;
            }
            break;
          }
        default:
          break;
      }
    }

    WindowDimensions newDimensions =
        new WindowDimensions(
            newLocation, new Dimension(xe.get_width(), xe.get_height()), copy(currentInsets), true);

    if (insLog.isLoggable(Level.FINER)) {
      insLog.log(
          Level.FINER,
          "Insets are {0}, new dimensions {1}",
          new Object[] {String.valueOf(currentInsets), String.valueOf(newDimensions)});
    }

    checkIfOnNewScreen(newDimensions.getBounds());

    Point oldLocation = getLocation();
    dimensions = newDimensions;
    if (!newLocation.equals(oldLocation)) {
      handleMoved(newDimensions);
    }
    reconfigureContentWindow(newDimensions);
    updateChildrenSizes();
  }
示例#15
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();
    }
  }
示例#16
0
 void updateSizeHints(WindowDimensions dims) {
   Rectangle rec = dims.getClientRect();
   checkShellRect(rec);
   updateSizeHints(rec.x, rec.y, rec.width, rec.height);
 }
示例#17
0
 public void handleMoved(WindowDimensions dims) {
   Point loc = dims.getLocation();
   ComponentAccessor.setX((Component) target, loc.x);
   ComponentAccessor.setY((Component) target, loc.y);
   postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
 }