Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwincapturablewindows.cpp
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
7#include <qt_windows.h>
8
10
11static QString windowTitle(HWND hwnd) {
12 // QTBUG-114890
13 // TODO: investigate the case when hwnd is inner and belows to another thread.
14 // It might causes deadlocks in specific cases.
15 auto titleLength = ::GetWindowTextLengthW(hwnd);
16 std::wstring buffer(titleLength, L'\0');
17 titleLength = ::GetWindowTextW(hwnd, buffer.data(), titleLength);
18 buffer.resize(titleLength);
19
21}
22
24{
26
27 auto windowHandler = [](HWND hwnd, LPARAM lParam) {
28 auto& windows = *reinterpret_cast<QList<QCapturableWindow>*>(lParam);
29
30 auto windowData = std::make_unique<QCapturableWindowPrivate>();
31 windowData->id = reinterpret_cast<QCapturableWindowPrivate::Id>(hwnd);
32 windowData->description = windowTitle(hwnd);
33 windows.push_back(windowData.release()->create());
34
35 return TRUE;
36 };
37
38 ::EnumWindows(windowHandler, reinterpret_cast<LPARAM>(&result));
39
40 return result;
41}
42
44{
45 const auto hwnd = reinterpret_cast<HWND>(window.id);
46 return hwnd && ::GetAncestor(hwnd, GA_ROOT) == hwnd;
47}
48
Definition qlist.h:74
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString fromStdWString(const std::wstring &s)
Returns a copy of the str string.
Definition qstring.h:1333
bool isWindowValid(const QCapturableWindowPrivate &window) const override
QList< QCapturableWindow > windows() const override
Combined button and popup list for selecting options.
GLenum GLuint buffer
GLuint64EXT * result
[6]
static QT_BEGIN_NAMESPACE QString windowTitle(HWND hwnd)
aWidget window() -> setWindowTitle("New Window Title")
[2]