我试图按顺序获取所有窗口,但XQueryTree的算法令我感到困惑。这就是我所做的:
我的收藏品阵列:[]
A
,我将其推送到数组的开头。所以[A]
[B, A]
B
并找到子B1, B2
[B1, B, A]
B2
所以现在[B2, B1, B, A]
C
开始,现在[C, B2, B1, B, A]
C
并且找不到孩子,所以继续D
开始,现在[D, C, B2, B1, B, A]
D
并且找不到孩子当我写这个算法时,我正在自己辩论,这是从最顶部到最底部的z顺序的正确算法吗?当我使用下面的代码实现它时,它看起来并不正确。 D
应该是z次序中最顶层的,A
应该是最底层的。{/ p>
这是我现在的代码:
var rezWinArr = [];
var processWin = function(w) {
rezWinArr.splice(0, 0, thisWin); // puts the win into the array at position 0
var rez_XQ = ostypes.API('XQueryTree')(ostypes.HELPER.cachedXOpenDisplay(), w, xqRoot.address(), xqParent.address(), xqChildArr.address(), nChilds.address()); // interesting note about XQueryTree and workspaces: "The problem with this approach is that it will only return windows on the same virtual desktop. In the case of multiple virtual desktops, windows on other virtual desktops will be ignored." source: http://www.experts-exchange.com/Programming/System/Q_21443252.html
var jsNC = parseInt(cutils.jscGetDeepest(nChilds));
if (jsNC > 0) {
var jsChildArr = ctypes.cast(xqChildArr, ostypes.TYPE.Window.array(jsNC).ptr).contents;
for (var i = 0; i < jsNC; i++) {
var wChild = jsChildArr[i];
processWin(wChild);
}
ostypes.API('XFree')(xqChildArr);
}
}
processWin(ostypes.HELPER.cachedDefaultRootWindow());
谢谢!