Search in sources :

Example 1 with X11GraphicsDevice

use of sun.awt.X11GraphicsDevice in project jdk8u_jdk by JetBrains.

the class XWindowPeer method collectJavaToplevels.

/*
     * Returns a Vector of all Java top-level windows,
     * sorted by their current Z-order
     */
static Vector<XWindowPeer> collectJavaToplevels() {
    Vector<XWindowPeer> javaToplevels = new Vector<XWindowPeer>();
    Vector<Long> v = new Vector<Long>();
    X11GraphicsEnvironment ge = (X11GraphicsEnvironment) GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (!ge.runningXinerama() && (gds.length > 1)) {
        for (GraphicsDevice gd : gds) {
            int screen = ((X11GraphicsDevice) gd).getScreen();
            long rootWindow = XlibWrapper.RootWindow(XToolkit.getDisplay(), screen);
            v.add(rootWindow);
        }
    } else {
        v.add(XToolkit.getDefaultRootWindow());
    }
    final int windowsCount = windows.size();
    while ((v.size() > 0) && (javaToplevels.size() < windowsCount)) {
        long win = v.remove(0);
        XQueryTree qt = new XQueryTree(win);
        try {
            if (qt.execute() != 0) {
                int nchildren = qt.get_nchildren();
                long children = qt.get_children();
                // XQueryTree returns window children ordered by z-order
                for (int i = 0; i < nchildren; i++) {
                    long child = Native.getWindow(children, i);
                    XBaseWindow childWindow = XToolkit.windowToXWindow(child);
                    // filter out Java non-toplevels
                    if ((childWindow != null) && !(childWindow instanceof XWindowPeer)) {
                        continue;
                    } else {
                        v.add(child);
                    }
                    if (childWindow instanceof XWindowPeer) {
                        XWindowPeer np = (XWindowPeer) childWindow;
                        javaToplevels.add(np);
                        // XQueryTree returns windows sorted by their z-order. However,
                        // if WM has not handled transient for hint for a child window,
                        // it may appear in javaToplevels before its owner. Move such
                        // children after their owners.
                        int k = 0;
                        XWindowPeer toCheck = javaToplevels.get(k);
                        while (toCheck != np) {
                            XWindowPeer toCheckOwnerPeer = toCheck.getOwnerPeer();
                            if (toCheckOwnerPeer == np) {
                                javaToplevels.remove(k);
                                javaToplevels.add(toCheck);
                            } else {
                                k++;
                            }
                            toCheck = javaToplevels.get(k);
                        }
                    }
                }
            }
        } finally {
            qt.dispose();
        }
    }
    return javaToplevels;
}
Also used : X11GraphicsEnvironment(sun.awt.X11GraphicsEnvironment) X11GraphicsDevice(sun.awt.X11GraphicsDevice) X11GraphicsDevice(sun.awt.X11GraphicsDevice) Vector(java.util.Vector)

Example 2 with X11GraphicsDevice

use of sun.awt.X11GraphicsDevice in project jdk8u_jdk by JetBrains.

the class XEmbedClientHelper method handleReparentNotify.

public void handleReparentNotify(XEvent xev) {
    XReparentEvent re = xev.get_xreparent();
    long newParent = re.get_parent();
    if (active) {
        // unregister accelerators, etc. for old parent
        embedded.notifyStopped();
        // check if newParent is a root window
        X11GraphicsConfig gc = (X11GraphicsConfig) embedded.getGraphicsConfiguration();
        X11GraphicsDevice gd = (X11GraphicsDevice) gc.getDevice();
        if ((newParent == XlibUtil.getRootWindow(gd.getScreen())) || (newParent == XToolkit.getDefaultRootWindow())) {
            // reparenting to root means XEmbed termination
            active = false;
        } else {
            // continue XEmbed with a new parent
            server = newParent;
            embedded.notifyStarted();
        }
    }
}
Also used : X11GraphicsConfig(sun.awt.X11GraphicsConfig) X11GraphicsDevice(sun.awt.X11GraphicsDevice)

Example 3 with X11GraphicsDevice

use of sun.awt.X11GraphicsDevice in project jdk8u_jdk by JetBrains.

the class XCanvasPeer method getAppropriateGraphicsConfiguration.

/* Get a GraphicsConfig with the same visual on the new
     * screen, which should be easy in Xinerama mode.
     */
public GraphicsConfiguration getAppropriateGraphicsConfiguration(GraphicsConfiguration gc) {
    if (graphicsConfig == null || gc == null) {
        return gc;
    }
    // Opt: Only need to do if we're not using the default GC
    int screenNum = ((X11GraphicsDevice) gc.getDevice()).getScreen();
    X11GraphicsConfig parentgc;
    // save vis id of current gc
    int visual = graphicsConfig.getVisual();
    X11GraphicsDevice newDev = (X11GraphicsDevice) GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[screenNum];
    for (int i = 0; i < newDev.getNumConfigs(screenNum); i++) {
        if (visual == newDev.getConfigVisualId(i, screenNum)) {
            // use that
            graphicsConfig = (X11GraphicsConfig) newDev.getConfigurations()[i];
            break;
        }
    }
    // just in case...
    if (graphicsConfig == null) {
        graphicsConfig = (X11GraphicsConfig) GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[screenNum].getDefaultConfiguration();
    }
    return graphicsConfig;
}
Also used : X11GraphicsConfig(sun.awt.X11GraphicsConfig) X11GraphicsDevice(sun.awt.X11GraphicsDevice)

Aggregations

X11GraphicsDevice (sun.awt.X11GraphicsDevice)3 X11GraphicsConfig (sun.awt.X11GraphicsConfig)2 Vector (java.util.Vector)1 X11GraphicsEnvironment (sun.awt.X11GraphicsEnvironment)1