src/X11Command.h
branchv_0
changeset 11 3948229234cd
parent 10 803beead60c4
equal deleted inserted replaced
10:803beead60c4 11:3948229234cd
   321 		XFree(rawResult);
   321 		XFree(rawResult);
   322 
   322 
   323 		return result;
   323 		return result;
   324 	}
   324 	}
   325 
   325 
   326 	void listWindow(const Display& display, Window window, relpipe::common::type::Integer level, Configuration& configuration, std::shared_ptr<writer::RelationalWriter> writer, std::function<void() > relationalWriterFlush) {
   326 	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) {
   327 		Window rootWindow;
   327 		Window rootWindow;
   328 		Window parentWindow;
   328 		Window parentWindow;
   329 		unsigned int childrenCount;
   329 		unsigned int childrenCount;
   330 		Window* childrenList;
   330 		Window* childrenList;
   331 		if (!XQueryTree(display.display, window, &rootWindow, &parentWindow, &childrenList, &childrenCount))
   331 		if (!XQueryTree(display.display, window, &rootWindow, &parentWindow, &childrenList, &childrenCount))
   345 			XFree(classHint.res_name);
   345 			XFree(classHint.res_name);
   346 		}
   346 		}
   347 
   347 
   348 		// The PID as reported by the application itself in the property. Some applications do not report their PID.
   348 		// The PID as reported by the application itself in the property. Some applications do not report their PID.
   349 		relpipe::common::type::Integer processId = findWindowPropertyInteger(display, window, "_NET_WM_PID");
   349 		relpipe::common::type::Integer processId = findWindowPropertyInteger(display, window, "_NET_WM_PID");
       
   350 		if (configuration.inheritProcessIdInWindowList && processId < 0) processId = parentProcess;
   350 		// TODO: support also other properties: customizable through options or all in a nested structure/relation/xml
   351 		// TODO: support also other properties: customizable through options or all in a nested structure/relation/xml
   351 
   352 
   352 		writer->writeAttribute(std::to_wstring(window));
   353 		writer->writeAttribute(std::to_wstring(window));
   353 		writer->writeAttribute(std::to_wstring(windowAttributes.root));
   354 		writer->writeAttribute(std::to_wstring(windowAttributes.root));
   354 		writer->writeAttribute(std::to_wstring(parentWindow));
   355 		writer->writeAttribute(std::to_wstring(parentWindow));
   360 		writer->writeAttribute(std::to_wstring(windowAttributes.x));
   361 		writer->writeAttribute(std::to_wstring(windowAttributes.x));
   361 		writer->writeAttribute(std::to_wstring(windowAttributes.y));
   362 		writer->writeAttribute(std::to_wstring(windowAttributes.y));
   362 		writer->writeAttribute(std::to_wstring(windowAttributes.width));
   363 		writer->writeAttribute(std::to_wstring(windowAttributes.width));
   363 		writer->writeAttribute(std::to_wstring(windowAttributes.height));
   364 		writer->writeAttribute(std::to_wstring(windowAttributes.height));
   364 
   365 
   365 		for (unsigned int i = 0; i < childrenCount; i++) listWindow(display, childrenList[i], level + 1, configuration, writer, relationalWriterFlush);
   366 		for (unsigned int i = 0; i < childrenCount; i++) listWindow(display, childrenList[i], level + 1, processId, configuration, writer, relationalWriterFlush);
   366 
   367 
   367 		XFree(childrenList);
   368 		XFree(childrenList);
   368 	}
   369 	}
   369 
   370 
   370 	void listWindows(const Display& display, Configuration& configuration, std::shared_ptr<writer::RelationalWriter> writer, std::function<void() > relationalWriterFlush) {
   371 	void listWindows(const Display& display, Configuration& configuration, std::shared_ptr<writer::RelationalWriter> writer, std::function<void() > relationalWriterFlush) {
   383 			{L"height", relpipe::writer::TypeId::INTEGER},
   384 			{L"height", relpipe::writer::TypeId::INTEGER},
   384 		}, true);
   385 		}, true);
   385 
   386 
   386 		for (int screenCount = XScreenCount(display.display), screen = 0; screen < screenCount; screen++) {
   387 		for (int screenCount = XScreenCount(display.display), screen = 0; screen < screenCount; screen++) {
   387 			Window root = RootWindow(display.display, screen);
   388 			Window root = RootWindow(display.display, screen);
   388 			listWindow(display, root, 0, configuration, writer, relationalWriterFlush);
   389 			listWindow(display, root, 0, -1, configuration, writer, relationalWriterFlush);
   389 		}
   390 		}
   390 	}
   391 	}
   391 
   392 
   392 	void listScreens(const Display& display, Configuration& configuration, std::shared_ptr<writer::RelationalWriter> writer, std::function<void() > relationalWriterFlush) {
   393 	void listScreens(const Display& display, Configuration& configuration, std::shared_ptr<writer::RelationalWriter> writer, std::function<void() > relationalWriterFlush) {
   393 		writer->startRelation(L"x11_screen",{
   394 		writer->startRelation(L"x11_screen",{