# HG changeset patch # User František Kučera # Date 1618144631 -7200 # Node ID 3948229234cd98f4eecbb98fb5601792b106db11 # Parent 803beead60c4b1be40f34cb87b84cd38287515a7 list windows: process (PID): inherit PID recursively from parent if the _NET_WM_PID property is missing diff -r 803beead60c4 -r 3948229234cd src/Configuration.h --- a/src/Configuration.h Sat Apr 10 21:10:17 2021 +0200 +++ b/src/Configuration.h Sun Apr 11 14:37:11 2021 +0200 @@ -33,6 +33,8 @@ bool listWindows = false; bool listScreens = false; + bool inheritProcessIdInWindowList = true; + virtual ~Configuration() { } }; diff -r 803beead60c4 -r 3948229234cd src/X11Command.h --- a/src/X11Command.h Sat Apr 10 21:10:17 2021 +0200 +++ b/src/X11Command.h Sun Apr 11 14:37:11 2021 +0200 @@ -323,7 +323,7 @@ return result; } - void listWindow(const Display& display, Window window, relpipe::common::type::Integer level, Configuration& configuration, std::shared_ptr writer, std::function relationalWriterFlush) { + void listWindow(const Display& display, Window window, relpipe::common::type::Integer level, relpipe::common::type::Integer parentProcess, Configuration& configuration, std::shared_ptr writer, std::function relationalWriterFlush) { Window rootWindow; Window parentWindow; unsigned int childrenCount; @@ -347,6 +347,7 @@ // The PID as reported by the application itself in the property. Some applications do not report their PID. relpipe::common::type::Integer processId = findWindowPropertyInteger(display, window, "_NET_WM_PID"); + if (configuration.inheritProcessIdInWindowList && processId < 0) processId = parentProcess; // TODO: support also other properties: customizable through options or all in a nested structure/relation/xml writer->writeAttribute(std::to_wstring(window)); @@ -362,7 +363,7 @@ writer->writeAttribute(std::to_wstring(windowAttributes.width)); writer->writeAttribute(std::to_wstring(windowAttributes.height)); - for (unsigned int i = 0; i < childrenCount; i++) listWindow(display, childrenList[i], level + 1, configuration, writer, relationalWriterFlush); + for (unsigned int i = 0; i < childrenCount; i++) listWindow(display, childrenList[i], level + 1, processId, configuration, writer, relationalWriterFlush); XFree(childrenList); } @@ -385,7 +386,7 @@ for (int screenCount = XScreenCount(display.display), screen = 0; screen < screenCount; screen++) { Window root = RootWindow(display.display, screen); - listWindow(display, root, 0, configuration, writer, relationalWriterFlush); + listWindow(display, root, 0, -1, configuration, writer, relationalWriterFlush); } }