261 relationalWriterFlush(); |
261 relationalWriterFlush(); |
262 } |
262 } |
263 } |
263 } |
264 |
264 |
265 relpipe::common::type::StringX fetchWindowName(const Display& display, Window window) { |
265 relpipe::common::type::StringX fetchWindowName(const Display& display, Window window) { |
266 relpipe::common::type::StringX name; |
266 std::string name; |
267 // TODO: this does not work → use XGetWMName(), XmbTextPropertyToTextList(), XFreeStringList() instead of XFetchName() |
267 |
268 // char* rawName = nullptr; |
268 XTextProperty property; |
269 // if (XFetchName(display.display, window, &rawName) && rawName) |
269 if (XGetWMName(display.display, window, &property) && property.nitems > 0) { |
270 // name = convertor.from_bytes(rawName); // bad encoding, std::range_error – wstring_convert::from_bytes |
270 int count = 0; |
271 // std::cout << "\n\n\n>>> " << rawName << " <<<\n\n\n"; // bad encoding, not UTF-8 |
271 int result; |
272 //XFree(rawName); |
272 char** list = nullptr; |
273 return name; |
273 result = XmbTextPropertyToTextList(display.display, &property, &list, &count); |
|
274 if ((result == Success || result > 0) && list) for (int i = 0; i < count; i++) name.append(list[i]); |
|
275 // else name = (char*) property.value; // TODO: use property.value? |
|
276 XFreeStringList(list); |
|
277 } |
|
278 XFree(property.value); |
|
279 |
|
280 return convertor.from_bytes(name); |
274 } |
281 } |
275 |
282 |
276 void listWindow(const Display& display, Window window, relpipe::common::type::Integer level, Configuration& configuration, std::shared_ptr<writer::RelationalWriter> writer, std::function<void() > relationalWriterFlush) { |
283 void listWindow(const Display& display, Window window, relpipe::common::type::Integer level, Configuration& configuration, std::shared_ptr<writer::RelationalWriter> writer, std::function<void() > relationalWriterFlush) { |
277 Window rootWindow; |
284 Window rootWindow; |
278 Window parentWindow; |
285 Window parentWindow; |