Java Code Examples for sun.awt.AWTAccessor.ComponentAccessor#getPeer()

The following examples show how to use sun.awt.AWTAccessor.ComponentAccessor#getPeer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XPanelPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void setForegroundForHierarchy(Container cont, Color c) {
    synchronized(target.getTreeLock()) {
        final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
        int n = cont.getComponentCount();
        for(int i=0; i < n; i++) {
            Component comp = cont.getComponent(i);
            Color color = comp.getForeground();
            if (color == null || color.equals(c)) {
                ComponentPeer cpeer = acc.getPeer(comp);
                if (cpeer != null) {
                    cpeer.setForeground(c);
                }
                if (cpeer instanceof LightweightPeer
                    && comp instanceof Container)
                {
                    setForegroundForHierarchy((Container) comp, c);
                }
            }
        }
    }
}
 
Example 2
Source File: DropTarget.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Notify the DropTarget that it has been associated with a Component
 *
 **********************************************************************
 * This method is usually called from java.awt.Component.addNotify() of
 * the Component associated with this DropTarget to notify the DropTarget
 * that a ComponentPeer has been associated with that Component.
 *
 * Calling this method, other than to notify this DropTarget of the
 * association of the ComponentPeer with the Component may result in
 * a malfunction of the DnD system.
 **********************************************************************
 */
public void addNotify() {
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    ComponentPeer peer = acc.getPeer(component);
    if (peer == null || peer == componentPeer) {
        return;
    }

    componentPeer = peer;


    for (Component c = component;
         c != null && peer instanceof LightweightPeer; c = c.getParent()) {
        peer = acc.getPeer(c);
    }

    if (peer instanceof DropTargetPeer) {
        nativePeer = (DropTargetPeer) peer;
        ((DropTargetPeer)peer).addDropTarget(this);
    } else {
        nativePeer = null;
    }
}
 
Example 3
Source File: D3DGraphicsDevice.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void addFSWindowListener(Window w) {
    // if the window is not a toplevel (has an owner) we have to use the
    // real toplevel to enter the full-screen mode with (4933099).
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    if (!(w instanceof Frame) && !(w instanceof Dialog) &&
        (realFSWindow = getToplevelOwner(w)) != null)
    {
        ownerOrigBounds = realFSWindow.getBounds();
        WWindowPeer fp = acc.getPeer(realFSWindow);
        ownerWasVisible = realFSWindow.isVisible();
        Rectangle r = w.getBounds();
        // we use operations on peer instead of component because calling
        // them on component will take the tree lock
        fp.reshape(r.x, r.y, r.width, r.height);
        fp.setVisible(true);
    } else {
        realFSWindow = w;
    }

    fsWindowWasAlwaysOnTop = realFSWindow.isAlwaysOnTop();
    ((WWindowPeer) acc.getPeer(realFSWindow)).setAlwaysOnTop(true);

    fsWindowListener = new D3DFSWindowAdapter();
    realFSWindow.addWindowListener(fsWindowListener);
}
 
Example 4
Source File: KeyboardFocusManagerPeerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static boolean shouldFocusOnClick(Component component) {
    boolean acceptFocusOnClick = false;

    // A component is generally allowed to accept focus on click
    // if its peer is focusable. There're some exceptions though.


    // CANVAS & SCROLLBAR accept focus on click
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    if (component instanceof Canvas ||
        component instanceof Scrollbar)
    {
        acceptFocusOnClick = true;

    // PANEL, empty only, accepts focus on click
    } else if (component instanceof Panel) {
        acceptFocusOnClick = (((Panel)component).getComponentCount() == 0);


    // Other components
    } else {
        ComponentPeer peer = (component != null ? acc.getPeer(component) : null);
        acceptFocusOnClick = (peer != null ? peer.isFocusable() : false);
    }
    return acceptFocusOnClick && acc.canBeFocusOwner(component);
}
 
Example 5
Source File: XPanelPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void setBackground(Color c) {
    Component comp;
    int i;

    Container cont = (Container) target;
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    synchronized(target.getTreeLock()) {
        int n = cont.getComponentCount();
        for(i=0; i < n; i++) {
            comp = cont.getComponent(i);
            ComponentPeer peer = acc.getPeer(comp);
            if (peer != null) {
                Color color = comp.getBackground();
                if (color == null || color.equals(c)) {
                    peer.setBackground(c);
                }
            }
        }
    }
    super.setBackground(c);
}
 
