예제 #1
0
  /**
   * Verifies that all required parameters are set. If not, sets them to default values. Verifies
   * values of critical parameters, adjust their values when needed.
   *
   * @throws IllegalArgumentException if params is null
   */
  protected void checkParams(XCreateWindowParams params) {
    if (params == null) {
      throw new IllegalArgumentException("Window creation parameters are null");
    }
    params.putIfNull(PARENT_WINDOW, Long.valueOf(XToolkit.getDefaultRootWindow()));
    params.putIfNull(BOUNDS, new Rectangle(DEF_LOCATION, DEF_LOCATION, MIN_SIZE, MIN_SIZE));
    params.putIfNull(DEPTH, Integer.valueOf((int) XlibWrapper.CopyFromParent));
    params.putIfNull(VISUAL, Long.valueOf(XlibWrapper.CopyFromParent));
    params.putIfNull(VISUAL_CLASS, Integer.valueOf((int) XlibWrapper.InputOnly));
    params.putIfNull(VALUE_MASK, Long.valueOf(XlibWrapper.CWEventMask));
    Rectangle bounds = (Rectangle) params.get(BOUNDS);
    bounds.width = Math.max(MIN_SIZE, bounds.width);
    bounds.height = Math.max(MIN_SIZE, bounds.height);

    Long eventMaskObj = (Long) params.get(EVENT_MASK);
    long eventMask = eventMaskObj != null ? eventMaskObj.longValue() : 0;
    // We use our own synthetic grab see XAwtState.getGrabWindow()
    // (see X vol. 1, 8.3.3.2)
    eventMask |= PropertyChangeMask | OwnerGrabButtonMask;
    params.put(EVENT_MASK, Long.valueOf(eventMask));
  }