Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcgcapturablewindows.mm
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include "private/qcapturablewindow_p.h"
6#include "QtCore/private/qcore_mac_p.h"
7
8#include <AppKit/NSWindow.h>
9
11
12QList<QCapturableWindow> QCGCapturableWindows::windows() const
13{
14 QList<QCapturableWindow> result;
15 QCFType<CFArrayRef> windowList(
16 CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID));
17
18 // Iterate through the window dictionaries
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);
24
25 CGWindowID windowId = 0;
26 static_assert(sizeof(windowId) == 4,
27 "CGWindowID size is not compatible with kCFNumberSInt32Type");
28 CFNumberGetValue(windowNumber, kCFNumberSInt32Type, &windowId);
29
30 auto windowData = std::make_unique<QCapturableWindowPrivate>();
31 windowData->id = static_cast<QCapturableWindowPrivate::Id>(windowId);
32 if (windowName)
33 windowData->description = QString::fromCFString(windowName);
34
35 result.push_back(windowData.release()->create());
36 }
37
38 return result;
39}
40
42{
43 QCFType<CFArrayRef> windowList(
44 CGWindowListCreate(kCGWindowListOptionIncludingWindow, window.id));
45 return CFArrayGetCount(windowList) > 0;
46}
47
bool isWindowValid(const QCapturableWindowPrivate &window) const override
QList< QCapturableWindow > windows() const override
Combined button and popup list for selecting options.
GLenum GLenum GLsizei count
GLuint64EXT * result
[6]
aWidget window() -> setWindowTitle("New Window Title")
[2]