Example 6
Source File: TestXEmbedServer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void addClient() {
    client = new Canvas() {
            public void paint(Graphics g) {
                super.paint(g);
            }
        };
    client.setBackground(new Color(30, 220, 40));
    clientCont.add(client);
    clientCont.validate();
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    WindowIDProvider pid = (WindowIDProvider)acc.getPeer(client);
    log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow());
    Rectangle toFocusBounds = toFocus.getBounds();
    toFocusBounds.setLocation(toFocus.getLocationOnScreen());
    f.validate();

    // KDE doesn't accept clicks on title as activation - click below title
    Rectangle fbounds = f.getBounds();
    fbounds.y += f.getInsets().top;
    fbounds.height -= f.getInsets().top;

    Process proc = startClient(new Rectangle[] {fbounds, dummy.getBounds(), toFocusBounds,
                                                new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()),
                                                new Rectangle(10, 130, 20, 20)}, pid.getWindow());
    new ClientWatcher(client, proc, clientCont).start();
}
 
Example 7
Source File: WInputMethod.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private WComponentPeer getNearestNativePeer(Component comp)
{
    if (comp==null)     return null;
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    ComponentPeer peer = acc.getPeer(comp);
    if (peer==null)     return null;

    while (peer instanceof java.awt.peer.LightweightPeer) {
        comp = comp.getParent();
        if (comp==null) return null;
        peer = acc.getPeer(comp);
        if (peer==null) return null;
    }

    if (peer instanceof WComponentPeer)
        return (WComponentPeer)peer;
    else
        return null;

}
 
Example 8
Source File: XFileDialogPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public boolean dispatchKeyEvent(KeyEvent keyEvent) {
    int id = keyEvent.getID();
    int keyCode = keyEvent.getKeyCode();

    if (id == KeyEvent.KEY_PRESSED && keyCode == KeyEvent.VK_ESCAPE) {
        synchronized (target.getTreeLock()) {
            Component comp = (Component) keyEvent.getSource();
            while (comp != null) {
                // Fix for 6240084 Disposing a file dialog when the drop-down is active does not dispose the dropdown menu, on Xtoolkit
                // See also 6259493
                ComponentAccessor acc = AWTAccessor.getComponentAccessor();
                if (comp == pathChoice) {
                    XChoicePeer choicePeer = acc.getPeer(pathChoice);
                    if (choicePeer.isUnfurled()){
                        return false;
                    }
                }
                Object peer = acc.getPeer(comp);
                if (peer == this) {
                    handleCancel();
                    return true;
                }
                comp = comp.getParent();
            }
        }
    }

    return false;
}
 
Example 9
Source File: BasicSplitPaneUI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Should be messaged before the dragging session starts, resets
 * lastDragLocation and dividerSize.
 */
protected void startDragging() {
    Component       leftC = splitPane.getLeftComponent();
    Component       rightC = splitPane.getRightComponent();
    ComponentPeer   cPeer;

    beginDragDividerLocation = getDividerLocation(splitPane);
    draggingHW = false;
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    if(leftC != null && (cPeer = acc.getPeer(leftC)) != null &&
       !(cPeer instanceof LightweightPeer)) {
        draggingHW = true;
    } else if(rightC != null && (cPeer = acc.getPeer(rightC)) != null
              && !(cPeer instanceof LightweightPeer)) {
        draggingHW = true;
    }
    if(orientation == JSplitPane.HORIZONTAL_SPLIT) {
        setLastDragLocation(divider.getBounds().x);
        dividerSize = divider.getSize().width;
        if(!isContinuousLayout() && draggingHW) {
            nonContinuousLayoutDivider.setBounds
                    (getLastDragLocation(), 0, dividerSize,
                     splitPane.getHeight());
                  addHeavyweightDivider();
        }
    } else {
        setLastDragLocation(divider.getBounds().y);
        dividerSize = divider.getSize().height;
        if(!isContinuousLayout() && draggingHW) {
            nonContinuousLayoutDivider.setBounds
                    (0, getLastDragLocation(), splitPane.getWidth(),
                     dividerSize);
                  addHeavyweightDivider();
        }
    }
}
 
