Exemple #1
0
  /*
   * Tracks changes of available formats.
   * NOTE: This method may be called by privileged threads.
   *       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   */
  private void checkChange(XSelectionEvent xse) {
    final long propertyAtom = xse.get_property();
    if (propertyAtom != getTargetsPropertyAtom().getAtom()) {
      // wrong atom
      return;
    }

    final XAtom selectionAtom = XAtom.get(xse.get_selection());
    final XSelection changedSelection = XSelection.getSelection(selectionAtom);

    if (null == changedSelection || changedSelection != selection) {
      // unknown selection - do nothing
      return;
    }

    isSelectionNotifyProcessed = true;

    if (selection.isOwner()) {
      // selection is owner - do not need formats
      return;
    }

    long[] formats = null;

    if (propertyAtom == XConstants.None) {
      // We treat None property atom as "empty selection".
      formats = new long[0];
    } else {
      WindowPropertyGetter targetsGetter =
          new WindowPropertyGetter(
              XWindow.getXAWTRootWindow().getWindow(),
              XAtom.get(propertyAtom),
              0,
              XSelection.MAX_LENGTH,
              true,
              XConstants.AnyPropertyType);
      try {
        targetsGetter.execute();
        formats = XSelection.getFormats(targetsGetter);
      } finally {
        targetsGetter.dispose();
      }
    }

    checkChange(formats);
  }
Exemple #2
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();
    }
  }