| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qplatformscreen.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | QPlatformScreen::QPlatformScreen() | - | ||||||||||||
| 5 | : d_ptr(new QPlatformScreenPrivate) | - | ||||||||||||
| 6 | { | - | ||||||||||||
| 7 | QPlatformScreenPrivate * const d = d_func(); | - | ||||||||||||
| 8 | d->screen = 0; | - | ||||||||||||
| 9 | } | - | ||||||||||||
| 10 | - | |||||||||||||
| 11 | QPlatformScreen::~QPlatformScreen() | - | ||||||||||||
| 12 | { | - | ||||||||||||
| 13 | QPlatformScreenPrivate * const d = d_func(); | - | ||||||||||||
| 14 | if (d->screen) { | - | ||||||||||||
| 15 | QMessageLogger(__FILE__, 5864, __PRETTY_FUNCTION__).warning("Manually deleting a QPlatformScreen. Call QPlatformIntegration::destroyScreen instead."); | - | ||||||||||||
| 16 | QGuiApplicationPrivate::platformIntegration()->removeScreen(d->screen); | - | ||||||||||||
| 17 | delete d->screen; | - | ||||||||||||
| 18 | } | - | ||||||||||||
| 19 | } | - | ||||||||||||
| 20 | QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int height) const | - | ||||||||||||
| 21 | { | - | ||||||||||||
| 22 | (void)window;; | - | ||||||||||||
| 23 | (void)x;; | - | ||||||||||||
| 24 | (void)y;; | - | ||||||||||||
| 25 | (void)width;; | - | ||||||||||||
| 26 | (void)height;; | - | ||||||||||||
| 27 | return QPixmap(); | - | ||||||||||||
| 28 | } | - | ||||||||||||
| 29 | - | |||||||||||||
| 30 | - | |||||||||||||
| 31 | - | |||||||||||||
| 32 | - | |||||||||||||
| 33 | - | |||||||||||||
| 34 | - | |||||||||||||
| 35 | - | |||||||||||||
| 36 | QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const | - | ||||||||||||
| 37 | { | - | ||||||||||||
| 38 | const QWindowList list = QGuiApplication::topLevelWindows(); | - | ||||||||||||
| 39 | for (int i = list.size()-1; i >= 0
| 0 | ||||||||||||
| 40 | QWindow *w = list[i]; | - | ||||||||||||
| 41 | if (w->isVisible()
| 0 | ||||||||||||
| 42 | return never executed: w;return w;never executed: return w; | 0 | ||||||||||||
| 43 | } never executed: end of block | 0 | ||||||||||||
| 44 | - | |||||||||||||
| 45 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 46 | } | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | - | |||||||||||||
| 49 | - | |||||||||||||
| 50 | - | |||||||||||||
| 51 | - | |||||||||||||
| 52 | - | |||||||||||||
| 53 | const QPlatformScreen *QPlatformScreen::screenForPosition(const QPoint &point) const | - | ||||||||||||
| 54 | { | - | ||||||||||||
| 55 | if (!geometry().contains(point)
| 0 | ||||||||||||
| 56 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(virtualSiblings())>::type> _container_((virtualSiblings())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^const auto screens = 1)virtualSiblings(); | - | ||||||||||||
| 57 | for (const QPlatformScreen *screen = *_container_.i; _container_.control; _container_.control = 0: screens) { | - | ||||||||||||
| 58 | if (screen->geometry().contains(point)
| 0 | ||||||||||||
| 59 | return never executed: screen;return screen;never executed: return screen; | 0 | ||||||||||||
| 60 | } never executed: end of block | 0 | ||||||||||||
| 61 | } never executed: end of block | 0 | ||||||||||||
| 62 | return never executed: this;return this;never executed: return this; | 0 | ||||||||||||
| 63 | } | - | ||||||||||||
| 64 | QList<QPlatformScreen *> QPlatformScreen::virtualSiblings() const | - | ||||||||||||
| 65 | { | - | ||||||||||||
| 66 | QList<QPlatformScreen *> list; | - | ||||||||||||
| 67 | list << const_cast<QPlatformScreen *>(this); | - | ||||||||||||
| 68 | return list; | - | ||||||||||||
| 69 | } | - | ||||||||||||
| 70 | - | |||||||||||||
| 71 | QScreen *QPlatformScreen::screen() const | - | ||||||||||||
| 72 | { | - | ||||||||||||
| 73 | const QPlatformScreenPrivate * const d = d_func(); | - | ||||||||||||
| 74 | return d->screen; | - | ||||||||||||
| 75 | } | - | ||||||||||||
| 76 | QSizeF QPlatformScreen::physicalSize() const | - | ||||||||||||
| 77 | { | - | ||||||||||||
| 78 | static const int dpi = 100; | - | ||||||||||||
| 79 | return QSizeF(geometry().size()) / dpi * qreal(25.4); | - | ||||||||||||
| 80 | } | - | ||||||||||||
| 81 | QDpi QPlatformScreen::logicalDpi() const | - | ||||||||||||
| 82 | { | - | ||||||||||||
| 83 | QSizeF ps = physicalSize(); | - | ||||||||||||
| 84 | QSize s = geometry().size(); | - | ||||||||||||
| 85 | - | |||||||||||||
| 86 | return QDpi(25.4 * s.width() / ps.width(), | - | ||||||||||||
| 87 | 25.4 * s.height() / ps.height()); | - | ||||||||||||
| 88 | } | - | ||||||||||||
| 89 | qreal QPlatformScreen::devicePixelRatio() const | - | ||||||||||||
| 90 | { | - | ||||||||||||
| 91 | return 1.0; | - | ||||||||||||
| 92 | } | - | ||||||||||||
| 93 | qreal QPlatformScreen::pixelDensity() const | - | ||||||||||||
| 94 | { | - | ||||||||||||
| 95 | return 1.0; | - | ||||||||||||
| 96 | } | - | ||||||||||||
| 97 | - | |||||||||||||
| 98 | - | |||||||||||||
| 99 | - | |||||||||||||
| 100 | - | |||||||||||||
| 101 | - | |||||||||||||
| 102 | - | |||||||||||||
| 103 | - | |||||||||||||
| 104 | qreal QPlatformScreen::refreshRate() const | - | ||||||||||||
| 105 | { | - | ||||||||||||
| 106 | return 60; | - | ||||||||||||
| 107 | } | - | ||||||||||||
| 108 | Qt::ScreenOrientation QPlatformScreen::nativeOrientation() const | - | ||||||||||||
| 109 | { | - | ||||||||||||
| 110 | return Qt::PrimaryOrientation; | - | ||||||||||||
| 111 | } | - | ||||||||||||
| 112 | Qt::ScreenOrientation QPlatformScreen::orientation() const | - | ||||||||||||
| 113 | { | - | ||||||||||||
| 114 | return Qt::PrimaryOrientation; | - | ||||||||||||
| 115 | } | - | ||||||||||||
| 116 | void QPlatformScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) | - | ||||||||||||
| 117 | { | - | ||||||||||||
| 118 | (void)mask;; | - | ||||||||||||
| 119 | } | - | ||||||||||||
| 120 | - | |||||||||||||
| 121 | QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window) | - | ||||||||||||
| 122 | { | - | ||||||||||||
| 123 | - | |||||||||||||
| 124 | - | |||||||||||||
| 125 | if (!window->screen()) | - | ||||||||||||
| 126 | return 0; | - | ||||||||||||
| 127 | return window->screen()->handle(); | - | ||||||||||||
| 128 | } | - | ||||||||||||
| 129 | QPlatformCursor *QPlatformScreen::cursor() const | - | ||||||||||||
| 130 | { | - | ||||||||||||
| 131 | return 0; | - | ||||||||||||
| 132 | } | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | - | |||||||||||||
| 135 | - | |||||||||||||
| 136 | - | |||||||||||||
| 137 | - | |||||||||||||
| 138 | void QPlatformScreen::resizeMaximizedWindows() | - | ||||||||||||
| 139 | { | - | ||||||||||||
| 140 | QList<QWindow*> windows = QGuiApplication::allWindows(); | - | ||||||||||||
| 141 | - | |||||||||||||
| 142 | - | |||||||||||||
| 143 | const QRect oldGeometry = screen()->geometry(); | - | ||||||||||||
| 144 | const QRect oldAvailableGeometry = screen()->availableGeometry(); | - | ||||||||||||
| 145 | const QRect newGeometry = deviceIndependentGeometry(); | - | ||||||||||||
| 146 | const QRect newAvailableGeometry = QHighDpi::fromNative(availableGeometry(), QHighDpiScaling::factor(this), newGeometry.topLeft()); | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | - | |||||||||||||
| 149 | for (int i = 0; i < windows.size(); ++i) { | - | ||||||||||||
| 150 | QWindow *w = windows.at(i); | - | ||||||||||||
| 151 | - | |||||||||||||
| 152 | - | |||||||||||||
| 153 | if (!w->handle()) | - | ||||||||||||
| 154 | continue; | - | ||||||||||||
| 155 | - | |||||||||||||
| 156 | if (platformScreenForWindow(w) != this) | - | ||||||||||||
| 157 | continue; | - | ||||||||||||
| 158 | - | |||||||||||||
| 159 | if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) | - | ||||||||||||
| 160 | w->setGeometry(newAvailableGeometry); | - | ||||||||||||
| 161 | else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) | - | ||||||||||||
| 162 | w->setGeometry(newGeometry); | - | ||||||||||||
| 163 | } | - | ||||||||||||
| 164 | } | - | ||||||||||||
| 165 | - | |||||||||||||
| 166 | - | |||||||||||||
| 167 | static int log2(uint i) | - | ||||||||||||
| 168 | { | - | ||||||||||||
| 169 | if (i == 0) | - | ||||||||||||
| 170 | return -1; | - | ||||||||||||
| 171 | - | |||||||||||||
| 172 | int result = 0; | - | ||||||||||||
| 173 | while (!(i & 1)) { | - | ||||||||||||
| 174 | ++result; | - | ||||||||||||
| 175 | i >>= 1; | - | ||||||||||||
| 176 | } | - | ||||||||||||
| 177 | return result; | - | ||||||||||||
| 178 | } | - | ||||||||||||
| 179 | - | |||||||||||||
| 180 | int QPlatformScreen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) | - | ||||||||||||
| 181 | { | - | ||||||||||||
| 182 | if (a == Qt::PrimaryOrientation || b == Qt::PrimaryOrientation) { | - | ||||||||||||
| 183 | QMessageLogger(__FILE__, 369376, __PRETTY_FUNCTION__).warning("Use QScreen version of %sBetween() when passing Qt::PrimaryOrientation", "angle"); | - | ||||||||||||
| 184 | return 0; | - | ||||||||||||
| 185 | } | - | ||||||||||||
| 186 | - | |||||||||||||
| 187 | if (a == b) | - | ||||||||||||
| 188 | return 0; | - | ||||||||||||
| 189 | - | |||||||||||||
| 190 | int ia = log2(uint(a)); | - | ||||||||||||
| 191 | int ib = log2(uint(b)); | - | ||||||||||||
| 192 | - | |||||||||||||
| 193 | int delta = ia - ib; | - | ||||||||||||
| 194 | - | |||||||||||||
| 195 | if (delta < 0) | - | ||||||||||||
| 196 | delta = delta + 4; | - | ||||||||||||
| 197 | - | |||||||||||||
| 198 | int angles[] = { 0, 90, 180, 270 }; | - | ||||||||||||
| 199 | return angles[delta]; | - | ||||||||||||
| 200 | } | - | ||||||||||||
| 201 | - | |||||||||||||
| 202 | QTransform QPlatformScreen::transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target) | - | ||||||||||||
| 203 | { | - | ||||||||||||
| 204 | if (a == Qt::PrimaryOrientation || b == Qt::PrimaryOrientation) { | - | ||||||||||||
| 205 | QMessageLogger(__FILE__, 391398, __PRETTY_FUNCTION__).warning("Use QScreen version of %sBetween() when passing Qt::PrimaryOrientation", "transform"); | - | ||||||||||||
| 206 | return QTransform(); | - | ||||||||||||
| 207 | } | - | ||||||||||||
| 208 | - | |||||||||||||
| 209 | if (a == b) | - | ||||||||||||
| 210 | return QTransform(); | - | ||||||||||||
| 211 | - | |||||||||||||
| 212 | int angle = angleBetween(a, b); | - | ||||||||||||
| 213 | - | |||||||||||||
| 214 | QTransform result; | - | ||||||||||||
| 215 | switch (angle) { | - | ||||||||||||
| 216 | case 90: | - | ||||||||||||
| 217 | result.translate(target.width(), 0); | - | ||||||||||||
| 218 | break; | - | ||||||||||||
| 219 | case 180: | - | ||||||||||||
| 220 | result.translate(target.width(), target.height()); | - | ||||||||||||
| 221 | break; | - | ||||||||||||
| 222 | case 270: | - | ||||||||||||
| 223 | result.translate(0, target.height()); | - | ||||||||||||
| 224 | break; | - | ||||||||||||
| 225 | default: | - | ||||||||||||
| 226 | ((!(false)) ? qt_assert("false",__FILE__,412419) : qt_noop()); | - | ||||||||||||
| 227 | } | - | ||||||||||||
| 228 | result.rotate(angle); | - | ||||||||||||
| 229 | - | |||||||||||||
| 230 | return result; | - | ||||||||||||
| 231 | } | - | ||||||||||||
| 232 | - | |||||||||||||
| 233 | QRect QPlatformScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect) | - | ||||||||||||
| 234 | { | - | ||||||||||||
| 235 | if (a == Qt::PrimaryOrientation || b == Qt::PrimaryOrientation) { | - | ||||||||||||
| 236 | QMessageLogger(__FILE__, 422429, __PRETTY_FUNCTION__).warning("Use QScreen version of %sBetween() when passing Qt::PrimaryOrientation", "map"); | - | ||||||||||||
| 237 | return rect; | - | ||||||||||||
| 238 | } | - | ||||||||||||
| 239 | - | |||||||||||||
| 240 | if (a == b) | - | ||||||||||||
| 241 | return rect; | - | ||||||||||||
| 242 | - | |||||||||||||
| 243 | if ((a == Qt::PortraitOrientation || a == Qt::InvertedPortraitOrientation) | - | ||||||||||||
| 244 | != (b == Qt::PortraitOrientation || b == Qt::InvertedPortraitOrientation)) | - | ||||||||||||
| 245 | { | - | ||||||||||||
| 246 | return QRect(rect.y(), rect.x(), rect.height(), rect.width()); | - | ||||||||||||
| 247 | } | - | ||||||||||||
| 248 | - | |||||||||||||
| 249 | return rect; | - | ||||||||||||
| 250 | } | - | ||||||||||||
| 251 | - | |||||||||||||
| 252 | QRect QPlatformScreen::deviceIndependentGeometry() const | - | ||||||||||||
| 253 | { | - | ||||||||||||
| 254 | qreal scaleFactor = QHighDpiScaling::factor(this); | - | ||||||||||||
| 255 | QRect nativeGeometry = geometry(); | - | ||||||||||||
| 256 | return QRect(nativeGeometry.topLeft(), QHighDpi::fromNative(nativeGeometry.size(), scaleFactor)); | - | ||||||||||||
| 257 | } | - | ||||||||||||
| 258 | QPlatformScreen::SubpixelAntialiasingType QPlatformScreen::subpixelAntialiasingTypeHint() const | - | ||||||||||||
| 259 | { | - | ||||||||||||
| 260 | static int type = -1; | - | ||||||||||||
| 261 | if (type == -1) { | - | ||||||||||||
| 262 | QByteArray env = qgetenv("QT_SUBPIXEL_AA_TYPE"); | - | ||||||||||||
| 263 | if (env == "RGB") | - | ||||||||||||
| 264 | type = QPlatformScreen::Subpixel_RGB; | - | ||||||||||||
| 265 | else if (env == "BGR") | - | ||||||||||||
| 266 | type = QPlatformScreen::Subpixel_BGR; | - | ||||||||||||
| 267 | else if (env == "VRGB") | - | ||||||||||||
| 268 | type = QPlatformScreen::Subpixel_VRGB; | - | ||||||||||||
| 269 | else if (env == "VBGR") | - | ||||||||||||
| 270 | type = QPlatformScreen::Subpixel_VBGR; | - | ||||||||||||
| 271 | else | - | ||||||||||||
| 272 | type = QPlatformScreen::Subpixel_None; | - | ||||||||||||
| 273 | } | - | ||||||||||||
| 274 | - | |||||||||||||
| 275 | return static_cast<QPlatformScreen::SubpixelAntialiasingType>(type); | - | ||||||||||||
| 276 | } | - | ||||||||||||
| 277 | - | |||||||||||||
| 278 | - | |||||||||||||
| 279 | - | |||||||||||||
| 280 | - | |||||||||||||
| 281 | - | |||||||||||||
| 282 | - | |||||||||||||
| 283 | QPlatformScreen::PowerState QPlatformScreen::powerState() const | - | ||||||||||||
| 284 | { | - | ||||||||||||
| 285 | return PowerStateOn; | - | ||||||||||||
| 286 | } | - | ||||||||||||
| 287 | - | |||||||||||||
| 288 | - | |||||||||||||
| 289 | - | |||||||||||||
| 290 | - | |||||||||||||
| 291 | void QPlatformScreen::setPowerState(PowerState state) | - | ||||||||||||
| 292 | { | - | ||||||||||||
| 293 | (void)state;; | - | ||||||||||||
| 294 | } | - | ||||||||||||
| 295 | - | |||||||||||||
| 296 | - | |||||||||||||
| Switch to Source code | Preprocessed file |