Example 10
Source File: CPlatformWindow.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override  // PlatformWindow
public void toFront() {
    LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
    Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    if( w != null && acc.getPeer(w) != null
            && ((LWWindowPeer)acc.getPeer(w)).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
            && !lwcToolkit.isApplicationActive()) {
        lwcToolkit.activateApplicationIgnoringOtherApps();
    }
    updateFocusabilityForAutoRequestFocus(false);
    execute(CPlatformWindow::nativePushNSWindowToFront);
    updateFocusabilityForAutoRequestFocus(true);
}
 
Example 11
Source File: LWWindowPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private boolean isOneOfOwnersOf(LWWindowPeer peer) {
    Window owner = (peer != null ? peer.getTarget().getOwner() : null);
    while (owner != null) {
        final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
        if (acc.getPeer(owner) == this) {
            return true;
        }
        owner = owner.getOwner();
    }
    return false;
}
 
Example 12
Source File: XWindow.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static long getParentWindowID(Component target) {

        Component temp = target.getParent();
        final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
        ComponentPeer peer = acc.getPeer(temp);
        while (!(peer instanceof XWindow))
        {
            temp = temp.getParent();
            peer = acc.getPeer(temp);
        }

        if (peer != null && peer instanceof XWindow)
            return ((XWindow)peer).getContentWindow();
        else return 0;
    }
 
Example 13
Source File: CGLVolatileSurfaceManager.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Create a FBO-based SurfaceData object (or init the backbuffer
     * of an existing window if this is a double buffered GraphicsConfig)
     */
    protected SurfaceData initAcceleratedSurface() {
        SurfaceData sData = null;
        Component comp = vImg.getComponent();
        final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
        final ComponentPeer peer = (comp != null) ? acc.getPeer(comp) : null;

        try {
            boolean createVSynced = false;
            boolean forceback = false;
            if (context instanceof Boolean) {
                forceback = ((Boolean)context).booleanValue();
                if (forceback && peer instanceof BackBufferCapsProvider) {
                    BackBufferCapsProvider provider =
                        (BackBufferCapsProvider)peer;
                    BufferCapabilities caps = provider.getBackBufferCaps();
                    if (caps instanceof ExtendedBufferCapabilities) {
                        ExtendedBufferCapabilities ebc =
                            (ExtendedBufferCapabilities)caps;
                        if (ebc.getVSync() == VSYNC_ON &&
                            ebc.getFlipContents() == COPIED)
                        {
                            createVSynced = true;
                            forceback = false;
                        }
                    }
                }
            }

            if (forceback) {
                // peer must be non-null in this case
                // TODO: modify parameter to delegate
                //                sData = CGLSurfaceData.createData(peer, vImg, FLIP_BACKBUFFER);
            } else {
                CGLGraphicsConfig gc =
                    (CGLGraphicsConfig)vImg.getGraphicsConfig();
                ColorModel cm = gc.getColorModel(vImg.getTransparency());
                int type = vImg.getForcedAccelSurfaceType();
                // if acceleration type is forced (type != UNDEFINED) then
                // use the forced type, otherwise choose FBOBJECT
                if (type == OGLSurfaceData.UNDEFINED) {
                    type = OGLSurfaceData.FBOBJECT;
                }
                if (createVSynced) {
                    // TODO: modify parameter to delegate
//                  sData = CGLSurfaceData.createData(peer, vImg, type);
                } else {
                    sData = CGLSurfaceData.createData(gc,
                                                      vImg.getWidth(),
                                                      vImg.getHeight(),
                                                      cm, vImg, type);
                }
            }
        } catch (NullPointerException ex) {
            sData = null;
        } catch (OutOfMemoryError er) {
            sData = null;
        }

        return sData;
    }
 
