Example #1
0
 /*
  * Retrieves the owner of the peer.
  * Note: this method returns the owner which can be activated, (i.e. the instance
  * of Frame or Dialog may be returned).
  */
 static LWWindowPeer getOwnerFrameDialog(LWWindowPeer peer) {
   Window owner = (peer != null ? peer.getTarget().getOwner() : null);
   while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) {
     owner = owner.getOwner();
   }
   return owner == null ? null : (LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(owner);
 }
 private boolean noIntersections(Rectangle bounds) {
   Window owner = SwingUtilities.getWindowAncestor(myComponent);
   Window popup = SwingUtilities.getWindowAncestor(myTipComponent);
   Window focus = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow();
   if (focus == owner.getOwner()) {
     focus = null; // do not check intersection with parent
   }
   boolean focused = SystemInfo.isWindows || owner.isFocused();
   for (Window other : owner.getOwnedWindows()) {
     if (!focused && !SystemInfo.isWindows) {
       focused = other.isFocused();
     }
     if (popup != other
         && other.isVisible()
         && bounds.x + 10 >= other.getX()
         && bounds.intersects(other.getBounds())) {
       return false;
     }
     if (focus == other) {
       focus = null; // already checked
     }
   }
   return focused
       && (focus == owner || focus == null || !owner.getBounds().intersects(focus.getBounds()));
 }
Example #3
0
 static LWWindowPeer getOwnerFrameDialog(LWWindowPeer peer) {
   Window owner = (peer != null ? peer.getTarget().getOwner() : null);
   while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) {
     owner = owner.getOwner();
   }
   return owner != null ? (LWWindowPeer) owner.getPeer() : null;
 }
Example #4
0
  public LWWindowPeer(
      Window target,
      PlatformComponent platformComponent,
      PlatformWindow platformWindow,
      PeerType peerType) {
    super(target, platformComponent);
    this.platformWindow = platformWindow;
    this.peerType = peerType;

    Window owner = target.getOwner();
    LWWindowPeer ownerPeer =
        owner == null ? null : (LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(owner);
    PlatformWindow ownerDelegate = (ownerPeer != null) ? ownerPeer.getPlatformWindow() : null;

    // The delegate.initialize() needs a non-null GC on X11.
    GraphicsConfiguration gc = getTarget().getGraphicsConfiguration();
    synchronized (getStateLock()) {
      // graphicsConfig should be updated according to the real window
      // bounds when the window is shown, see 4868278
      this.graphicsConfig = gc;
    }

    if (!target.isFontSet()) {
      target.setFont(DEFAULT_FONT);
    }

    if (!target.isBackgroundSet()) {
      target.setBackground(SystemColor.window);
    } else {
      // first we check if user provided alpha for background. This is
      // similar to what Apple's Java do.
      // Since JDK7 we should rely on setOpacity() only.
      // this.opacity = c.getAlpha();
    }

    if (!target.isForegroundSet()) {
      target.setForeground(SystemColor.windowText);
      // we should not call setForeground because it will call a repaint
      // which the peer may not be ready to do yet.
    }

    platformWindow.initialize(target, this, ownerDelegate);

    // Init warning window(for applets)
    SecurityWarningWindow warn = null;
    if (target.getWarningString() != null) {
      // accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip
      // and TrayIcon balloon windows without a warning window.
      if (!AWTAccessor.getWindowAccessor().isTrayIconWindow(target)) {
        LWToolkit toolkit = (LWToolkit) Toolkit.getDefaultToolkit();
        warn = toolkit.createSecurityWarning(target, this);
      }
    }

    warningWindow = warn;
  }
Example #5
0
 private boolean isOneOfOwnersOf(LWWindowPeer peer) {
   Window owner = (peer != null ? peer.getTarget().getOwner() : null);
   while (owner != null) {
     if ((LWWindowPeer) owner.getPeer() == this) {
       return true;
     }
     owner = owner.getOwner();
   }
   return false;
 }