Java Code Examples for sun.awt.X11GraphicsEnvironment#getScreenDevices()

The following examples show how to use sun.awt.X11GraphicsEnvironment#getScreenDevices() . 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: XWindowPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 2
Source File: XWindowPeer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 3
Source File: XWindowPeer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 4
Source File: XWindowPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 5
Source File: XWindowPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 6
Source File: XWindowPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 7
Source File: XWindowPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 8
Source File: XWindowPeer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 9
Source File: XWindowPeer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 10
Source File: XWindowPeer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 11
Source File: XWindowPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}
 
Example 12
Source File: XWindowPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
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;
}