39 QMacAutoReleasePool autoReleasePool;
42 q23::expected<QMacScreenCaptureKit::CapturableItems, QString> enumerateResult =
43 QMacScreenCaptureKit::enumerateCapturableItems()
45 if (!enumerateResult) {
46 qCWarning(qLcMacScreenCapture)
47 <<
"Failed to enumerate capturable windows/displays: "
48 << enumerateResult.error();
52 QMacScreenCaptureKit::CapturableItems
const &capturableItems = *enumerateResult;
54 QList<QCapturableWindow> result;
56 for (AVFScopedPointer<SCWindow>
const &window : capturableItems.windows) {
59 if (!window.data().onScreen)
62 QString bundleIdentifier = QString::fromNSString(window.data().owningApplication.bundleIdentifier);
64 if (bundleIdentifier.isEmpty())
67 bool bundleIdentifierBlacklisted = std::any_of(
68 windowBundleIdentifierBlacklist.begin(),
69 windowBundleIdentifierBlacklist.end(),
70 [&](
const char *identifier) {
71 return QString::fromLatin1(identifier, -1) == bundleIdentifier;
73 if (bundleIdentifierBlacklisted)
77 QString title = QString::fromNSString(window.data().title);
81 result.push_back(QCapturableWindowPrivate::create(
82 static_cast<QCapturableWindowPrivate::Id>(window.data().windowID),
92 QMacAutoReleasePool autoReleasePool;
98 q23::expected<QMacScreenCaptureKit::CapturableItems, QString> enumerateResult =
99 QMacScreenCaptureKit::enumerateCapturableItems()
101 if (!enumerateResult) {
102 qCWarning(qLcMacScreenCapture)
103 <<
"Failed to enumerate capturable windows/displays during QSckCapturableWindows::isWindowValid: "
104 << enumerateResult.error();
108 std::vector<AVFScopedPointer<SCWindow>>
const &windows = enumerateResult->windows;
113 [&](AVFScopedPointer<SCWindow>
const &item) {
114 return item.data().windowID ==
static_cast<CGWindowID>(window.id);
121 QMacAutoReleasePool autoReleasePool;
123 auto *nsView =
reinterpret_cast<NSView*>(window->winId());
125 NSWindow *nsWindow = [nsView window];
126 if (nsWindow ==
nullptr)
127 return q23::unexpected{ QStringLiteral(
"NSView had no associated NSWindow") };
129 auto cgWindowId = (CGWindowID)[nsWindow windowNumber];
130 if (cgWindowId == kCGNullWindowID)
131 return q23::unexpected{ QStringLiteral(
"NSWindow has no CGWindowID") };
133 return QCapturableWindowPrivate::create(
134 static_cast<QCapturableWindowPrivate::Id>(cgWindowId),