Example 14
Source File: CPlatformWindow.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private void orderAboveSiblingsImpl(Window[] windows) {
    ArrayList<Window> childWindows = new ArrayList<Window>();

    final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
    final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();

    // Go through the list of windows and perform ordering.
    for (Window w : windows) {
        boolean iconified = false;
        final Object p = componentAccessor.getPeer(w);
        if (p instanceof LWWindowPeer) {
            CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
            iconified = isIconified();
            if (pw != null && pw.isVisible() && !iconified) {
                // If the window is one of ancestors of 'main window' or is going to become main by itself,
                // the window should be ordered above its siblings; otherwise the window is just ordered
                // above its nearest parent.
                if (pw.isOneOfOwnersOrSelf(this)) {
                    pw.execute(CWrapper.NSWindow::orderFront);
                } else {
                    pw.owner.execute(ownerPtr -> {
                        pw.execute(ptr -> {
                            CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
                        });
                    });
                }
                pw.applyWindowLevel(w);
            }
        }
        // Retrieve the child windows for each window from the list except iconified ones
        // and store them for future use.
        // Note: we collect data about child windows even for invisible owners, since they may have
        // visible children.
        if (!iconified) {
            childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
        }
    }
    // If some windows, which have just been ordered, have any child windows, let's start new iteration
    // and order these child windows.
    if (!childWindows.isEmpty()) {
        orderAboveSiblingsImpl(childWindows.toArray(new Window[0]));
    }
}
 
