| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qscreen.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | #include "qscreen.h" | - | ||||||||||||
| 35 | #include "qscreen_p.h" | - | ||||||||||||
| 36 | #include "qpixmap.h" | - | ||||||||||||
| 37 | #include "qguiapplication_p.h" | - | ||||||||||||
| 38 | #include <qpa/qplatformscreen.h> | - | ||||||||||||
| 39 | #include <qpa/qplatformscreen_p.h> | - | ||||||||||||
| 40 | - | |||||||||||||
| 41 | #include <QtCore/QDebug> | - | ||||||||||||
| 42 | #include <QtCore/private/qobject_p.h> | - | ||||||||||||
| 43 | #include "qhighdpiscaling_p.h" | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | /*! | - | ||||||||||||
| 48 | \class QScreen | - | ||||||||||||
| 49 | \since 5.0 | - | ||||||||||||
| 50 | \brief The QScreen class is used to query screen properties. | - | ||||||||||||
| 51 | \inmodule QtGui | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | A note on logical vs physical dots per inch: physical DPI is based on the | - | ||||||||||||
| 54 | actual physical pixel sizes when available, and is useful for print preview | - | ||||||||||||
| 55 | and other cases where it's desirable to know the exact physical dimensions | - | ||||||||||||
| 56 | of screen displayed contents. | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | Logical dots per inch are used to convert font and user interface elements | - | ||||||||||||
| 59 | from point sizes to pixel sizes, and might be different from the physical | - | ||||||||||||
| 60 | dots per inch. The logical dots per inch are sometimes user-settable in the | - | ||||||||||||
| 61 | desktop environment's settings panel, to let the user globally control UI | - | ||||||||||||
| 62 | and font sizes in different applications. | - | ||||||||||||
| 63 | - | |||||||||||||
| 64 | \inmodule QtGui | - | ||||||||||||
| 65 | */ | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | QScreen::QScreen(QPlatformScreen *screen) | - | ||||||||||||
| 68 | : QObject(*new QScreenPrivate(), 0) | - | ||||||||||||
| 69 | { | - | ||||||||||||
| 70 | Q_D(QScreen); | - | ||||||||||||
| 71 | d->setPlatformScreen(screen); | - | ||||||||||||
| 72 | } never executed: end of block | 0 | ||||||||||||
| 73 | - | |||||||||||||
| 74 | void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen) | - | ||||||||||||
| 75 | { | - | ||||||||||||
| 76 | Q_Q(QScreen); | - | ||||||||||||
| 77 | platformScreen = screen; | - | ||||||||||||
| 78 | platformScreen->d_func()->screen = q; | - | ||||||||||||
| 79 | orientation = platformScreen->orientation(); | - | ||||||||||||
| 80 | geometry = platformScreen->deviceIndependentGeometry(); | - | ||||||||||||
| 81 | availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft()); | - | ||||||||||||
| 82 | logicalDpi = platformScreen->logicalDpi(); | - | ||||||||||||
| 83 | refreshRate = platformScreen->refreshRate(); | - | ||||||||||||
| 84 | // safeguard ourselves against buggy platform behavior... | - | ||||||||||||
| 85 | if (refreshRate < 1.0)
| 0 | ||||||||||||
| 86 | refreshRate = 60.0; never executed: refreshRate = 60.0; | 0 | ||||||||||||
| 87 | - | |||||||||||||
| 88 | updatePrimaryOrientation(); | - | ||||||||||||
| 89 | - | |||||||||||||
| 90 | filteredOrientation = orientation; | - | ||||||||||||
| 91 | if (filteredOrientation == Qt::PrimaryOrientation)
| 0 | ||||||||||||
| 92 | filteredOrientation = primaryOrientation; never executed: filteredOrientation = primaryOrientation; | 0 | ||||||||||||
| 93 | - | |||||||||||||
| 94 | updateHighDpi(); | - | ||||||||||||
| 95 | } never executed: end of block | 0 | ||||||||||||
| 96 | - | |||||||||||||
| 97 | - | |||||||||||||
| 98 | /*! | - | ||||||||||||
| 99 | Destroys the screen. | - | ||||||||||||
| 100 | */ | - | ||||||||||||
| 101 | QScreen::~QScreen() | - | ||||||||||||
| 102 | { | - | ||||||||||||
| 103 | if (!qApp)
| 0 | ||||||||||||
| 104 | return; never executed: return; | 0 | ||||||||||||
| 105 | - | |||||||||||||
| 106 | // Allow clients to manage windows that are affected by the screen going | - | ||||||||||||
| 107 | // away, before we fall back to moving them to the primary screen. | - | ||||||||||||
| 108 | emit qApp->screenRemoved(this); | - | ||||||||||||
| 109 | - | |||||||||||||
| 110 | if (QGuiApplication::closingDown())
| 0 | ||||||||||||
| 111 | return; never executed: return; | 0 | ||||||||||||
| 112 | - | |||||||||||||
| 113 | QScreen *primaryScreen = QGuiApplication::primaryScreen(); | - | ||||||||||||
| 114 | if (this == primaryScreen)
| 0 | ||||||||||||
| 115 | return; never executed: return; | 0 | ||||||||||||
| 116 | - | |||||||||||||
| 117 | bool movingFromVirtualSibling = primaryScreen && primaryScreen->handle()->virtualSiblings().contains(handle());
| 0 | ||||||||||||
| 118 | - | |||||||||||||
| 119 | // Move any leftover windows to the primary screen | - | ||||||||||||
| 120 | foreach (QWindow *window, QGuiApplication::allWindows()) { | - | ||||||||||||
| 121 | if (!window->isTopLevel() || window->screen() != this)
| 0 | ||||||||||||
| 122 | continue; never executed: continue; | 0 | ||||||||||||
| 123 | - | |||||||||||||
| 124 | const bool wasVisible = window->isVisible(); | - | ||||||||||||
| 125 | window->setScreen(primaryScreen); | - | ||||||||||||
| 126 | - | |||||||||||||
| 127 | // Re-show window if moved from a virtual sibling screen. Otherwise | - | ||||||||||||
| 128 | // leave it up to the application developer to show the window. | - | ||||||||||||
| 129 | if (movingFromVirtualSibling)
| 0 | ||||||||||||
| 130 | window->setVisible(wasVisible); never executed: window->setVisible(wasVisible); | 0 | ||||||||||||
| 131 | } never executed: end of block | 0 | ||||||||||||
| 132 | } never executed: end of block | 0 | ||||||||||||
| 133 | - | |||||||||||||
| 134 | /*! | - | ||||||||||||
| 135 | Get the platform screen handle. | - | ||||||||||||
| 136 | */ | - | ||||||||||||
| 137 | QPlatformScreen *QScreen::handle() const | - | ||||||||||||
| 138 | { | - | ||||||||||||
| 139 | Q_D(const QScreen); | - | ||||||||||||
| 140 | return d->platformScreen; never executed: return d->platformScreen; | 0 | ||||||||||||
| 141 | } | - | ||||||||||||
| 142 | - | |||||||||||||
| 143 | /*! | - | ||||||||||||
| 144 | \property QScreen::name | - | ||||||||||||
| 145 | \brief a user presentable string representing the screen | - | ||||||||||||
| 146 | - | |||||||||||||
| 147 | For example, on X11 these correspond to the XRandr screen names, | - | ||||||||||||
| 148 | typically "VGA1", "HDMI1", etc. | - | ||||||||||||
| 149 | */ | - | ||||||||||||
| 150 | QString QScreen::name() const | - | ||||||||||||
| 151 | { | - | ||||||||||||
| 152 | Q_D(const QScreen); | - | ||||||||||||
| 153 | return d->platformScreen->name(); never executed: return d->platformScreen->name(); | 0 | ||||||||||||
| 154 | } | - | ||||||||||||
| 155 | - | |||||||||||||
| 156 | /*! | - | ||||||||||||
| 157 | \property QScreen::depth | - | ||||||||||||
| 158 | \brief the color depth of the screen | - | ||||||||||||
| 159 | */ | - | ||||||||||||
| 160 | int QScreen::depth() const | - | ||||||||||||
| 161 | { | - | ||||||||||||
| 162 | Q_D(const QScreen); | - | ||||||||||||
| 163 | return d->platformScreen->depth(); never executed: return d->platformScreen->depth(); | 0 | ||||||||||||
| 164 | } | - | ||||||||||||
| 165 | - | |||||||||||||
| 166 | /*! | - | ||||||||||||
| 167 | \property QScreen::size | - | ||||||||||||
| 168 | \brief the pixel resolution of the screen | - | ||||||||||||
| 169 | */ | - | ||||||||||||
| 170 | QSize QScreen::size() const | - | ||||||||||||
| 171 | { | - | ||||||||||||
| 172 | Q_D(const QScreen); | - | ||||||||||||
| 173 | return d->geometry.size(); never executed: return d->geometry.size(); | 0 | ||||||||||||
| 174 | } | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | /*! | - | ||||||||||||
| 177 | \property QScreen::physicalDotsPerInchX | - | ||||||||||||
| 178 | \brief the number of physical dots or pixels per inch in the horizontal direction | - | ||||||||||||
| 179 | - | |||||||||||||
| 180 | This value represents the actual horizontal pixel density on the screen's display. | - | ||||||||||||
| 181 | Depending on what information the underlying system provides the value might not be | - | ||||||||||||
| 182 | entirely accurate. | - | ||||||||||||
| 183 | - | |||||||||||||
| 184 | \sa physicalDotsPerInchY() | - | ||||||||||||
| 185 | */ | - | ||||||||||||
| 186 | qreal QScreen::physicalDotsPerInchX() const | - | ||||||||||||
| 187 | { | - | ||||||||||||
| 188 | return size().width() / physicalSize().width() * qreal(25.4); never executed: return size().width() / physicalSize().width() * qreal(25.4); | 0 | ||||||||||||
| 189 | } | - | ||||||||||||
| 190 | - | |||||||||||||
| 191 | /*! | - | ||||||||||||
| 192 | \property QScreen::physicalDotsPerInchY | - | ||||||||||||
| 193 | \brief the number of physical dots or pixels per inch in the vertical direction | - | ||||||||||||
| 194 | - | |||||||||||||
| 195 | This value represents the actual vertical pixel density on the screen's display. | - | ||||||||||||
| 196 | Depending on what information the underlying system provides the value might not be | - | ||||||||||||
| 197 | entirely accurate. | - | ||||||||||||
| 198 | - | |||||||||||||
| 199 | \sa physicalDotsPerInchX() | - | ||||||||||||
| 200 | */ | - | ||||||||||||
| 201 | qreal QScreen::physicalDotsPerInchY() const | - | ||||||||||||
| 202 | { | - | ||||||||||||
| 203 | return size().height() / physicalSize().height() * qreal(25.4); never executed: return size().height() / physicalSize().height() * qreal(25.4); | 0 | ||||||||||||
| 204 | } | - | ||||||||||||
| 205 | - | |||||||||||||
| 206 | /*! | - | ||||||||||||
| 207 | \property QScreen::physicalDotsPerInch | - | ||||||||||||
| 208 | \brief the number of physical dots or pixels per inch | - | ||||||||||||
| 209 | - | |||||||||||||
| 210 | This value represents the pixel density on the screen's display. | - | ||||||||||||
| 211 | Depending on what information the underlying system provides the value might not be | - | ||||||||||||
| 212 | entirely accurate. | - | ||||||||||||
| 213 | - | |||||||||||||
| 214 | This is a convenience property that's simply the average of the physicalDotsPerInchX | - | ||||||||||||
| 215 | and physicalDotsPerInchY properties. | - | ||||||||||||
| 216 | - | |||||||||||||
| 217 | \sa physicalDotsPerInchX() | - | ||||||||||||
| 218 | \sa physicalDotsPerInchY() | - | ||||||||||||
| 219 | */ | - | ||||||||||||
| 220 | qreal QScreen::physicalDotsPerInch() const | - | ||||||||||||
| 221 | { | - | ||||||||||||
| 222 | QSize sz = size(); | - | ||||||||||||
| 223 | QSizeF psz = physicalSize(); | - | ||||||||||||
| 224 | return ((sz.height() / psz.height()) + (sz.width() / psz.width())) * qreal(25.4 * 0.5); never executed: return ((sz.height() / psz.height()) + (sz.width() / psz.width())) * qreal(25.4 * 0.5); | 0 | ||||||||||||
| 225 | } | - | ||||||||||||
| 226 | - | |||||||||||||
| 227 | /*! | - | ||||||||||||
| 228 | \property QScreen::logicalDotsPerInchX | - | ||||||||||||
| 229 | \brief the number of logical dots or pixels per inch in the horizontal direction | - | ||||||||||||
| 230 | - | |||||||||||||
| 231 | This value is used to convert font point sizes to pixel sizes. | - | ||||||||||||
| 232 | - | |||||||||||||
| 233 | \sa logicalDotsPerInchY() | - | ||||||||||||
| 234 | */ | - | ||||||||||||
| 235 | qreal QScreen::logicalDotsPerInchX() const | - | ||||||||||||
| 236 | { | - | ||||||||||||
| 237 | Q_D(const QScreen); | - | ||||||||||||
| 238 | if (QHighDpiScaling::isActive())
| 0 | ||||||||||||
| 239 | return QHighDpiScaling::logicalDpi().first; never executed: return QHighDpiScaling::logicalDpi().first; | 0 | ||||||||||||
| 240 | return d->logicalDpi.first; never executed: return d->logicalDpi.first; | 0 | ||||||||||||
| 241 | } | - | ||||||||||||
| 242 | - | |||||||||||||
| 243 | /*! | - | ||||||||||||
| 244 | \property QScreen::logicalDotsPerInchY | - | ||||||||||||
| 245 | \brief the number of logical dots or pixels per inch in the vertical direction | - | ||||||||||||
| 246 | - | |||||||||||||
| 247 | This value is used to convert font point sizes to pixel sizes. | - | ||||||||||||
| 248 | - | |||||||||||||
| 249 | \sa logicalDotsPerInchX() | - | ||||||||||||
| 250 | */ | - | ||||||||||||
| 251 | qreal QScreen::logicalDotsPerInchY() const | - | ||||||||||||
| 252 | { | - | ||||||||||||
| 253 | Q_D(const QScreen); | - | ||||||||||||
| 254 | if (QHighDpiScaling::isActive())
| 0 | ||||||||||||
| 255 | return QHighDpiScaling::logicalDpi().second; never executed: return QHighDpiScaling::logicalDpi().second; | 0 | ||||||||||||
| 256 | return d->logicalDpi.second; never executed: return d->logicalDpi.second; | 0 | ||||||||||||
| 257 | } | - | ||||||||||||
| 258 | - | |||||||||||||
| 259 | /*! | - | ||||||||||||
| 260 | \property QScreen::logicalDotsPerInch | - | ||||||||||||
| 261 | \brief the number of logical dots or pixels per inch | - | ||||||||||||
| 262 | - | |||||||||||||
| 263 | This value can be used to convert font point sizes to pixel sizes. | - | ||||||||||||
| 264 | - | |||||||||||||
| 265 | This is a convenience property that's simply the average of the logicalDotsPerInchX | - | ||||||||||||
| 266 | and logicalDotsPerInchY properties. | - | ||||||||||||
| 267 | - | |||||||||||||
| 268 | \sa logicalDotsPerInchX() | - | ||||||||||||
| 269 | \sa logicalDotsPerInchY() | - | ||||||||||||
| 270 | */ | - | ||||||||||||
| 271 | qreal QScreen::logicalDotsPerInch() const | - | ||||||||||||
| 272 | { | - | ||||||||||||
| 273 | Q_D(const QScreen); | - | ||||||||||||
| 274 | QDpi dpi = QHighDpiScaling::isActive() ? QHighDpiScaling::logicalDpi() : d->logicalDpi;
| 0 | ||||||||||||
| 275 | return (dpi.first + dpi.second) * qreal(0.5); never executed: return (dpi.first + dpi.second) * qreal(0.5); | 0 | ||||||||||||
| 276 | } | - | ||||||||||||
| 277 | - | |||||||||||||
| 278 | /*! | - | ||||||||||||
| 279 | \property QScreen::devicePixelRatio | - | ||||||||||||
| 280 | \brief the screen's ratio between physical pixels and device-independent pixels | - | ||||||||||||
| 281 | \since 5.5 | - | ||||||||||||
| 282 | - | |||||||||||||
| 283 | Returns the ratio between physical pixels and device-independent pixels for the screen. | - | ||||||||||||
| 284 | - | |||||||||||||
| 285 | Common values are 1.0 on normal displays and 2.0 on "retina" displays. | - | ||||||||||||
| 286 | Higher values are also possible. | - | ||||||||||||
| 287 | - | |||||||||||||
| 288 | \sa QWindow::devicePixelRatio(), QGuiApplication::devicePixelRatio() | - | ||||||||||||
| 289 | */ | - | ||||||||||||
| 290 | qreal QScreen::devicePixelRatio() const | - | ||||||||||||
| 291 | { | - | ||||||||||||
| 292 | Q_D(const QScreen); | - | ||||||||||||
| 293 | return d->platformScreen->devicePixelRatio() * QHighDpiScaling::factor(this); never executed: return d->platformScreen->devicePixelRatio() * QHighDpiScaling::factor(this); | 0 | ||||||||||||
| 294 | } | - | ||||||||||||
| 295 | - | |||||||||||||
| 296 | /*! | - | ||||||||||||
| 297 | \property QScreen::physicalSize | - | ||||||||||||
| 298 | \brief the screen's physical size (in millimeters) | - | ||||||||||||
| 299 | - | |||||||||||||
| 300 | The physical size represents the actual physical dimensions of the | - | ||||||||||||
| 301 | screen's display. | - | ||||||||||||
| 302 | - | |||||||||||||
| 303 | Depending on what information the underlying system provides the value | - | ||||||||||||
| 304 | might not be entirely accurate. | - | ||||||||||||
| 305 | */ | - | ||||||||||||
| 306 | QSizeF QScreen::physicalSize() const | - | ||||||||||||
| 307 | { | - | ||||||||||||
| 308 | Q_D(const QScreen); | - | ||||||||||||
| 309 | return d->platformScreen->physicalSize(); never executed: return d->platformScreen->physicalSize(); | 0 | ||||||||||||
| 310 | } | - | ||||||||||||
| 311 | - | |||||||||||||
| 312 | /*! | - | ||||||||||||
| 313 | \property QScreen::availableSize | - | ||||||||||||
| 314 | \brief the screen's available size in pixels | - | ||||||||||||
| 315 | - | |||||||||||||
| 316 | The available size is the size excluding window manager reserved areas | - | ||||||||||||
| 317 | such as task bars and system menus. | - | ||||||||||||
| 318 | */ | - | ||||||||||||
| 319 | QSize QScreen::availableSize() const | - | ||||||||||||
| 320 | { | - | ||||||||||||
| 321 | Q_D(const QScreen); | - | ||||||||||||
| 322 | return d->availableGeometry.size(); never executed: return d->availableGeometry.size(); | 0 | ||||||||||||
| 323 | } | - | ||||||||||||
| 324 | - | |||||||||||||
| 325 | /*! | - | ||||||||||||
| 326 | \property QScreen::geometry | - | ||||||||||||
| 327 | \brief the screen's geometry in pixels | - | ||||||||||||
| 328 | - | |||||||||||||
| 329 | As an example this might return QRect(0, 0, 1280, 1024), or in a | - | ||||||||||||
| 330 | virtual desktop setting QRect(1280, 0, 1280, 1024). | - | ||||||||||||
| 331 | */ | - | ||||||||||||
| 332 | QRect QScreen::geometry() const | - | ||||||||||||
| 333 | { | - | ||||||||||||
| 334 | Q_D(const QScreen); | - | ||||||||||||
| 335 | return d->geometry; never executed: return d->geometry; | 0 | ||||||||||||
| 336 | } | - | ||||||||||||
| 337 | - | |||||||||||||
| 338 | /*! | - | ||||||||||||
| 339 | \property QScreen::availableGeometry | - | ||||||||||||
| 340 | \brief the screen's available geometry in pixels | - | ||||||||||||
| 341 | - | |||||||||||||
| 342 | The available geometry is the geometry excluding window manager reserved areas | - | ||||||||||||
| 343 | such as task bars and system menus. | - | ||||||||||||
| 344 | */ | - | ||||||||||||
| 345 | QRect QScreen::availableGeometry() const | - | ||||||||||||
| 346 | { | - | ||||||||||||
| 347 | Q_D(const QScreen); | - | ||||||||||||
| 348 | return d->availableGeometry; never executed: return d->availableGeometry; | 0 | ||||||||||||
| 349 | } | - | ||||||||||||
| 350 | - | |||||||||||||
| 351 | /*! | - | ||||||||||||
| 352 | Get the screen's virtual siblings. | - | ||||||||||||
| 353 | - | |||||||||||||
| 354 | The virtual siblings are the screen instances sharing the same virtual desktop. | - | ||||||||||||
| 355 | They share a common coordinate system, and windows can freely be moved or | - | ||||||||||||
| 356 | positioned across them without having to be re-created. | - | ||||||||||||
| 357 | */ | - | ||||||||||||
| 358 | QList<QScreen *> QScreen::virtualSiblings() const | - | ||||||||||||
| 359 | { | - | ||||||||||||
| 360 | Q_D(const QScreen); | - | ||||||||||||
| 361 | QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings(); | - | ||||||||||||
| 362 | QList<QScreen *> screens; | - | ||||||||||||
| 363 | screens.reserve(platformScreens.count()); | - | ||||||||||||
| 364 | foreach (QPlatformScreen *platformScreen, platformScreens) | - | ||||||||||||
| 365 | screens << platformScreen->screen(); never executed: screens << platformScreen->screen(); | 0 | ||||||||||||
| 366 | return screens; never executed: return screens; | 0 | ||||||||||||
| 367 | } | - | ||||||||||||
| 368 | - | |||||||||||||
| 369 | /*! | - | ||||||||||||
| 370 | \property QScreen::virtualSize | - | ||||||||||||
| 371 | \brief the pixel size of the virtual desktop to which this screen belongs | - | ||||||||||||
| 372 | - | |||||||||||||
| 373 | Returns the pixel size of the virtual desktop corresponding to this screen. | - | ||||||||||||
| 374 | - | |||||||||||||
| 375 | This is the combined size of the virtual siblings' individual geometries. | - | ||||||||||||
| 376 | - | |||||||||||||
| 377 | \sa virtualSiblings() | - | ||||||||||||
| 378 | */ | - | ||||||||||||
| 379 | QSize QScreen::virtualSize() const | - | ||||||||||||
| 380 | { | - | ||||||||||||
| 381 | return virtualGeometry().size(); never executed: return virtualGeometry().size(); | 0 | ||||||||||||
| 382 | } | - | ||||||||||||
| 383 | - | |||||||||||||
| 384 | /*! | - | ||||||||||||
| 385 | \property QScreen::virtualGeometry | - | ||||||||||||
| 386 | \brief the pixel geometry of the virtual desktop to which this screen belongs | - | ||||||||||||
| 387 | - | |||||||||||||
| 388 | Returns the pixel geometry of the virtual desktop corresponding to this screen. | - | ||||||||||||
| 389 | - | |||||||||||||
| 390 | This is the union of the virtual siblings' individual geometries. | - | ||||||||||||
| 391 | - | |||||||||||||
| 392 | \sa virtualSiblings() | - | ||||||||||||
| 393 | */ | - | ||||||||||||
| 394 | QRect QScreen::virtualGeometry() const | - | ||||||||||||
| 395 | { | - | ||||||||||||
| 396 | QRect result; | - | ||||||||||||
| 397 | foreach (QScreen *screen, virtualSiblings()) | - | ||||||||||||
| 398 | result |= screen->geometry(); never executed: result |= screen->geometry(); | 0 | ||||||||||||
| 399 | return result; never executed: return result; | 0 | ||||||||||||
| 400 | } | - | ||||||||||||
| 401 | - | |||||||||||||
| 402 | /*! | - | ||||||||||||
| 403 | \property QScreen::availableVirtualSize | - | ||||||||||||
| 404 | \brief the available size of the virtual desktop to which this screen belongs | - | ||||||||||||
| 405 | - | |||||||||||||
| 406 | Returns the available pixel size of the virtual desktop corresponding to this screen. | - | ||||||||||||
| 407 | - | |||||||||||||
| 408 | This is the combined size of the virtual siblings' individual available geometries. | - | ||||||||||||
| 409 | - | |||||||||||||
| 410 | \sa availableSize(), virtualSiblings() | - | ||||||||||||
| 411 | */ | - | ||||||||||||
| 412 | QSize QScreen::availableVirtualSize() const | - | ||||||||||||
| 413 | { | - | ||||||||||||
| 414 | return availableVirtualGeometry().size(); never executed: return availableVirtualGeometry().size(); | 0 | ||||||||||||
| 415 | } | - | ||||||||||||
| 416 | - | |||||||||||||
| 417 | /*! | - | ||||||||||||
| 418 | \property QScreen::availableVirtualGeometry | - | ||||||||||||
| 419 | \brief the available geometry of the virtual desktop to which this screen belongs | - | ||||||||||||
| 420 | - | |||||||||||||
| 421 | Returns the available geometry of the virtual desktop corresponding to this screen. | - | ||||||||||||
| 422 | - | |||||||||||||
| 423 | This is the union of the virtual siblings' individual available geometries. | - | ||||||||||||
| 424 | - | |||||||||||||
| 425 | \sa availableGeometry(), virtualSiblings() | - | ||||||||||||
| 426 | */ | - | ||||||||||||
| 427 | QRect QScreen::availableVirtualGeometry() const | - | ||||||||||||
| 428 | { | - | ||||||||||||
| 429 | QRect result; | - | ||||||||||||
| 430 | foreach (QScreen *screen, virtualSiblings()) | - | ||||||||||||
| 431 | result |= screen->availableGeometry(); never executed: result |= screen->availableGeometry(); | 0 | ||||||||||||
| 432 | return result; never executed: return result; | 0 | ||||||||||||
| 433 | } | - | ||||||||||||
| 434 | - | |||||||||||||
| 435 | /*! | - | ||||||||||||
| 436 | Sets the orientations that the application is interested in receiving | - | ||||||||||||
| 437 | updates for in conjunction with this screen. | - | ||||||||||||
| 438 | - | |||||||||||||
| 439 | For example, to receive orientation() updates and thus have | - | ||||||||||||
| 440 | orientationChanged() signals being emitted for LandscapeOrientation and | - | ||||||||||||
| 441 | InvertedLandscapeOrientation, call setOrientationUpdateMask() with | - | ||||||||||||
| 442 | \a{mask} set to Qt::LandscapeOrientation | Qt::InvertedLandscapeOrientation. | - | ||||||||||||
| 443 | - | |||||||||||||
| 444 | The default, 0, means no orientationChanged() signals are fired. | - | ||||||||||||
| 445 | */ | - | ||||||||||||
| 446 | void QScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) | - | ||||||||||||
| 447 | { | - | ||||||||||||
| 448 | Q_D(QScreen); | - | ||||||||||||
| 449 | d->orientationUpdateMask = mask; | - | ||||||||||||
| 450 | d->platformScreen->setOrientationUpdateMask(mask); | - | ||||||||||||
| 451 | QGuiApplicationPrivate::updateFilteredScreenOrientation(this); | - | ||||||||||||
| 452 | } never executed: end of block | 0 | ||||||||||||
| 453 | - | |||||||||||||
| 454 | /*! | - | ||||||||||||
| 455 | Returns the currently set orientation update mask. | - | ||||||||||||
| 456 | - | |||||||||||||
| 457 | \sa setOrientationUpdateMask() | - | ||||||||||||
| 458 | */ | - | ||||||||||||
| 459 | Qt::ScreenOrientations QScreen::orientationUpdateMask() const | - | ||||||||||||
| 460 | { | - | ||||||||||||
| 461 | Q_D(const QScreen); | - | ||||||||||||
| 462 | return d->orientationUpdateMask; never executed: return d->orientationUpdateMask; | 0 | ||||||||||||
| 463 | } | - | ||||||||||||
| 464 | - | |||||||||||||
| 465 | /*! | - | ||||||||||||
| 466 | \property QScreen::orientation | - | ||||||||||||
| 467 | \brief the screen orientation | - | ||||||||||||
| 468 | - | |||||||||||||
| 469 | The screen orientation represents the physical orientation | - | ||||||||||||
| 470 | of the display. For example, the screen orientation of a mobile device | - | ||||||||||||
| 471 | will change based on how it is being held. A change to the orientation | - | ||||||||||||
| 472 | might or might not trigger a change to the primary orientation of the screen. | - | ||||||||||||
| 473 | - | |||||||||||||
| 474 | Changes to this property will be filtered by orientationUpdateMask(), | - | ||||||||||||
| 475 | so in order to receive orientation updates the application must first | - | ||||||||||||
| 476 | call setOrientationUpdateMask() with a mask of the orientations it wants | - | ||||||||||||
| 477 | to receive. | - | ||||||||||||
| 478 | - | |||||||||||||
| 479 | Qt::PrimaryOrientation is never returned. | - | ||||||||||||
| 480 | - | |||||||||||||
| 481 | \sa primaryOrientation() | - | ||||||||||||
| 482 | */ | - | ||||||||||||
| 483 | Qt::ScreenOrientation QScreen::orientation() const | - | ||||||||||||
| 484 | { | - | ||||||||||||
| 485 | Q_D(const QScreen); | - | ||||||||||||
| 486 | return d->filteredOrientation; never executed: return d->filteredOrientation; | 0 | ||||||||||||
| 487 | } | - | ||||||||||||
| 488 | - | |||||||||||||
| 489 | /*! | - | ||||||||||||
| 490 | \property QScreen::refreshRate | - | ||||||||||||
| 491 | \brief the approximate vertical refresh rate of the screen in Hz | - | ||||||||||||
| 492 | */ | - | ||||||||||||
| 493 | qreal QScreen::refreshRate() const | - | ||||||||||||
| 494 | { | - | ||||||||||||
| 495 | Q_D(const QScreen); | - | ||||||||||||
| 496 | return d->refreshRate; never executed: return d->refreshRate; | 0 | ||||||||||||
| 497 | } | - | ||||||||||||
| 498 | - | |||||||||||||
| 499 | /*! | - | ||||||||||||
| 500 | \property QScreen::primaryOrientation | - | ||||||||||||
| 501 | \brief the primary screen orientation | - | ||||||||||||
| 502 | - | |||||||||||||
| 503 | The primary screen orientation is Qt::LandscapeOrientation | - | ||||||||||||
| 504 | if the screen geometry's width is greater than or equal to its | - | ||||||||||||
| 505 | height, or Qt::PortraitOrientation otherwise. This property might | - | ||||||||||||
| 506 | change when the screen orientation was changed (i.e. when the | - | ||||||||||||
| 507 | display is rotated). | - | ||||||||||||
| 508 | The behavior is however platform dependent and can often be specified in | - | ||||||||||||
| 509 | an application manifest file. | - | ||||||||||||
| 510 | - | |||||||||||||
| 511 | */ | - | ||||||||||||
| 512 | Qt::ScreenOrientation QScreen::primaryOrientation() const | - | ||||||||||||
| 513 | { | - | ||||||||||||
| 514 | Q_D(const QScreen); | - | ||||||||||||
| 515 | return d->primaryOrientation; never executed: return d->primaryOrientation; | 0 | ||||||||||||
| 516 | } | - | ||||||||||||
| 517 | - | |||||||||||||
| 518 | /*! | - | ||||||||||||
| 519 | \property QScreen::nativeOrientation | - | ||||||||||||
| 520 | \brief the native screen orientation | - | ||||||||||||
| 521 | \since 5.2 | - | ||||||||||||
| 522 | - | |||||||||||||
| 523 | The native orientation of the screen is the orientation where the logo | - | ||||||||||||
| 524 | sticker of the device appears the right way up, or Qt::PrimaryOrientation | - | ||||||||||||
| 525 | if the platform does not support this functionality. | - | ||||||||||||
| 526 | - | |||||||||||||
| 527 | The native orientation is a property of the hardware, and does not change. | - | ||||||||||||
| 528 | */ | - | ||||||||||||
| 529 | Qt::ScreenOrientation QScreen::nativeOrientation() const | - | ||||||||||||
| 530 | { | - | ||||||||||||
| 531 | Q_D(const QScreen); | - | ||||||||||||
| 532 | return d->platformScreen->nativeOrientation(); never executed: return d->platformScreen->nativeOrientation(); | 0 | ||||||||||||
| 533 | } | - | ||||||||||||
| 534 | - | |||||||||||||
| 535 | /*! | - | ||||||||||||
| 536 | Convenience function to compute the angle of rotation to get from | - | ||||||||||||
| 537 | rotation \a a to rotation \a b. | - | ||||||||||||
| 538 | - | |||||||||||||
| 539 | The result will be 0, 90, 180, or 270. | - | ||||||||||||
| 540 | - | |||||||||||||
| 541 | Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). | - | ||||||||||||
| 542 | */ | - | ||||||||||||
| 543 | int QScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) const | - | ||||||||||||
| 544 | { | - | ||||||||||||
| 545 | if (a == Qt::PrimaryOrientation)
| 0 | ||||||||||||
| 546 | a = primaryOrientation(); never executed: a = primaryOrientation(); | 0 | ||||||||||||
| 547 | - | |||||||||||||
| 548 | if (b == Qt::PrimaryOrientation)
| 0 | ||||||||||||
| 549 | b = primaryOrientation(); never executed: b = primaryOrientation(); | 0 | ||||||||||||
| 550 | - | |||||||||||||
| 551 | return QPlatformScreen::angleBetween(a, b); never executed: return QPlatformScreen::angleBetween(a, b); | 0 | ||||||||||||
| 552 | } | - | ||||||||||||
| 553 | - | |||||||||||||
| 554 | /*! | - | ||||||||||||
| 555 | Convenience function to compute a transform that maps from the coordinate system | - | ||||||||||||
| 556 | defined by orientation \a a into the coordinate system defined by orientation | - | ||||||||||||
| 557 | \a b and target dimensions \a target. | - | ||||||||||||
| 558 | - | |||||||||||||
| 559 | Example, \a a is Qt::Landscape, \a b is Qt::Portrait, and \a target is QRect(0, 0, w, h) | - | ||||||||||||
| 560 | the resulting transform will be such that the point QPoint(0, 0) is mapped to QPoint(0, w), | - | ||||||||||||
| 561 | and QPoint(h, w) is mapped to QPoint(0, h). Thus, the landscape coordinate system QRect(0, 0, h, w) | - | ||||||||||||
| 562 | is mapped (with a 90 degree rotation) into the portrait coordinate system QRect(0, 0, w, h). | - | ||||||||||||
| 563 | - | |||||||||||||
| 564 | Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). | - | ||||||||||||
| 565 | */ | - | ||||||||||||
| 566 | QTransform QScreen::transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target) const | - | ||||||||||||
| 567 | { | - | ||||||||||||
| 568 | if (a == Qt::PrimaryOrientation)
| 0 | ||||||||||||
| 569 | a = primaryOrientation(); never executed: a = primaryOrientation(); | 0 | ||||||||||||
| 570 | - | |||||||||||||
| 571 | if (b == Qt::PrimaryOrientation)
| 0 | ||||||||||||
| 572 | b = primaryOrientation(); never executed: b = primaryOrientation(); | 0 | ||||||||||||
| 573 | - | |||||||||||||
| 574 | return QPlatformScreen::transformBetween(a, b, target); never executed: return QPlatformScreen::transformBetween(a, b, target); | 0 | ||||||||||||
| 575 | } | - | ||||||||||||
| 576 | - | |||||||||||||
| 577 | /*! | - | ||||||||||||
| 578 | Maps the rect between two screen orientations. | - | ||||||||||||
| 579 | - | |||||||||||||
| 580 | This will flip the x and y dimensions of the rectangle \a{rect} if the orientation \a{a} is | - | ||||||||||||
| 581 | Qt::PortraitOrientation or Qt::InvertedPortraitOrientation and orientation \a{b} is | - | ||||||||||||
| 582 | Qt::LandscapeOrientation or Qt::InvertedLandscapeOrientation, or vice versa. | - | ||||||||||||
| 583 | - | |||||||||||||
| 584 | Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). | - | ||||||||||||
| 585 | */ | - | ||||||||||||
| 586 | QRect QScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect) const | - | ||||||||||||
| 587 | { | - | ||||||||||||
| 588 | if (a == Qt::PrimaryOrientation)
| 0 | ||||||||||||
| 589 | a = primaryOrientation(); never executed: a = primaryOrientation(); | 0 | ||||||||||||
| 590 | - | |||||||||||||
| 591 | if (b == Qt::PrimaryOrientation)
| 0 | ||||||||||||
| 592 | b = primaryOrientation(); never executed: b = primaryOrientation(); | 0 | ||||||||||||
| 593 | - | |||||||||||||
| 594 | return QPlatformScreen::mapBetween(a, b, rect); never executed: return QPlatformScreen::mapBetween(a, b, rect); | 0 | ||||||||||||
| 595 | } | - | ||||||||||||
| 596 | - | |||||||||||||
| 597 | /*! | - | ||||||||||||
| 598 | Convenience function that returns \c true if \a o is either portrait or inverted portrait; | - | ||||||||||||
| 599 | otherwise returns \c false. | - | ||||||||||||
| 600 | - | |||||||||||||
| 601 | Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). | - | ||||||||||||
| 602 | */ | - | ||||||||||||
| 603 | bool QScreen::isPortrait(Qt::ScreenOrientation o) const | - | ||||||||||||
| 604 | { | - | ||||||||||||
| 605 | return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation never executed: return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
| 0 | ||||||||||||
| 606 | || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation); never executed: return o == Qt::PortraitOrientation || o == Qt::InvertedPortraitOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::PortraitOrientation);
| 0 | ||||||||||||
| 607 | } | - | ||||||||||||
| 608 | - | |||||||||||||
| 609 | /*! | - | ||||||||||||
| 610 | Convenience function that returns \c true if \a o is either landscape or inverted landscape; | - | ||||||||||||
| 611 | otherwise returns \c false. | - | ||||||||||||
| 612 | - | |||||||||||||
| 613 | Qt::PrimaryOrientation is interpreted as the screen's primaryOrientation(). | - | ||||||||||||
| 614 | */ | - | ||||||||||||
| 615 | bool QScreen::isLandscape(Qt::ScreenOrientation o) const | - | ||||||||||||
| 616 | { | - | ||||||||||||
| 617 | return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation never executed: return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
| 0 | ||||||||||||
| 618 | || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation); never executed: return o == Qt::LandscapeOrientation || o == Qt::InvertedLandscapeOrientation || (o == Qt::PrimaryOrientation && primaryOrientation() == Qt::LandscapeOrientation);
| 0 | ||||||||||||
| 619 | } | - | ||||||||||||
| 620 | - | |||||||||||||
| 621 | /*! | - | ||||||||||||
| 622 | \fn void QScreen::orientationChanged(Qt::ScreenOrientation orientation) | - | ||||||||||||
| 623 | - | |||||||||||||
| 624 | This signal is emitted when the orientation of the screen | - | ||||||||||||
| 625 | changes with \a orientation as an argument. | - | ||||||||||||
| 626 | - | |||||||||||||
| 627 | \sa orientation() | - | ||||||||||||
| 628 | */ | - | ||||||||||||
| 629 | - | |||||||||||||
| 630 | /*! | - | ||||||||||||
| 631 | \fn void QScreen::primaryOrientationChanged(Qt::ScreenOrientation orientation) | - | ||||||||||||
| 632 | - | |||||||||||||
| 633 | This signal is emitted when the primary orientation of the screen | - | ||||||||||||
| 634 | changes with \a orientation as an argument. | - | ||||||||||||
| 635 | - | |||||||||||||
| 636 | \sa primaryOrientation() | - | ||||||||||||
| 637 | */ | - | ||||||||||||
| 638 | - | |||||||||||||
| 639 | void QScreenPrivate::updatePrimaryOrientation() | - | ||||||||||||
| 640 | { | - | ||||||||||||
| 641 | primaryOrientation = geometry.width() >= geometry.height() ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
| 0 | ||||||||||||
| 642 | } never executed: end of block | 0 | ||||||||||||
| 643 | - | |||||||||||||
| 644 | /*! | - | ||||||||||||
| 645 | Creates and returns a pixmap constructed by grabbing the contents | - | ||||||||||||
| 646 | of the given \a window restricted by QRect(\a x, \a y, \a width, | - | ||||||||||||
| 647 | \a height). | - | ||||||||||||
| 648 | - | |||||||||||||
| 649 | The arguments (\a{x}, \a{y}) specify the offset in the window, | - | ||||||||||||
| 650 | whereas (\a{width}, \a{height}) specify the area to be copied. If | - | ||||||||||||
| 651 | \a width is negative, the function copies everything to the right | - | ||||||||||||
| 652 | border of the window. If \a height is negative, the function | - | ||||||||||||
| 653 | copies everything to the bottom of the window. | - | ||||||||||||
| 654 | - | |||||||||||||
| 655 | The window system identifier (\c WId) can be retrieved using the | - | ||||||||||||
| 656 | QWidget::winId() function. The rationale for using a window | - | ||||||||||||
| 657 | identifier and not a QWidget, is to enable grabbing of windows | - | ||||||||||||
| 658 | that are not part of the application, window system frames, and so | - | ||||||||||||
| 659 | on. | - | ||||||||||||
| 660 | - | |||||||||||||
| 661 | The grabWindow() function grabs pixels from the screen, not from | - | ||||||||||||
| 662 | the window, i.e. if there is another window partially or entirely | - | ||||||||||||
| 663 | over the one you grab, you get pixels from the overlying window, | - | ||||||||||||
| 664 | too. The mouse cursor is generally not grabbed. | - | ||||||||||||
| 665 | - | |||||||||||||
| 666 | Note on X11 that if the given \a window doesn't have the same depth | - | ||||||||||||
| 667 | as the root window, and another window partially or entirely | - | ||||||||||||
| 668 | obscures the one you grab, you will \e not get pixels from the | - | ||||||||||||
| 669 | overlying window. The contents of the obscured areas in the | - | ||||||||||||
| 670 | pixmap will be undefined and uninitialized. | - | ||||||||||||
| 671 | - | |||||||||||||
| 672 | On Windows Vista and above grabbing a layered window, which is | - | ||||||||||||
| 673 | created by setting the Qt::WA_TranslucentBackground attribute, will | - | ||||||||||||
| 674 | not work. Instead grabbing the desktop widget should work. | - | ||||||||||||
| 675 | - | |||||||||||||
| 676 | \warning In general, grabbing an area outside the screen is not | - | ||||||||||||
| 677 | safe. This depends on the underlying window system. | - | ||||||||||||
| 678 | */ | - | ||||||||||||
| 679 | - | |||||||||||||
| 680 | QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height) | - | ||||||||||||
| 681 | { | - | ||||||||||||
| 682 | const QPlatformScreen *platformScreen = handle(); | - | ||||||||||||
| 683 | if (!platformScreen) {
| 0 | ||||||||||||
| 684 | qWarning("invoked with handle==0"); | - | ||||||||||||
| 685 | return QPixmap(); never executed: return QPixmap(); | 0 | ||||||||||||
| 686 | } | - | ||||||||||||
| 687 | const qreal factor = QHighDpiScaling::factor(this); | - | ||||||||||||
| 688 | if (qFuzzyCompare(factor, 1))
| 0 | ||||||||||||
| 689 | return platformScreen->grabWindow(window, x, y, width, height); never executed: return platformScreen->grabWindow(window, x, y, width, height); | 0 | ||||||||||||
| 690 | - | |||||||||||||
| 691 | const QPoint nativePos = QHighDpi::toNative(QPoint(x, y), factor); | - | ||||||||||||
| 692 | QSize nativeSize(width, height); | - | ||||||||||||
| 693 | if (nativeSize.isValid())
| 0 | ||||||||||||
| 694 | nativeSize = QHighDpi::toNative(nativeSize, factor); never executed: nativeSize = QHighDpi::toNative(nativeSize, factor); | 0 | ||||||||||||
| 695 | QPixmap result = | - | ||||||||||||
| 696 | platformScreen->grabWindow(window, nativePos.x(), nativePos.y(), | - | ||||||||||||
| 697 | nativeSize.width(), nativeSize.height()); | - | ||||||||||||
| 698 | result.setDevicePixelRatio(factor); | - | ||||||||||||
| 699 | return result; never executed: return result; | 0 | ||||||||||||
| 700 | } | - | ||||||||||||
| 701 | - | |||||||||||||
| 702 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||
| 703 | - | |||||||||||||
| 704 | static inline void formatRect(QDebug &debug, const QRect r) | - | ||||||||||||
| 705 | { | - | ||||||||||||
| 706 | debug << r.width() << 'x' << r.height() | - | ||||||||||||
| 707 | << forcesign << r.x() << r.y() << noforcesign; | - | ||||||||||||
| 708 | } never executed: end of block | 0 | ||||||||||||
| 709 | - | |||||||||||||
| 710 | Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QScreen *screen) | - | ||||||||||||
| 711 | { | - | ||||||||||||
| 712 | const QDebugStateSaver saver(debug); | - | ||||||||||||
| 713 | debug.nospace(); | - | ||||||||||||
| 714 | debug << "QScreen(" << (const void *)screen; | - | ||||||||||||
| 715 | if (screen) {
| 0 | ||||||||||||
| 716 | debug << ", name=" << screen->name(); | - | ||||||||||||
| 717 | if (debug.verbosity() > 2) {
| 0 | ||||||||||||
| 718 | if (screen == QGuiApplication::primaryScreen())
| 0 | ||||||||||||
| 719 | debug << ", primary"; never executed: debug << ", primary"; | 0 | ||||||||||||
| 720 | debug << ", geometry="; | - | ||||||||||||
| 721 | formatRect(debug, screen->geometry()); | - | ||||||||||||
| 722 | debug << ", available="; | - | ||||||||||||
| 723 | formatRect(debug, screen->availableGeometry()); | - | ||||||||||||
| 724 | debug << ", logical DPI=" << screen->logicalDotsPerInchX() | - | ||||||||||||
| 725 | << ',' << screen->logicalDotsPerInchY() | - | ||||||||||||
| 726 | << ", physical DPI=" << screen->physicalDotsPerInchX() | - | ||||||||||||
| 727 | << ',' << screen->physicalDotsPerInchY() | - | ||||||||||||
| 728 | << ", devicePixelRatio=" << screen->devicePixelRatio() | - | ||||||||||||
| 729 | << ", orientation=" << screen->orientation() | - | ||||||||||||
| 730 | << ", physical size=" << screen->physicalSize().width() | - | ||||||||||||
| 731 | << 'x' << screen->physicalSize().height() << "mm"; | - | ||||||||||||
| 732 | } never executed: end of block | 0 | ||||||||||||
| 733 | } never executed: end of block | 0 | ||||||||||||
| 734 | debug << ')'; | - | ||||||||||||
| 735 | return debug; never executed: return debug; | 0 | ||||||||||||
| 736 | } | - | ||||||||||||
| 737 | #endif // !QT_NO_DEBUG_STREAM | - | ||||||||||||
| 738 | - | |||||||||||||
| 739 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |