| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 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 Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/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 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qplatformscreen.h" | - |
| 43 | #include <QtGui/qguiapplication.h> | - |
| 44 | #include <qpa/qplatformcursor.h> | - |
| 45 | #include <QtGui/private/qguiapplication_p.h> | - |
| 46 | #include <qpa/qplatformscreen_p.h> | - |
| 47 | #include <qpa/qplatformintegration.h> | - |
| 48 | #include <QtGui/qscreen.h> | - |
| 49 | #include <QtGui/qwindow.h> | - |
| 50 | | - |
| 51 | QT_BEGIN_NAMESPACE | - |
| 52 | | - |
| 53 | QPlatformScreen::QPlatformScreen() | - |
| 54 | : d_ptr(new QPlatformScreenPrivate) | - |
| 55 | { | - |
| 56 | Q_D(QPlatformScreen); executed (the execution status of this line is deduced): QPlatformScreenPrivate * const d = d_func(); | - |
| 57 | d->screen = 0; executed (the execution status of this line is deduced): d->screen = 0; | - |
| 58 | } executed: }Execution Count:289 | 289 |
| 59 | | - |
| 60 | QPlatformScreen::~QPlatformScreen() | - |
| 61 | { | - |
| 62 | Q_D(QPlatformScreen); executed (the execution status of this line is deduced): QPlatformScreenPrivate * const d = d_func(); | - |
| 63 | | - |
| 64 | QGuiApplicationPrivate::screen_list.removeOne(d->screen); executed (the execution status of this line is deduced): QGuiApplicationPrivate::screen_list.removeOne(d->screen); | - |
| 65 | delete d->screen; executed (the execution status of this line is deduced): delete d->screen; | - |
| 66 | } executed: }Execution Count:287 | 287 |
| 67 | | - |
| 68 | /*! | - |
| 69 | \fn QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int height) const | - |
| 70 | | - |
| 71 | This function is called when Qt needs to be able to grab the content of a window. | - |
| 72 | | - |
| 73 | Returnes the content of the window specified with the WId handle within the boundaries of | - |
| 74 | QRect(x,y,width,height). | - |
| 75 | */ | - |
| 76 | QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int height) const | - |
| 77 | { | - |
| 78 | Q_UNUSED(window); never executed (the execution status of this line is deduced): (void)window;; | - |
| 79 | Q_UNUSED(x); never executed (the execution status of this line is deduced): (void)x;; | - |
| 80 | Q_UNUSED(y); never executed (the execution status of this line is deduced): (void)y;; | - |
| 81 | Q_UNUSED(width); never executed (the execution status of this line is deduced): (void)width;; | - |
| 82 | Q_UNUSED(height); never executed (the execution status of this line is deduced): (void)height;; | - |
| 83 | return QPixmap(); never executed: return QPixmap(); | 0 |
| 84 | } | - |
| 85 | | - |
| 86 | /*! | - |
| 87 | Return the given top level window for a given position. | - |
| 88 | | - |
| 89 | Default implementation retrieves a list of all top level windows and finds the first window | - |
| 90 | which contains point \a pos | - |
| 91 | */ | - |
| 92 | QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const | - |
| 93 | { | - |
| 94 | QWindowList list = QGuiApplication::topLevelWindows(); never executed (the execution status of this line is deduced): QWindowList list = QGuiApplication::topLevelWindows(); | - |
| 95 | for (int i = list.size()-1; i >= 0; --i) { | 0 |
| 96 | QWindow *w = list[i]; never executed (the execution status of this line is deduced): QWindow *w = list[i]; | - |
| 97 | if (w->isVisible() && w->geometry().contains(pos)) never evaluated: w->isVisible() never evaluated: w->geometry().contains(pos) | 0 |
| 98 | return w; never executed: return w; | 0 |
| 99 | } | 0 |
| 100 | | - |
| 101 | return 0; never executed: return 0; | 0 |
| 102 | } | - |
| 103 | | - |
| 104 | /*! | - |
| 105 | Returns a list of all the platform screens that are part of the same | - |
| 106 | virtual desktop. | - |
| 107 | | - |
| 108 | Screens part of the same virtual desktop share a common coordinate system, | - |
| 109 | and windows can be freely moved between them. | - |
| 110 | */ | - |
| 111 | QList<QPlatformScreen *> QPlatformScreen::virtualSiblings() const | - |
| 112 | { | - |
| 113 | QList<QPlatformScreen *> list; never executed (the execution status of this line is deduced): QList<QPlatformScreen *> list; | - |
| 114 | list << const_cast<QPlatformScreen *>(this); never executed (the execution status of this line is deduced): list << const_cast<QPlatformScreen *>(this); | - |
| 115 | return list; never executed: return list; | 0 |
| 116 | } | - |
| 117 | | - |
| 118 | QScreen *QPlatformScreen::screen() const | - |
| 119 | { | - |
| 120 | Q_D(const QPlatformScreen); executed (the execution status of this line is deduced): const QPlatformScreenPrivate * const d = d_func(); | - |
| 121 | return d->screen; executed: return d->screen;Execution Count:171730 | 171730 |
| 122 | } | - |
| 123 | | - |
| 124 | /*! | - |
| 125 | Reimplement this function in subclass to return the physical size of the | - |
| 126 | screen, in millimeters. The physical size represents the actual physical | - |
| 127 | dimensions of the display. | - |
| 128 | | - |
| 129 | The default implementation takes the pixel size of the screen, considers a | - |
| 130 | resolution of 100 dots per inch, and returns the calculated physical size. | - |
| 131 | A device with a screen that has different resolutions will need to be | - |
| 132 | supported by a suitable reimplementation of this function. | - |
| 133 | | - |
| 134 | \sa logcalDpi | - |
| 135 | */ | - |
| 136 | QSizeF QPlatformScreen::physicalSize() const | - |
| 137 | { | - |
| 138 | static const int dpi = 100; | - |
| 139 | return QSizeF(geometry().size()) / dpi * qreal(25.4); never executed: return QSizeF(geometry().size()) / dpi * qreal(25.4); | 0 |
| 140 | } | - |
| 141 | | - |
| 142 | /*! | - |
| 143 | Reimplement this function in subclass to return the logical horizontal | - |
| 144 | and vertical dots per inch metrics of the screen. | - |
| 145 | | - |
| 146 | The logical dots per inch metrics are used by QFont to convert point sizes | - |
| 147 | to pixel sizes. | - |
| 148 | | - |
| 149 | The default implementation uses the screen pixel size and physical size to | - |
| 150 | compute the metrics. | - |
| 151 | | - |
| 152 | \sa physicalSize | - |
| 153 | */ | - |
| 154 | QDpi QPlatformScreen::logicalDpi() const | - |
| 155 | { | - |
| 156 | QSizeF ps = physicalSize(); never executed (the execution status of this line is deduced): QSizeF ps = physicalSize(); | - |
| 157 | QSize s = geometry().size(); never executed (the execution status of this line is deduced): QSize s = geometry().size(); | - |
| 158 | | - |
| 159 | return QDpi(25.4 * s.width() / ps.width(), never executed: return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height()); | 0 |
| 160 | 25.4 * s.height() / ps.height()); never executed: return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height()); | 0 |
| 161 | } | - |
| 162 | | - |
| 163 | /*! | - |
| 164 | Reimplement this function in subclass to return the device pixel | - |
| 165 | ratio for the screen. This is the ratio between physical pixels | - |
| 166 | and device-independent pixels. | - |
| 167 | | - |
| 168 | \sa QPlatformWindow::devicePixelRatio(); | - |
| 169 | */ | - |
| 170 | qreal QPlatformScreen::devicePixelRatio() const | - |
| 171 | { | - |
| 172 | return 1.0; executed: return 1.0;Execution Count:2 | 2 |
| 173 | } | - |
| 174 | | - |
| 175 | /*! | - |
| 176 | Reimplement this function in subclass to return the vertical refresh rate | - |
| 177 | of the screen, in Hz. | - |
| 178 | | - |
| 179 | The default returns 60, a sensible default for modern displays. | - |
| 180 | */ | - |
| 181 | qreal QPlatformScreen::refreshRate() const | - |
| 182 | { | - |
| 183 | return 60; never executed: return 60; | 0 |
| 184 | } | - |
| 185 | | - |
| 186 | /*! | - |
| 187 | Reimplement this function in subclass to return the native orientation | - |
| 188 | of the screen, e.g. the orientation where the logo sticker of the device | - |
| 189 | appears the right way up. | - |
| 190 | | - |
| 191 | The default implementation returns Qt::PrimaryOrientation. | - |
| 192 | */ | - |
| 193 | Qt::ScreenOrientation QPlatformScreen::nativeOrientation() const | - |
| 194 | { | - |
| 195 | return Qt::PrimaryOrientation; never executed: return Qt::PrimaryOrientation; | 0 |
| 196 | } | - |
| 197 | | - |
| 198 | /*! | - |
| 199 | Reimplement this function in subclass to return the current orientation | - |
| 200 | of the screen, for example based on accelerometer data to determine | - |
| 201 | the device orientation. | - |
| 202 | | - |
| 203 | The default implementation returns Qt::PrimaryOrientation. | - |
| 204 | */ | - |
| 205 | Qt::ScreenOrientation QPlatformScreen::orientation() const | - |
| 206 | { | - |
| 207 | return Qt::PrimaryOrientation; never executed: return Qt::PrimaryOrientation; | 0 |
| 208 | } | - |
| 209 | | - |
| 210 | /* | - |
| 211 | Reimplement this function in subclass to filter out unneeded screen | - |
| 212 | orientation updates. | - |
| 213 | | - |
| 214 | The orientations will anyway be filtered before QScreen::orientationChanged() | - |
| 215 | is emitted, but the mask can be used by the platform plugin for example to | - |
| 216 | prevent having to have an accelerometer sensor running all the time, or to | - |
| 217 | improve the reported values. As an example of the latter, in case of only | - |
| 218 | Landscape | InvertedLandscape being set in the mask, on a platform that gets | - |
| 219 | its orientation readings from an accelerometer sensor embedded in a handheld | - |
| 220 | device, the platform can report transitions between the two even when the | - |
| 221 | device is held in an orientation that's closer to portrait. | - |
| 222 | | - |
| 223 | By default, the orientation update mask is empty, so unless this function | - |
| 224 | has been called with a non-empty mask the platform does not need to report | - |
| 225 | any orientation updates through | - |
| 226 | QWindowSystemInterface::handleScreenOrientationChange(). | - |
| 227 | */ | - |
| 228 | void QPlatformScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) | - |
| 229 | { | - |
| 230 | Q_UNUSED(mask); executed (the execution status of this line is deduced): (void)mask;; | - |
| 231 | } executed: }Execution Count:3 | 3 |
| 232 | | - |
| 233 | QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window) | - |
| 234 | { | - |
| 235 | return window->screen()->handle(); executed: return window->screen()->handle();Execution Count:171342 | 171342 |
| 236 | } | - |
| 237 | | - |
| 238 | /*! | - |
| 239 | \class QPlatformScreen | - |
| 240 | \since 4.8 | - |
| 241 | \internal | - |
| 242 | \preliminary | - |
| 243 | \ingroup qpa | - |
| 244 | | - |
| 245 | \brief The QPlatformScreen class provides an abstraction for visual displays. | - |
| 246 | | - |
| 247 | Many window systems has support for retrieving information on the attached displays. To be able | - |
| 248 | to query the display QPA uses QPlatformScreen. Qt its self is most dependent on the | - |
| 249 | physicalSize() function, since this is the function it uses to calculate the dpi to use when | - |
| 250 | converting point sizes to pixels sizes. However, this is unfortunate on some systems, as the | - |
| 251 | native system fakes its dpi size. | - |
| 252 | | - |
| 253 | QPlatformScreen is also used by the public api QDesktopWidget for information about the desktop. | - |
| 254 | */ | - |
| 255 | | - |
| 256 | /*! \fn QRect QPlatformScreen::geometry() const = 0 | - |
| 257 | Reimplement in subclass to return the pixel geometry of the screen | - |
| 258 | */ | - |
| 259 | | - |
| 260 | /*! \fn QRect QPlatformScreen::availableGeometry() const | - |
| 261 | Reimplement in subclass to return the pixel geometry of the available space | - |
| 262 | This normally is the desktop screen minus the task manager, global menubar etc. | - |
| 263 | */ | - |
| 264 | | - |
| 265 | /*! \fn int QPlatformScreen::depth() const = 0 | - |
| 266 | Reimplement in subclass to return current depth of the screen | - |
| 267 | */ | - |
| 268 | | - |
| 269 | /*! \fn QImage::Format QPlatformScreen::format() const = 0 | - |
| 270 | Reimplement in subclass to return the image format which corresponds to the screen format | - |
| 271 | */ | - |
| 272 | | - |
| 273 | /*! | - |
| 274 | Implemented in subclasses to return a page flipper object for the screen, or 0 if the | - |
| 275 | hardware does not support page flipping. The default implementation returns 0. | - |
| 276 | */ | - |
| 277 | QPlatformScreenPageFlipper *QPlatformScreen::pageFlipper() const | - |
| 278 | { | - |
| 279 | return 0; never executed: return 0; | 0 |
| 280 | } | - |
| 281 | | - |
| 282 | /*! | - |
| 283 | Reimplement this function in subclass to return the cursor of the screen. | - |
| 284 | | - |
| 285 | The default implementation returns 0. | - |
| 286 | */ | - |
| 287 | QPlatformCursor *QPlatformScreen::cursor() const | - |
| 288 | { | - |
| 289 | return 0; never executed: return 0; | 0 |
| 290 | } | - |
| 291 | | - |
| 292 | /*! | - |
| 293 | Convenience method to resize all the maximized and fullscreen windows | - |
| 294 | of this platform screen. | - |
| 295 | */ | - |
| 296 | void QPlatformScreen::resizeMaximizedWindows() | - |
| 297 | { | - |
| 298 | QList<QWindow*> windows = QGuiApplication::allWindows(); never executed (the execution status of this line is deduced): QList<QWindow*> windows = QGuiApplication::allWindows(); | - |
| 299 | | - |
| 300 | // 'screen()' still has the old geometry info while 'this' has the new geometry info | - |
| 301 | const QRect oldGeometry = screen()->geometry(); never executed (the execution status of this line is deduced): const QRect oldGeometry = screen()->geometry(); | - |
| 302 | const QRect oldAvailableGeometry = screen()->availableGeometry(); never executed (the execution status of this line is deduced): const QRect oldAvailableGeometry = screen()->availableGeometry(); | - |
| 303 | const QRect newGeometry = geometry(); never executed (the execution status of this line is deduced): const QRect newGeometry = geometry(); | - |
| 304 | const QRect newAvailableGeometry = availableGeometry(); never executed (the execution status of this line is deduced): const QRect newAvailableGeometry = availableGeometry(); | - |
| 305 | | - |
| 306 | // make sure maximized and fullscreen windows are updated | - |
| 307 | for (int i = 0; i < windows.size(); ++i) { never evaluated: i < windows.size() | 0 |
| 308 | QWindow *w = windows.at(i); never executed (the execution status of this line is deduced): QWindow *w = windows.at(i); | - |
| 309 | | - |
| 310 | if (platformScreenForWindow(w) != this) never evaluated: platformScreenForWindow(w) != this | 0 |
| 311 | continue; never executed: continue; | 0 |
| 312 | | - |
| 313 | if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) never evaluated: w->windowState() & Qt::WindowFullScreen never evaluated: w->geometry() == oldGeometry | 0 |
| 314 | w->setGeometry(newGeometry); never executed: w->setGeometry(newGeometry); | 0 |
| 315 | else if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) never evaluated: w->windowState() & Qt::WindowMaximized never evaluated: w->geometry() == oldAvailableGeometry | 0 |
| 316 | w->setGeometry(newAvailableGeometry); never executed: w->setGeometry(newAvailableGeometry); | 0 |
| 317 | } | - |
| 318 | } | 0 |
| 319 | | - |
| 320 | QT_END_NAMESPACE | - |
| 321 | | - |
| | |