list windows: process (PID): inherit PID recursively from parent if the _NET_WM_PID property is missing
--- 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() {
}
};
--- 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::RelationalWriter> writer, std::function<void() > relationalWriterFlush) {
+ void listWindow(const Display& display, Window window, relpipe::common::type::Integer level, relpipe::common::type::Integer parentProcess, Configuration& configuration, std::shared_ptr<writer::RelationalWriter> writer, std::function<void() > 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);
}
}