Made iterateWindow actually use parent window

This commit is contained in:
WebFreak001 2018-03-08 21:48:35 +01:00
parent 3300a69966
commit 652b30151f
1 changed files with 8 additions and 3 deletions

View File

@ -31,7 +31,7 @@ struct WindowChildrenIterator {
EnumParams params; EnumParams params;
EnumWindows(function (window, lparam) nothrow { EnumChildWindows(parent, function (window, lparam) nothrow {
EnumParams* args = cast(EnumParams*)lparam; EnumParams* args = cast(EnumParams*)lparam;
try { try {
args.result = args.dg(window); args.result = args.dg(window);
@ -54,8 +54,7 @@ struct WindowChildrenIterator {
Window unusedWindow; Window unusedWindow;
Window* children; Window* children;
uint numChildren; uint numChildren;
Status status = XQueryTree(XDisplayConnection.get(), RootWindow(XDisplayConnection.get, DefaultScreen(XDisplayConnection.get)), Status status = XQueryTree(XDisplayConnection.get(), parent, &unusedWindow, &unusedWindow, &children, &numChildren);
&unusedWindow, &unusedWindow, &children, &numChildren);
if (status == 0 || children is null) if (status == 0 || children is null)
return 0; return 0;
scope (exit) scope (exit)
@ -149,3 +148,9 @@ int ownerPID(NativeWindowHandle window) @property {
} }
return -1; return -1;
} }
unittest {
import std.stdio;
auto window = findWindowByClass("x-terminal-emulator");
writeln("Terminal: ", window.ownerPID);
}