| 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 |  | 
| 4 | #include "qcapturablewindow.h" | 
| 5 | #include "qcapturablewindow_p.h" | 
| 6 | #include "qplatformmediaintegration_p.h" | 
| 7 |  | 
| 8 | QT_BEGIN_NAMESPACE | 
| 9 |  | 
| 10 | QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QCapturableWindowPrivate) | 
| 11 |  | 
| 12 | /*! | 
| 13 |     \class QCapturableWindow | 
| 14 |     \inmodule QtMultimedia | 
| 15 |     \ingroup multimedia | 
| 16 |     \ingroup multimedia_video | 
| 17 |     \since 6.6 | 
| 18 |  | 
| 19 |     \brief Used for getting the basic information of a capturable window. | 
| 20 |  | 
| 21 |     The class contains a set of window information, except the method | 
| 22 |     QCapturableWindow::isValid which pulls the current state | 
| 23 |     whenever it's called. | 
| 24 |  | 
| 25 |     \sa QWindowCapture | 
| 26 | */ | 
| 27 | /*! | 
| 28 |     \qmlvaluetype CapturableWindow | 
| 29 |     \nativetype QCapturableWindow | 
| 30 |     \brief The CapturableWindow type is used getting basic | 
| 31 |     of a window that is available for capturing via WindowCapture. | 
| 32 |  | 
| 33 |     \inqmlmodule QtMultimedia | 
| 34 |     \ingroup multimedia_qml | 
| 35 |     \ingroup multimedia_video_qml | 
| 36 |     \since 6.6 | 
| 37 |  | 
| 38 |     The class contains a dump of window information, except the property | 
| 39 |     'isValid' which pulls the actual window state every time. | 
| 40 |  | 
| 41 |     \sa WindowCapture | 
| 42 | */ | 
| 43 |  | 
| 44 | /*! | 
| 45 |     \fn  QCapturableWindow::QCapturableWindow(QCapturableWindow &&other) | 
| 46 |  | 
| 47 |     Constructs a QCapturableWindow by moving from \a other. | 
| 48 | */ | 
| 49 |  | 
| 50 | /*! | 
| 51 |     \fn void QCapturableWindow::swap(QCapturableWindow &other) noexcept | 
| 52 |  | 
| 53 |     Swaps the current window information with \a other. | 
| 54 | */ | 
| 55 |  | 
| 56 | /*! | 
| 57 |     \fn  QCapturableWindow &QCapturableWindow::operator=(QCapturableWindow &&other) | 
| 58 |  | 
| 59 |     Moves \a other into this QCapturableWindow. | 
| 60 | */ | 
| 61 |  | 
| 62 | /*! | 
| 63 |     Constructs a null capturable window information that doesn't refer to any window. | 
| 64 | */ | 
| 65 | QCapturableWindow::QCapturableWindow() = default; | 
| 66 |  | 
| 67 | /*! | 
| 68 |     Destroys the window information. | 
| 69 |  */ | 
| 70 | QCapturableWindow::~QCapturableWindow() = default; | 
| 71 |  | 
| 72 | /*! | 
| 73 |     Construct a new window information using \a other QCapturableWindow. | 
| 74 | */ | 
| 75 | QCapturableWindow::QCapturableWindow(const QCapturableWindow &other) = default; | 
| 76 |  | 
| 77 | /*! | 
| 78 |     Assigns the \a other window information to this QCapturableWindow. | 
| 79 | */ | 
| 80 | QCapturableWindow& QCapturableWindow::operator=(const QCapturableWindow &other) = default; | 
| 81 |  | 
| 82 | /*! | 
| 83 |     \fn bool QCapturableWindow::operator==(const QCapturableWindow &lhs, const QCapturableWindow &rhs) | 
| 84 |  | 
| 85 |     Returns \c true if window information \a lhs and \a rhs refer to the same window, | 
| 86 |     otherwise returns \c false. | 
| 87 | */ | 
| 88 |  | 
| 89 | /*! | 
| 90 |     \fn bool QCapturableWindow::operator!=(const QCapturableWindow &lhs, const QCapturableWindow &rhs) | 
| 91 |  | 
| 92 |     Returns \c true if window information \a lhs and \a rhs refer to different windows, | 
| 93 |     otherwise returns \c false. | 
| 94 | */ | 
| 95 | bool operator==(const QCapturableWindow &lhs, const QCapturableWindow &rhs) noexcept | 
| 96 | { | 
| 97 |     return lhs.d == rhs.d || (lhs.d && rhs.d && lhs.d->id == rhs.d->id); | 
| 98 | } | 
| 99 |  | 
| 100 | /*! | 
| 101 |     \qmlproperty string QtMultimedia::CapturableWindow::isValid | 
| 102 |  | 
| 103 |     This property identifies whether a window information is valid. | 
| 104 |  | 
| 105 |     An invalid window information refers to non-existing window or doesn't refer to any one. | 
| 106 | */ | 
| 107 |  | 
| 108 | /*! | 
| 109 |     Identifies whether a window information is valid. | 
| 110 |  | 
| 111 |     An invalid window information refers to non-existing window or doesn't refer to any one. | 
| 112 |  | 
| 113 |     Returns true if the window is valid, and false if it is not. | 
| 114 | */ | 
| 115 | bool QCapturableWindow::isValid() const | 
| 116 | { | 
| 117 |     return d && QPlatformMediaIntegration::instance()->isCapturableWindowValid(*d); | 
| 118 | } | 
| 119 |  | 
| 120 | /*! | 
| 121 |     \qmlproperty string QtMultimedia::CapturableWindow::description | 
| 122 |  | 
| 123 |     This property holds the description of the reffered window. | 
| 124 | */ | 
| 125 |  | 
| 126 | /*! | 
| 127 |     Returns a description of the window. In most cases it represents the window title. | 
| 128 | */ | 
| 129 | QString QCapturableWindow::description() const | 
| 130 | { | 
| 131 |     if (!d) | 
| 132 |         return {}; | 
| 133 |  | 
| 134 |     if (d->description.isEmpty() && d->id) | 
| 135 |         return QLatin1String("Window 0x" ) + QString::number(d->id, base: 16); | 
| 136 |  | 
| 137 |     return d->description; | 
| 138 | } | 
| 139 |  | 
| 140 | QCapturableWindow::QCapturableWindow(QCapturableWindowPrivate *capturablePrivate) | 
| 141 |     : d(capturablePrivate) | 
| 142 | { | 
| 143 | } | 
| 144 |  | 
| 145 | #ifndef QT_NO_DEBUG_STREAM | 
| 146 | QDebug operator<<(QDebug dbg, const QCapturableWindow &window) | 
| 147 | { | 
| 148 |     dbg << QStringLiteral("Capturable window '%1'" ).arg(a: window.description()); | 
| 149 |     return dbg; | 
| 150 | } | 
| 151 | #endif | 
| 152 |  | 
| 153 |  | 
| 154 | QT_END_NAMESPACE | 
| 155 |  | 
| 156 | #include "moc_qcapturablewindow.cpp" | 
| 157 |  |