use of sun.awt.X11GraphicsEnvironment 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;
}
Aggregations