Example 15
Source File: WScrollPanePeer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    while (hwAncestor != null
           && !(acc.getPeer(hwAncestor) instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = acc.getPeer(hwAncestor);
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 16
Source File: CPlatformWindow.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void orderAboveSiblingsImpl(Window[] windows) {
    ArrayList<Window> childWindows = new ArrayList<Window>();

    final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
    final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();

    // Go through the list of windows and perform ordering.
    for (Window w : windows) {
        boolean iconified = false;
        final Object p = componentAccessor.getPeer(w);
        if (p instanceof LWWindowPeer) {
            CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
            iconified = isIconified();
            if (pw != null && pw.isVisible() && !iconified) {
                // If the window is one of ancestors of 'main window' or is going to become main by itself,
                // the window should be ordered above its siblings; otherwise the window is just ordered
                // above its nearest parent.
                if (pw.isOneOfOwnersOrSelf(this)) {
                    pw.execute(CWrapper.NSWindow::orderFront);
                } else {
                    pw.owner.execute(ownerPtr -> {
                        pw.execute(ptr -> {
                            CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
                        });
                    });
                }
                pw.applyWindowLevel(w);
            }
        }
        // Retrieve the child windows for each window from the list except iconified ones
        // and store them for future use.
        // Note: we collect data about child windows even for invisible owners, since they may have
        // visible children.
        if (!iconified) {
            childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
        }
    }
    // If some windows, which have just been ordered, have any child windows, let's start new iteration
    // and order these child windows.
    if (!childWindows.isEmpty()) {
        orderAboveSiblingsImpl(childWindows.toArray(new Window[0]));
    }
}
 
Example 17
Source File: CPlatformWindow.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private void orderAboveSiblingsImpl(Window[] windows) {
    ArrayList<Window> childWindows = new ArrayList<Window>();

    final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
    final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();

    // Go through the list of windows and perform ordering.
    for (Window w : windows) {
        boolean iconified = false;
        final Object p = componentAccessor.getPeer(w);
        if (p instanceof LWWindowPeer) {
            CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
            iconified = isIconified();
            if (pw != null && pw.isVisible() && !iconified) {
                // If the window is one of ancestors of 'main window' or is going to become main by itself,
                // the window should be ordered above its siblings; otherwise the window is just ordered
                // above its nearest parent.
                if (pw.isOneOfOwnersOrSelf(this)) {
                    pw.execute(CWrapper.NSWindow::orderFront);
                } else {
                    pw.owner.execute(ownerPtr -> {
                        pw.execute(ptr -> {
                            CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
                        });
                    });
                }
                pw.applyWindowLevel(w);
            }
        }
        // Retrieve the child windows for each window from the list except iconified ones
        // and store them for future use.
        // Note: we collect data about child windows even for invisible owners, since they may have
        // visible children.
        if (!iconified) {
            childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
        }
    }
    // If some windows, which have just been ordered, have any child windows, let's start new iteration
    // and order these child windows.
    if (!childWindows.isEmpty()) {
        orderAboveSiblingsImpl(childWindows.toArray(new Window[0]));
    }
}
 
Example 18
Source File: CPlatformWindow.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private void orderAboveSiblingsImpl(Window[] windows) {
    ArrayList<Window> childWindows = new ArrayList<Window>();

    final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
    final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();

    // Go through the list of windows and perform ordering.
    for (Window w : windows) {
        boolean iconified = false;
        final Object p = componentAccessor.getPeer(w);
        if (p instanceof LWWindowPeer) {
            CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
            iconified = isIconified();
            if (pw != null && pw.isVisible() && !iconified) {
                // If the window is one of ancestors of 'main window' or is going to become main by itself,
                // the window should be ordered above its siblings; otherwise the window is just ordered
                // above its nearest parent.
                if (pw.isOneOfOwnersOrSelf(this)) {
                    pw.execute(CWrapper.NSWindow::orderFront);
                } else {
                    pw.owner.execute(ownerPtr -> {
                        pw.execute(ptr -> {
                            CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
                        });
                    });
                }
                pw.applyWindowLevel(w);
            }
        }
        // Retrieve the child windows for each window from the list except iconified ones
        // and store them for future use.
        // Note: we collect data about child windows even for invisible owners, since they may have
        // visible children.
        if (!iconified) {
            childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
        }
    }
    // If some windows, which have just been ordered, have any child windows, let's start new iteration
    // and order these child windows.
    if (!childWindows.isEmpty()) {
        orderAboveSiblingsImpl(childWindows.toArray(new Window[0]));
    }
}
 
Example 19
Source File: CPlatformWindow.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private void orderAboveSiblingsImpl(Window[] windows) {
    ArrayList<Window> childWindows = new ArrayList<Window>();

    final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
    final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();

    // Go through the list of windows and perform ordering.
    for (Window w : windows) {
        boolean iconified = false;
        final Object p = componentAccessor.getPeer(w);
        if (p instanceof LWWindowPeer) {
            CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
            iconified = isIconified();
            if (pw != null && pw.isVisible() && !iconified) {
                // If the window is one of ancestors of 'main window' or is going to become main by itself,
                // the window should be ordered above its siblings; otherwise the window is just ordered
                // above its nearest parent.
                if (pw.isOneOfOwnersOrSelf(this)) {
                    pw.execute(CWrapper.NSWindow::orderFront);
                } else {
                    pw.owner.execute(ownerPtr -> {
                        pw.execute(ptr -> {
                            CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
                        });
                    });
                }
                pw.applyWindowLevel(w);
            }
        }
        // Retrieve the child windows for each window from the list except iconified ones
        // and store them for future use.
        // Note: we collect data about child windows even for invisible owners, since they may have
        // visible children.
        if (!iconified) {
            childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
        }
    }
    // If some windows, which have just been ordered, have any child windows, let's start new iteration
    // and order these child windows.
    if (!childWindows.isEmpty()) {
        orderAboveSiblingsImpl(childWindows.toArray(new Window[0]));
    }
}
 
Example 20
Source File: CPlatformWindow.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void orderAboveSiblingsImpl(Window[] windows) {
    ArrayList<Window> childWindows = new ArrayList<Window>();

    final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
    final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();

    // Go through the list of windows and perform ordering.
    for (Window w : windows) {
        boolean iconified = false;
        final Object p = componentAccessor.getPeer(w);
        if (p instanceof LWWindowPeer) {
            CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
            iconified = isIconified();
            if (pw != null && pw.isVisible() && !iconified) {
                // If the window is one of ancestors of 'main window' or is going to become main by itself,
                // the window should be ordered above its siblings; otherwise the window is just ordered
                // above its nearest parent.
                if (pw.isOneOfOwnersOrSelf(this)) {
                    pw.execute(CWrapper.NSWindow::orderFront);
                } else {
                    pw.owner.execute(ownerPtr -> {
                        pw.execute(ptr -> {
                            CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, ownerPtr);
                        });
                    });
                }
                pw.applyWindowLevel(w);
            }
        }
        // Retrieve the child windows for each window from the list except iconified ones
        // and store them for future use.
        // Note: we collect data about child windows even for invisible owners, since they may have
        // visible children.
        if (!iconified) {
            childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
        }
    }
    // If some windows, which have just been ordered, have any child windows, let's start new iteration
    // and order these child windows.
    if (!childWindows.isEmpty()) {
        orderAboveSiblingsImpl(childWindows.toArray(new Window[0]));
    }
}