14 QList<QCapturableWindow>
result;
15 QCFType<CFArrayRef> windowList(
16 CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID));
19 CFIndex
count = CFArrayGetCount(windowList);
20 for (CFIndex
i = 0;
i <
count; ++
i) {
21 auto windowInfo = (CFDictionaryRef)CFArrayGetValueAtIndex(windowList,
i);
22 auto windowNumber = (CFNumberRef)CFDictionaryGetValue(windowInfo, kCGWindowNumber);
23 auto windowName = (CFStringRef)CFDictionaryGetValue(windowInfo, kCGWindowName);
25 CGWindowID windowId = 0;
26 static_assert(
sizeof(windowId) == 4,
27 "CGWindowID size is not compatible with kCFNumberSInt32Type");
28 CFNumberGetValue(windowNumber, kCFNumberSInt32Type, &windowId);
30 auto windowData = std::make_unique<QCapturableWindowPrivate>();
33 windowData->description = QString::fromCFString(windowName);
35 result.push_back(windowData.release()->create());