From 652b30151f7b43298b3dac17f016a9977b298609 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Thu, 8 Mar 2018 21:48:35 +0100 Subject: [PATCH] Made iterateWindow actually use parent window --- wmutil.d | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wmutil.d b/wmutil.d index eeb8171..e83edbd 100644 --- a/wmutil.d +++ b/wmutil.d @@ -31,7 +31,7 @@ struct WindowChildrenIterator { EnumParams params; - EnumWindows(function (window, lparam) nothrow { + EnumChildWindows(parent, function (window, lparam) nothrow { EnumParams* args = cast(EnumParams*)lparam; try { args.result = args.dg(window); @@ -54,8 +54,7 @@ struct WindowChildrenIterator { Window unusedWindow; Window* children; uint numChildren; - Status status = XQueryTree(XDisplayConnection.get(), RootWindow(XDisplayConnection.get, DefaultScreen(XDisplayConnection.get)), - &unusedWindow, &unusedWindow, &children, &numChildren); + Status status = XQueryTree(XDisplayConnection.get(), parent, &unusedWindow, &unusedWindow, &children, &numChildren); if (status == 0 || children is null) return 0; scope (exit) @@ -149,3 +148,9 @@ int ownerPID(NativeWindowHandle window) @property { } return -1; } + +unittest { + import std.stdio; + auto window = findWindowByClass("x-terminal-emulator"); + writeln("Terminal: ", window.ownerPID); +}