| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qplatformwindow.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 "qplatformwindow.h" | - | ||||||||||||||||||
| 35 | #include "qplatformwindow_p.h" | - | ||||||||||||||||||
| 36 | #include "qplatformscreen.h" | - | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | #include <private/qguiapplication_p.h> | - | ||||||||||||||||||
| 39 | #include <qpa/qwindowsysteminterface.h> | - | ||||||||||||||||||
| 40 | #include <QtGui/qwindow.h> | - | ||||||||||||||||||
| 41 | #include <QtGui/qscreen.h> | - | ||||||||||||||||||
| 42 | #include <private/qhighdpiscaling_p.h> | - | ||||||||||||||||||
| 43 | #include <private/qwindow_p.h> | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | /*! | - | ||||||||||||||||||
| 49 | Constructs a platform window with the given top level window. | - | ||||||||||||||||||
| 50 | */ | - | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | QPlatformWindow::QPlatformWindow(QWindow *window) | - | ||||||||||||||||||
| 53 | : QPlatformSurface(window) | - | ||||||||||||||||||
| 54 | , d_ptr(new QPlatformWindowPrivate) | - | ||||||||||||||||||
| 55 | { | - | ||||||||||||||||||
| 56 | Q_D(QPlatformWindow); | - | ||||||||||||||||||
| 57 | d->rect = window->geometry(); | - | ||||||||||||||||||
| 58 | } never executed: end of block | 0 | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | /*! | - | ||||||||||||||||||
| 61 | Virtual destructor does not delete its top level window. | - | ||||||||||||||||||
| 62 | */ | - | ||||||||||||||||||
| 63 | QPlatformWindow::~QPlatformWindow() | - | ||||||||||||||||||
| 64 | { | - | ||||||||||||||||||
| 65 | } | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | /*! | - | ||||||||||||||||||
| 68 | Returns the window which belongs to the QPlatformWindow | - | ||||||||||||||||||
| 69 | */ | - | ||||||||||||||||||
| 70 | QWindow *QPlatformWindow::window() const | - | ||||||||||||||||||
| 71 | { | - | ||||||||||||||||||
| 72 | return static_cast<QWindow *>(m_surface); never executed: return static_cast<QWindow *>(m_surface); | 0 | ||||||||||||||||||
| 73 | } | - | ||||||||||||||||||
| 74 | - | |||||||||||||||||||
| 75 | /*! | - | ||||||||||||||||||
| 76 | Returns the parent platform window (or 0 if orphan). | - | ||||||||||||||||||
| 77 | */ | - | ||||||||||||||||||
| 78 | QPlatformWindow *QPlatformWindow::parent() const | - | ||||||||||||||||||
| 79 | { | - | ||||||||||||||||||
| 80 | return window()->parent() ? window()->parent()->handle() : 0; never executed: return window()->parent() ? window()->parent()->handle() : 0;
| 0 | ||||||||||||||||||
| 81 | } | - | ||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | /*! | - | ||||||||||||||||||
| 84 | Returns the platform screen handle corresponding to this platform window, | - | ||||||||||||||||||
| 85 | or null if the window is not associated with a screen. | - | ||||||||||||||||||
| 86 | */ | - | ||||||||||||||||||
| 87 | QPlatformScreen *QPlatformWindow::screen() const | - | ||||||||||||||||||
| 88 | { | - | ||||||||||||||||||
| 89 | QScreen *scr = window()->screen(); | - | ||||||||||||||||||
| 90 | return scr ? scr->handle() : Q_NULLPTR; never executed: return scr ? scr->handle() : nullptr;
| 0 | ||||||||||||||||||
| 91 | } | - | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | /*! | - | ||||||||||||||||||
| 94 | Returns the actual surface format of the window. | - | ||||||||||||||||||
| 95 | */ | - | ||||||||||||||||||
| 96 | QSurfaceFormat QPlatformWindow::format() const | - | ||||||||||||||||||
| 97 | { | - | ||||||||||||||||||
| 98 | return QSurfaceFormat(); never executed: return QSurfaceFormat(); | 0 | ||||||||||||||||||
| 99 | } | - | ||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | /*! | - | ||||||||||||||||||
| 102 | This function is called by Qt whenever a window is moved or the window is resized. The resize | - | ||||||||||||||||||
| 103 | can happen programatically(from ie. user application) or by the window manager. This means that | - | ||||||||||||||||||
| 104 | there is no need to call this function specifically from the window manager callback, instead | - | ||||||||||||||||||
| 105 | call QWindowSystemInterface::handleGeometryChange(QWindow *w, const QRect &newRect); | - | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | The position(x, y) part of the rect might be inclusive or exclusive of the window frame | - | ||||||||||||||||||
| 108 | as returned by frameMargins(). You can detect this in the plugin by checking | - | ||||||||||||||||||
| 109 | qt_window_private(window())->positionPolicy. | - | ||||||||||||||||||
| 110 | */ | - | ||||||||||||||||||
| 111 | void QPlatformWindow::setGeometry(const QRect &rect) | - | ||||||||||||||||||
| 112 | { | - | ||||||||||||||||||
| 113 | Q_D(QPlatformWindow); | - | ||||||||||||||||||
| 114 | d->rect = rect; | - | ||||||||||||||||||
| 115 | } never executed: end of block | 0 | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | /*! | - | ||||||||||||||||||
| 118 | Returnes the current geometry of a window | - | ||||||||||||||||||
| 119 | */ | - | ||||||||||||||||||
| 120 | QRect QPlatformWindow::geometry() const | - | ||||||||||||||||||
| 121 | { | - | ||||||||||||||||||
| 122 | Q_D(const QPlatformWindow); | - | ||||||||||||||||||
| 123 | return d->rect; never executed: return d->rect; | 0 | ||||||||||||||||||
| 124 | } | - | ||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | /*! | - | ||||||||||||||||||
| 127 | Returns the geometry of a window in 'normal' state | - | ||||||||||||||||||
| 128 | (neither maximized, fullscreen nor minimized) for saving geometries to | - | ||||||||||||||||||
| 129 | application settings. | - | ||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | \since 5.3 | - | ||||||||||||||||||
| 132 | */ | - | ||||||||||||||||||
| 133 | QRect QPlatformWindow::normalGeometry() const | - | ||||||||||||||||||
| 134 | { | - | ||||||||||||||||||
| 135 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||
| 136 | } | - | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | QMargins QPlatformWindow::frameMargins() const | - | ||||||||||||||||||
| 139 | { | - | ||||||||||||||||||
| 140 | return QMargins(); never executed: return QMargins(); | 0 | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | /*! | - | ||||||||||||||||||
| 144 | Reimplemented in subclasses to show the surface | - | ||||||||||||||||||
| 145 | if \a visible is \c true, and hide it if \a visible is \c false. | - | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | The default implementation sends a synchronous expose event. | - | ||||||||||||||||||
| 148 | */ | - | ||||||||||||||||||
| 149 | void QPlatformWindow::setVisible(bool visible) | - | ||||||||||||||||||
| 150 | { | - | ||||||||||||||||||
| 151 | Q_UNUSED(visible); | - | ||||||||||||||||||
| 152 | QRect rect(QPoint(), geometry().size()); | - | ||||||||||||||||||
| 153 | QWindowSystemInterface::handleExposeEvent(window(), rect); | - | ||||||||||||||||||
| 154 | QWindowSystemInterface::flushWindowSystemEvents(); | - | ||||||||||||||||||
| 155 | } never executed: end of block | 0 | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | /*! | - | ||||||||||||||||||
| 158 | Requests setting the window flags of this surface | - | ||||||||||||||||||
| 159 | to \a flags. | - | ||||||||||||||||||
| 160 | */ | - | ||||||||||||||||||
| 161 | void QPlatformWindow::setWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||
| 162 | { | - | ||||||||||||||||||
| 163 | Q_UNUSED(flags); | - | ||||||||||||||||||
| 164 | } never executed: end of block | 0 | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | /*! | - | ||||||||||||||||||
| 167 | Returns if this window is exposed in the windowing system. | - | ||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | An exposeEvent() is sent every time this value changes. | - | ||||||||||||||||||
| 170 | */ | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | bool QPlatformWindow::isExposed() const | - | ||||||||||||||||||
| 173 | { | - | ||||||||||||||||||
| 174 | return window()->isVisible(); never executed: return window()->isVisible(); | 0 | ||||||||||||||||||
| 175 | } | - | ||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 | /*! | - | ||||||||||||||||||
| 178 | Returns \c true if the window should appear active from a style perspective. | - | ||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | This function can make platform-specific isActive checks, such as checking | - | ||||||||||||||||||
| 181 | if the QWindow is embedded in an active native window. | - | ||||||||||||||||||
| 182 | */ | - | ||||||||||||||||||
| 183 | bool QPlatformWindow::isActive() const | - | ||||||||||||||||||
| 184 | { | - | ||||||||||||||||||
| 185 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 186 | } | - | ||||||||||||||||||
| 187 | - | |||||||||||||||||||
| 188 | /*! | - | ||||||||||||||||||
| 189 | Returns \c true if the window is a descendant of an embedded non-Qt window. | - | ||||||||||||||||||
| 190 | Example of an embedded non-Qt window is the parent window of an in-process QAxServer. | - | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | If \a parentWindow is nonzero, only check if the window is embedded in the | - | ||||||||||||||||||
| 193 | specified \a parentWindow. | - | ||||||||||||||||||
| 194 | */ | - | ||||||||||||||||||
| 195 | bool QPlatformWindow::isEmbedded(const QPlatformWindow *parentWindow) const | - | ||||||||||||||||||
| 196 | { | - | ||||||||||||||||||
| 197 | Q_UNUSED(parentWindow); | - | ||||||||||||||||||
| 198 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 199 | } | - | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | /*! | - | ||||||||||||||||||
| 202 | Translates the window coordinate \a pos to global screen | - | ||||||||||||||||||
| 203 | coordinates using native methods. This is required for embedded windows, | - | ||||||||||||||||||
| 204 | where the topmost QWindow coordinates are not global screen coordinates. | - | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | Returns \a pos if there is no platform specific implementation. | - | ||||||||||||||||||
| 207 | */ | - | ||||||||||||||||||
| 208 | QPoint QPlatformWindow::mapToGlobal(const QPoint &pos) const | - | ||||||||||||||||||
| 209 | { | - | ||||||||||||||||||
| 210 | const QPlatformWindow *p = this; | - | ||||||||||||||||||
| 211 | QPoint result = pos; | - | ||||||||||||||||||
| 212 | while (p) {
| 0 | ||||||||||||||||||
| 213 | result += p->geometry().topLeft(); | - | ||||||||||||||||||
| 214 | p = p->parent(); | - | ||||||||||||||||||
| 215 | } never executed: end of block | 0 | ||||||||||||||||||
| 216 | return result; never executed: return result; | 0 | ||||||||||||||||||
| 217 | } | - | ||||||||||||||||||
| 218 | - | |||||||||||||||||||
| 219 | /*! | - | ||||||||||||||||||
| 220 | Translates the global screen coordinate \a pos to window | - | ||||||||||||||||||
| 221 | coordinates using native methods. This is required for embedded windows, | - | ||||||||||||||||||
| 222 | where the topmost QWindow coordinates are not global screen coordinates. | - | ||||||||||||||||||
| 223 | - | |||||||||||||||||||
| 224 | Returns \a pos if there is no platform specific implementation. | - | ||||||||||||||||||
| 225 | */ | - | ||||||||||||||||||
| 226 | QPoint QPlatformWindow::mapFromGlobal(const QPoint &pos) const | - | ||||||||||||||||||
| 227 | { | - | ||||||||||||||||||
| 228 | const QPlatformWindow *p = this; | - | ||||||||||||||||||
| 229 | QPoint result = pos; | - | ||||||||||||||||||
| 230 | while (p) {
| 0 | ||||||||||||||||||
| 231 | result -= p->geometry().topLeft(); | - | ||||||||||||||||||
| 232 | p = p->parent(); | - | ||||||||||||||||||
| 233 | } never executed: end of block | 0 | ||||||||||||||||||
| 234 | return result; never executed: return result; | 0 | ||||||||||||||||||
| 235 | } | - | ||||||||||||||||||
| 236 | - | |||||||||||||||||||
| 237 | /*! | - | ||||||||||||||||||
| 238 | Requests setting the window state of this surface | - | ||||||||||||||||||
| 239 | to \a type. | - | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | Qt::WindowActive can be ignored. | - | ||||||||||||||||||
| 242 | */ | - | ||||||||||||||||||
| 243 | void QPlatformWindow::setWindowState(Qt::WindowState) | - | ||||||||||||||||||
| 244 | { | - | ||||||||||||||||||
| 245 | } | - | ||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | /*! | - | ||||||||||||||||||
| 248 | Reimplement in subclasses to return a handle to the native window | - | ||||||||||||||||||
| 249 | */ | - | ||||||||||||||||||
| 250 | WId QPlatformWindow::winId() const | - | ||||||||||||||||||
| 251 | { | - | ||||||||||||||||||
| 252 | // Return anything but 0. Returning 0 would cause havoc with QWidgets on | - | ||||||||||||||||||
| 253 | // very basic platform plugins that do not reimplement this function, | - | ||||||||||||||||||
| 254 | // because the top-level widget's internalWinId() would always be 0 which | - | ||||||||||||||||||
| 255 | // would mean top-levels are never treated as native. | - | ||||||||||||||||||
| 256 | return WId(1); never executed: return WId(1); | 0 | ||||||||||||||||||
| 257 | } | - | ||||||||||||||||||
| 258 | - | |||||||||||||||||||
| 259 | /*! | - | ||||||||||||||||||
| 260 | This function is called to enable native child window in QPA. It is common not to support this | - | ||||||||||||||||||
| 261 | feature in Window systems, but can be faked. When this function is called all geometry of this | - | ||||||||||||||||||
| 262 | platform window will be relative to the parent. | - | ||||||||||||||||||
| 263 | */ | - | ||||||||||||||||||
| 264 | //jl: It would be useful to have a property on the platform window which indicated if the sub-class | - | ||||||||||||||||||
| 265 | // supported the setParent. If not, then geometry would be in screen coordinates. | - | ||||||||||||||||||
| 266 | void QPlatformWindow::setParent(const QPlatformWindow *parent) | - | ||||||||||||||||||
| 267 | { | - | ||||||||||||||||||
| 268 | Q_UNUSED(parent); | - | ||||||||||||||||||
| 269 | qWarning("This plugin does not support setParent!"); | - | ||||||||||||||||||
| 270 | } never executed: end of block | 0 | ||||||||||||||||||
| 271 | - | |||||||||||||||||||
| 272 | /*! | - | ||||||||||||||||||
| 273 | Reimplement to set the window title to \a title. | - | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | The implementation might want to append the application display name to | - | ||||||||||||||||||
| 276 | the window title, like Windows and Linux do. | - | ||||||||||||||||||
| 277 | - | |||||||||||||||||||
| 278 | \sa QGuiApplication::applicationDisplayName() | - | ||||||||||||||||||
| 279 | */ | - | ||||||||||||||||||
| 280 | void QPlatformWindow::setWindowTitle(const QString &title) { Q_UNUSED(title); } never executed: end of block | 0 | ||||||||||||||||||
| 281 | - | |||||||||||||||||||
| 282 | /*! | - | ||||||||||||||||||
| 283 | Reimplement to set the window file path to \a filePath | - | ||||||||||||||||||
| 284 | */ | - | ||||||||||||||||||
| 285 | void QPlatformWindow::setWindowFilePath(const QString &filePath) { Q_UNUSED(filePath); } never executed: end of block | 0 | ||||||||||||||||||
| 286 | - | |||||||||||||||||||
| 287 | /*! | - | ||||||||||||||||||
| 288 | Reimplement to set the window icon to \a icon | - | ||||||||||||||||||
| 289 | */ | - | ||||||||||||||||||
| 290 | void QPlatformWindow::setWindowIcon(const QIcon &icon) { Q_UNUSED(icon); } never executed: end of block | 0 | ||||||||||||||||||
| 291 | - | |||||||||||||||||||
| 292 | /*! | - | ||||||||||||||||||
| 293 | Reimplement to be able to let Qt raise windows to the top of the desktop | - | ||||||||||||||||||
| 294 | */ | - | ||||||||||||||||||
| 295 | void QPlatformWindow::raise() { qWarning("This plugin does not support raise()"); } never executed: end of block | 0 | ||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | /*! | - | ||||||||||||||||||
| 298 | Reimplement to be able to let Qt lower windows to the bottom of the desktop | - | ||||||||||||||||||
| 299 | */ | - | ||||||||||||||||||
| 300 | void QPlatformWindow::lower() { qWarning("This plugin does not support lower()"); } never executed: end of block | 0 | ||||||||||||||||||
| 301 | - | |||||||||||||||||||
| 302 | /*! | - | ||||||||||||||||||
| 303 | Reimplement to propagate the size hints of the QWindow. | - | ||||||||||||||||||
| 304 | - | |||||||||||||||||||
| 305 | The size hints include QWindow::minimumSize(), QWindow::maximumSize(), | - | ||||||||||||||||||
| 306 | QWindow::sizeIncrement(), and QWindow::baseSize(). | - | ||||||||||||||||||
| 307 | */ | - | ||||||||||||||||||
| 308 | void QPlatformWindow::propagateSizeHints() {qWarning("This plugin does not support propagateSizeHints()"); } never executed: end of block | 0 | ||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | /*! | - | ||||||||||||||||||
| 311 | Reimplement to be able to let Qt set the opacity level of a window | - | ||||||||||||||||||
| 312 | */ | - | ||||||||||||||||||
| 313 | void QPlatformWindow::setOpacity(qreal level) | - | ||||||||||||||||||
| 314 | { | - | ||||||||||||||||||
| 315 | Q_UNUSED(level); | - | ||||||||||||||||||
| 316 | qWarning("This plugin does not support setting window opacity"); | - | ||||||||||||||||||
| 317 | } never executed: end of block | 0 | ||||||||||||||||||
| 318 | - | |||||||||||||||||||
| 319 | /*! | - | ||||||||||||||||||
| 320 | Reimplement to be able to let Qt set the mask of a window | - | ||||||||||||||||||
| 321 | */ | - | ||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | void QPlatformWindow::setMask(const QRegion ®ion) | - | ||||||||||||||||||
| 324 | { | - | ||||||||||||||||||
| 325 | Q_UNUSED(region); | - | ||||||||||||||||||
| 326 | qWarning("This plugin does not support setting window masks"); | - | ||||||||||||||||||
| 327 | } never executed: end of block | 0 | ||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | /*! | - | ||||||||||||||||||
| 330 | Reimplement to let Qt be able to request activation/focus for a window | - | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | Some window systems will probably not have callbacks for this functionality, | - | ||||||||||||||||||
| 333 | and then calling QWindowSystemInterface::handleWindowActivated(QWindow *w) | - | ||||||||||||||||||
| 334 | would be sufficient. | - | ||||||||||||||||||
| 335 | - | |||||||||||||||||||
| 336 | If the window system has some event handling/callbacks then call | - | ||||||||||||||||||
| 337 | QWindowSystemInterface::handleWindowActivated(QWindow *w) when the window system | - | ||||||||||||||||||
| 338 | gives the notification. | - | ||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | Default implementation calls QWindowSystem::handleWindowActivated(QWindow *w) | - | ||||||||||||||||||
| 341 | */ | - | ||||||||||||||||||
| 342 | void QPlatformWindow::requestActivateWindow() | - | ||||||||||||||||||
| 343 | { | - | ||||||||||||||||||
| 344 | QWindowSystemInterface::handleWindowActivated(window()); | - | ||||||||||||||||||
| 345 | } never executed: end of block | 0 | ||||||||||||||||||
| 346 | - | |||||||||||||||||||
| 347 | /*! | - | ||||||||||||||||||
| 348 | Handle changes to the orientation of the platform window's contents. | - | ||||||||||||||||||
| 349 | - | |||||||||||||||||||
| 350 | This is a hint to the window manager in case it needs to display | - | ||||||||||||||||||
| 351 | additional content like popups, dialogs, status bars, or similar | - | ||||||||||||||||||
| 352 | in relation to the window. | - | ||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | \sa QWindow::reportContentOrientationChange() | - | ||||||||||||||||||
| 355 | */ | - | ||||||||||||||||||
| 356 | void QPlatformWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation) | - | ||||||||||||||||||
| 357 | { | - | ||||||||||||||||||
| 358 | Q_UNUSED(orientation); | - | ||||||||||||||||||
| 359 | } never executed: end of block | 0 | ||||||||||||||||||
| 360 | - | |||||||||||||||||||
| 361 | /*! | - | ||||||||||||||||||
| 362 | Reimplement this function in subclass to return the device pixel ratio | - | ||||||||||||||||||
| 363 | for the window. This is the ratio between physical pixels | - | ||||||||||||||||||
| 364 | and device-independent pixels. | - | ||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | \sa QPlatformWindow::devicePixelRatio(); | - | ||||||||||||||||||
| 367 | */ | - | ||||||||||||||||||
| 368 | qreal QPlatformWindow::devicePixelRatio() const | - | ||||||||||||||||||
| 369 | { | - | ||||||||||||||||||
| 370 | return 1.0; never executed: return 1.0; | 0 | ||||||||||||||||||
| 371 | } | - | ||||||||||||||||||
| 372 | - | |||||||||||||||||||
| 373 | bool QPlatformWindow::setKeyboardGrabEnabled(bool grab) | - | ||||||||||||||||||
| 374 | { | - | ||||||||||||||||||
| 375 | Q_UNUSED(grab); | - | ||||||||||||||||||
| 376 | qWarning("This plugin does not support grabbing the keyboard"); | - | ||||||||||||||||||
| 377 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 378 | } | - | ||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | bool QPlatformWindow::setMouseGrabEnabled(bool grab) | - | ||||||||||||||||||
| 381 | { | - | ||||||||||||||||||
| 382 | Q_UNUSED(grab); | - | ||||||||||||||||||
| 383 | qWarning("This plugin does not support grabbing the mouse"); | - | ||||||||||||||||||
| 384 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 385 | } | - | ||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | /*! | - | ||||||||||||||||||
| 388 | Reimplement to be able to let Qt indicate that the window has been | - | ||||||||||||||||||
| 389 | modified. Return true if the native window supports setting the modified | - | ||||||||||||||||||
| 390 | flag, false otherwise. | - | ||||||||||||||||||
| 391 | */ | - | ||||||||||||||||||
| 392 | bool QPlatformWindow::setWindowModified(bool modified) | - | ||||||||||||||||||
| 393 | { | - | ||||||||||||||||||
| 394 | Q_UNUSED(modified); | - | ||||||||||||||||||
| 395 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 396 | } | - | ||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | /*! | - | ||||||||||||||||||
| 399 | Reimplement this method to be able to do any platform specific event | - | ||||||||||||||||||
| 400 | handling. All events for window() are passed to this function before being | - | ||||||||||||||||||
| 401 | sent to QWindow::event(). | - | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | The default implementation is empty and does nothing with \a event. | - | ||||||||||||||||||
| 404 | */ | - | ||||||||||||||||||
| 405 | void QPlatformWindow::windowEvent(QEvent *event) | - | ||||||||||||||||||
| 406 | { | - | ||||||||||||||||||
| 407 | Q_UNUSED(event); | - | ||||||||||||||||||
| 408 | } never executed: end of block | 0 | ||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | /*! | - | ||||||||||||||||||
| 411 | Reimplement this method to start a system size grip drag | - | ||||||||||||||||||
| 412 | operation if the system supports it and return true to indicate | - | ||||||||||||||||||
| 413 | success. | - | ||||||||||||||||||
| 414 | It is called from the mouse press event handler of the size grip. | - | ||||||||||||||||||
| 415 | - | |||||||||||||||||||
| 416 | The default implementation is empty and does nothing with \a pos | - | ||||||||||||||||||
| 417 | and \a corner. | - | ||||||||||||||||||
| 418 | */ | - | ||||||||||||||||||
| 419 | - | |||||||||||||||||||
| 420 | bool QPlatformWindow::startSystemResize(const QPoint &pos, Qt::Corner corner) | - | ||||||||||||||||||
| 421 | { | - | ||||||||||||||||||
| 422 | Q_UNUSED(pos) | - | ||||||||||||||||||
| 423 | Q_UNUSED(corner) | - | ||||||||||||||||||
| 424 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 425 | } | - | ||||||||||||||||||
| 426 | - | |||||||||||||||||||
| 427 | /*! | - | ||||||||||||||||||
| 428 | Reimplement this method to set whether frame strut events | - | ||||||||||||||||||
| 429 | should be sent to \a enabled. | - | ||||||||||||||||||
| 430 | - | |||||||||||||||||||
| 431 | \sa frameStrutEventsEnabled | - | ||||||||||||||||||
| 432 | */ | - | ||||||||||||||||||
| 433 | - | |||||||||||||||||||
| 434 | void QPlatformWindow::setFrameStrutEventsEnabled(bool enabled) | - | ||||||||||||||||||
| 435 | { | - | ||||||||||||||||||
| 436 | Q_UNUSED(enabled) // Do not warn as widgets enable it by default causing warnings with XCB. | - | ||||||||||||||||||
| 437 | } never executed: end of block | 0 | ||||||||||||||||||
| 438 | - | |||||||||||||||||||
| 439 | /*! | - | ||||||||||||||||||
| 440 | Reimplement this method to return whether | - | ||||||||||||||||||
| 441 | frame strut events are enabled. | - | ||||||||||||||||||
| 442 | */ | - | ||||||||||||||||||
| 443 | - | |||||||||||||||||||
| 444 | bool QPlatformWindow::frameStrutEventsEnabled() const | - | ||||||||||||||||||
| 445 | { | - | ||||||||||||||||||
| 446 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 447 | } | - | ||||||||||||||||||
| 448 | - | |||||||||||||||||||
| 449 | /*! | - | ||||||||||||||||||
| 450 | Call this method to put together a window title composed of | - | ||||||||||||||||||
| 451 | \a title | - | ||||||||||||||||||
| 452 | \a separator | - | ||||||||||||||||||
| 453 | the application display name | - | ||||||||||||||||||
| 454 | - | |||||||||||||||||||
| 455 | If the display name isn't set, and the title is empty, the raw app name is used. | - | ||||||||||||||||||
| 456 | */ | - | ||||||||||||||||||
| 457 | QString QPlatformWindow::formatWindowTitle(const QString &title, const QString &separator) | - | ||||||||||||||||||
| 458 | { | - | ||||||||||||||||||
| 459 | QString fullTitle = title; | - | ||||||||||||||||||
| 460 | if (QGuiApplicationPrivate::displayName && !title.endsWith(*QGuiApplicationPrivate::displayName)) {
| 0 | ||||||||||||||||||
| 461 | // Append display name, if set. | - | ||||||||||||||||||
| 462 | if (!fullTitle.isEmpty())
| 0 | ||||||||||||||||||
| 463 | fullTitle += separator; never executed: fullTitle += separator; | 0 | ||||||||||||||||||
| 464 | fullTitle += *QGuiApplicationPrivate::displayName; | - | ||||||||||||||||||
| 465 | } else if (fullTitle.isEmpty()) { never executed: end of block
| 0 | ||||||||||||||||||
| 466 | // Don't let the window title be completely empty, use the app name as fallback. | - | ||||||||||||||||||
| 467 | fullTitle = QCoreApplication::applicationName(); | - | ||||||||||||||||||
| 468 | } never executed: end of block | 0 | ||||||||||||||||||
| 469 | return fullTitle; never executed: return fullTitle; | 0 | ||||||||||||||||||
| 470 | } | - | ||||||||||||||||||
| 471 | - | |||||||||||||||||||
| 472 | /*! | - | ||||||||||||||||||
| 473 | Helper function for finding the new screen for \a newGeometry in response to | - | ||||||||||||||||||
| 474 | a geometry changed event. Returns the new screen if the window was moved to | - | ||||||||||||||||||
| 475 | another virtual sibling. If the screen changes, the platform plugin should call | - | ||||||||||||||||||
| 476 | QWindowSystemInterface::handleWindowScreenChanged(). | - | ||||||||||||||||||
| 477 | \note: The current screen will always be returned for child windows since | - | ||||||||||||||||||
| 478 | they should never signal screen changes. | - | ||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | \since 5.4 | - | ||||||||||||||||||
| 481 | \sa QWindowSystemInterface::handleWindowScreenChanged() | - | ||||||||||||||||||
| 482 | */ | - | ||||||||||||||||||
| 483 | QPlatformScreen *QPlatformWindow::screenForGeometry(const QRect &newGeometry) const | - | ||||||||||||||||||
| 484 | { | - | ||||||||||||||||||
| 485 | QPlatformScreen *currentScreen = screen(); | - | ||||||||||||||||||
| 486 | QPlatformScreen *fallback = currentScreen; | - | ||||||||||||||||||
| 487 | // QRect::center can return a value outside the rectangle if it's empty. | - | ||||||||||||||||||
| 488 | // Apply mapToGlobal() in case it is a foreign/embedded window. | - | ||||||||||||||||||
| 489 | QPoint center = newGeometry.isEmpty() ? newGeometry.topLeft() : newGeometry.center();
| 0 | ||||||||||||||||||
| 490 | if (window()->type() == Qt::ForeignWindow)
| 0 | ||||||||||||||||||
| 491 | center = mapToGlobal(center - newGeometry.topLeft()); never executed: center = mapToGlobal(center - newGeometry.topLeft()); | 0 | ||||||||||||||||||
| 492 | - | |||||||||||||||||||
| 493 | if (!parent() && currentScreen && !currentScreen->geometry().contains(center)) {
| 0 | ||||||||||||||||||
| 494 | Q_FOREACH (QPlatformScreen* screen, currentScreen->virtualSiblings()) { | - | ||||||||||||||||||
| 495 | if (screen->geometry().contains(center))
| 0 | ||||||||||||||||||
| 496 | return screen; never executed: return screen; | 0 | ||||||||||||||||||
| 497 | if (screen->geometry().intersects(newGeometry))
| 0 | ||||||||||||||||||
| 498 | fallback = screen; never executed: fallback = screen; | 0 | ||||||||||||||||||
| 499 | } never executed: end of block | 0 | ||||||||||||||||||
| 500 | } never executed: end of block | 0 | ||||||||||||||||||
| 501 | return fallback; never executed: return fallback; | 0 | ||||||||||||||||||
| 502 | } | - | ||||||||||||||||||
| 503 | - | |||||||||||||||||||
| 504 | /*! | - | ||||||||||||||||||
| 505 | Returns a size with both dimensions bounded to [0, QWINDOWSIZE_MAX] | - | ||||||||||||||||||
| 506 | */ | - | ||||||||||||||||||
| 507 | QSize QPlatformWindow::constrainWindowSize(const QSize &size) | - | ||||||||||||||||||
| 508 | { | - | ||||||||||||||||||
| 509 | return size.expandedTo(QSize(0, 0)).boundedTo(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)); never executed: return size.expandedTo(QSize(0, 0)).boundedTo(QSize(((1<<24)-1), ((1<<24)-1))); | 0 | ||||||||||||||||||
| 510 | } | - | ||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | /*! | - | ||||||||||||||||||
| 513 | Reimplement this method to set whether the window demands attention | - | ||||||||||||||||||
| 514 | (for example, by flashing the taskbar icon) depending on \a enabled. | - | ||||||||||||||||||
| 515 | - | |||||||||||||||||||
| 516 | \sa isAlertState() | - | ||||||||||||||||||
| 517 | \since 5.1 | - | ||||||||||||||||||
| 518 | */ | - | ||||||||||||||||||
| 519 | - | |||||||||||||||||||
| 520 | void QPlatformWindow::setAlertState(bool enable) | - | ||||||||||||||||||
| 521 | { | - | ||||||||||||||||||
| 522 | Q_UNUSED(enable) | - | ||||||||||||||||||
| 523 | } never executed: end of block | 0 | ||||||||||||||||||
| 524 | - | |||||||||||||||||||
| 525 | /*! | - | ||||||||||||||||||
| 526 | Reimplement this method return whether the window is in | - | ||||||||||||||||||
| 527 | an alert state. | - | ||||||||||||||||||
| 528 | - | |||||||||||||||||||
| 529 | \sa setAlertState() | - | ||||||||||||||||||
| 530 | \since 5.1 | - | ||||||||||||||||||
| 531 | */ | - | ||||||||||||||||||
| 532 | - | |||||||||||||||||||
| 533 | bool QPlatformWindow::isAlertState() const | - | ||||||||||||||||||
| 534 | { | - | ||||||||||||||||||
| 535 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 536 | } | - | ||||||||||||||||||
| 537 | - | |||||||||||||||||||
| 538 | // Return the effective screen for the initial geometry of a window. In a | - | ||||||||||||||||||
| 539 | // multimonitor-setup, try to find the right screen by checking the transient | - | ||||||||||||||||||
| 540 | // parent or the mouse cursor for parentless windows (cf QTBUG-34204, | - | ||||||||||||||||||
| 541 | // QDialog::adjustPosition()). | - | ||||||||||||||||||
| 542 | static inline const QScreen *effectiveScreen(const QWindow *window) | - | ||||||||||||||||||
| 543 | { | - | ||||||||||||||||||
| 544 | if (!window)
| 0 | ||||||||||||||||||
| 545 | return QGuiApplication::primaryScreen(); never executed: return QGuiApplication::primaryScreen(); | 0 | ||||||||||||||||||
| 546 | const QScreen *screen = window->screen(); | - | ||||||||||||||||||
| 547 | if (!screen)
| 0 | ||||||||||||||||||
| 548 | return QGuiApplication::primaryScreen(); never executed: return QGuiApplication::primaryScreen(); | 0 | ||||||||||||||||||
| 549 | const QList<QScreen *> siblings = screen->virtualSiblings(); | - | ||||||||||||||||||
| 550 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
| 551 | if (siblings.size() > 1) {
| 0 | ||||||||||||||||||
| 552 | const QPoint referencePoint = window->transientParent() ? window->transientParent()->geometry().center() : QCursor::pos();
| 0 | ||||||||||||||||||
| 553 | foreach (const QScreen *sibling, siblings) | - | ||||||||||||||||||
| 554 | if (sibling->geometry().contains(referencePoint))
| 0 | ||||||||||||||||||
| 555 | return sibling; never executed: return sibling; | 0 | ||||||||||||||||||
| 556 | } never executed: end of block | 0 | ||||||||||||||||||
| 557 | #endif | - | ||||||||||||||||||
| 558 | return screen; never executed: return screen; | 0 | ||||||||||||||||||
| 559 | } | - | ||||||||||||||||||
| 560 | - | |||||||||||||||||||
| 561 | /*! | - | ||||||||||||||||||
| 562 | Invalidates the window's surface by releasing its surface buffers. | - | ||||||||||||||||||
| 563 | - | |||||||||||||||||||
| 564 | Many platforms do not support releasing the surface memory, | - | ||||||||||||||||||
| 565 | and the default implementation does nothing. | - | ||||||||||||||||||
| 566 | - | |||||||||||||||||||
| 567 | The platform window is expected to recreate the surface again if | - | ||||||||||||||||||
| 568 | it is needed. For instance, if an OpenGL context is made current | - | ||||||||||||||||||
| 569 | on this window. | - | ||||||||||||||||||
| 570 | */ | - | ||||||||||||||||||
| 571 | void QPlatformWindow::invalidateSurface() | - | ||||||||||||||||||
| 572 | { | - | ||||||||||||||||||
| 573 | } | - | ||||||||||||||||||
| 574 | - | |||||||||||||||||||
| 575 | static QSize fixInitialSize(QSize size, const QWindow *w, | - | ||||||||||||||||||
| 576 | int defaultWidth, int defaultHeight) | - | ||||||||||||||||||
| 577 | { | - | ||||||||||||||||||
| 578 | if (size.width() == 0) {
| 0 | ||||||||||||||||||
| 579 | const int minWidth = w->minimumWidth(); | - | ||||||||||||||||||
| 580 | size.setWidth(minWidth > 0 ? minWidth : defaultWidth); | - | ||||||||||||||||||
| 581 | } never executed: end of block | 0 | ||||||||||||||||||
| 582 | if (size.height() == 0) {
| 0 | ||||||||||||||||||
| 583 | const int minHeight = w->minimumHeight(); | - | ||||||||||||||||||
| 584 | size.setHeight(minHeight > 0 ? minHeight : defaultHeight); | - | ||||||||||||||||||
| 585 | } never executed: end of block | 0 | ||||||||||||||||||
| 586 | return size; never executed: return size; | 0 | ||||||||||||||||||
| 587 | } | - | ||||||||||||||||||
| 588 | - | |||||||||||||||||||
| 589 | /*! | - | ||||||||||||||||||
| 590 | Helper function to get initial geometry on windowing systems which do not | - | ||||||||||||||||||
| 591 | do smart positioning and also do not provide a means of centering a | - | ||||||||||||||||||
| 592 | transient window w.r.t. its parent. For example this is useful on Windows | - | ||||||||||||||||||
| 593 | and MacOS but not X11, because an X11 window manager typically tries to | - | ||||||||||||||||||
| 594 | layout new windows to optimize usage of the available desktop space. | - | ||||||||||||||||||
| 595 | However if the given window already has geometry which the application has | - | ||||||||||||||||||
| 596 | initialized, it takes priority. | - | ||||||||||||||||||
| 597 | */ | - | ||||||||||||||||||
| 598 | QRect QPlatformWindow::initialGeometry(const QWindow *w, | - | ||||||||||||||||||
| 599 | const QRect &initialGeometry, int defaultWidth, int defaultHeight) | - | ||||||||||||||||||
| 600 | { | - | ||||||||||||||||||
| 601 | if (!w->isTopLevel()) {
| 0 | ||||||||||||||||||
| 602 | const qreal factor = QHighDpiScaling::factor(w); | - | ||||||||||||||||||
| 603 | const QSize size = fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor), | - | ||||||||||||||||||
| 604 | w, defaultWidth, defaultHeight); | - | ||||||||||||||||||
| 605 | return QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor)); never executed: return QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor)); | 0 | ||||||||||||||||||
| 606 | } | - | ||||||||||||||||||
| 607 | const QScreen *screen = effectiveScreen(w); | - | ||||||||||||||||||
| 608 | if (!screen)
| 0 | ||||||||||||||||||
| 609 | return initialGeometry; never executed: return initialGeometry; | 0 | ||||||||||||||||||
| 610 | QRect rect(QHighDpi::fromNativePixels(initialGeometry, w)); | - | ||||||||||||||||||
| 611 | rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight)); | - | ||||||||||||||||||
| 612 | if (qt_window_private(const_cast<QWindow*>(w))->positionAutomatic
| 0 | ||||||||||||||||||
| 613 | && w->type() != Qt::Popup) {
| 0 | ||||||||||||||||||
| 614 | const QRect availableGeometry = screen->availableGeometry(); | - | ||||||||||||||||||
| 615 | // Center unless the geometry ( + unknown window frame) is too large for the screen). | - | ||||||||||||||||||
| 616 | if (rect.height() < (availableGeometry.height() * 8) / 9
| 0 | ||||||||||||||||||
| 617 | && rect.width() < (availableGeometry.width() * 8) / 9) {
| 0 | ||||||||||||||||||
| 618 | const QWindow *tp = w->transientParent(); | - | ||||||||||||||||||
| 619 | if (tp) {
| 0 | ||||||||||||||||||
| 620 | // A transient window should be centered w.r.t. its transient parent. | - | ||||||||||||||||||
| 621 | rect.moveCenter(tp->geometry().center()); | - | ||||||||||||||||||
| 622 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 623 | // Center the window on the screen. (Only applicable on platforms | - | ||||||||||||||||||
| 624 | // which do not provide a better way.) | - | ||||||||||||||||||
| 625 | rect.moveCenter(availableGeometry.center()); | - | ||||||||||||||||||
| 626 | } never executed: end of block | 0 | ||||||||||||||||||
| 627 | } | - | ||||||||||||||||||
| 628 | } never executed: end of block | 0 | ||||||||||||||||||
| 629 | return QHighDpi::toNativePixels(rect, screen); never executed: return QHighDpi::toNativePixels(rect, screen); | 0 | ||||||||||||||||||
| 630 | } | - | ||||||||||||||||||
| 631 | - | |||||||||||||||||||
| 632 | /*! | - | ||||||||||||||||||
| 633 | Requests an QEvent::UpdateRequest event. The event will be | - | ||||||||||||||||||
| 634 | delivered to the QWindow. | - | ||||||||||||||||||
| 635 | - | |||||||||||||||||||
| 636 | QPlatformWindow subclasses can re-implement this function to | - | ||||||||||||||||||
| 637 | provide display refresh synchronized updates. The event | - | ||||||||||||||||||
| 638 | should be delivered using QWindowPrivate::deliverUpdateRequest() | - | ||||||||||||||||||
| 639 | to not get out of sync with the the internal state of QWindow. | - | ||||||||||||||||||
| 640 | - | |||||||||||||||||||
| 641 | The default implementation posts an UpdateRequest event to the | - | ||||||||||||||||||
| 642 | window after 5 ms. The additional time is there to give the event | - | ||||||||||||||||||
| 643 | loop a bit of idle time to gather system events. | - | ||||||||||||||||||
| 644 | - | |||||||||||||||||||
| 645 | */ | - | ||||||||||||||||||
| 646 | void QPlatformWindow::requestUpdate() | - | ||||||||||||||||||
| 647 | { | - | ||||||||||||||||||
| 648 | static int timeout = -1; | - | ||||||||||||||||||
| 649 | if (timeout == -1) {
| 0 | ||||||||||||||||||
| 650 | bool ok = false; | - | ||||||||||||||||||
| 651 | timeout = qEnvironmentVariableIntValue("QT_QPA_UPDATE_IDLE_TIME", &ok); | - | ||||||||||||||||||
| 652 | if (!ok)
| 0 | ||||||||||||||||||
| 653 | timeout = 5; never executed: timeout = 5; | 0 | ||||||||||||||||||
| 654 | } never executed: end of block | 0 | ||||||||||||||||||
| 655 | - | |||||||||||||||||||
| 656 | QWindow *w = window(); | - | ||||||||||||||||||
| 657 | QWindowPrivate *wp = (QWindowPrivate *) QObjectPrivate::get(w); | - | ||||||||||||||||||
| 658 | Q_ASSERT(wp->updateTimer == 0); | - | ||||||||||||||||||
| 659 | wp->updateTimer = w->startTimer(timeout, Qt::PreciseTimer); | - | ||||||||||||||||||
| 660 | } never executed: end of block | 0 | ||||||||||||||||||
| 661 | - | |||||||||||||||||||
| 662 | /*! | - | ||||||||||||||||||
| 663 | Returns the QWindow minimum size. | - | ||||||||||||||||||
| 664 | */ | - | ||||||||||||||||||
| 665 | QSize QPlatformWindow::windowMinimumSize() const | - | ||||||||||||||||||
| 666 | { | - | ||||||||||||||||||
| 667 | return constrainWindowSize(QHighDpi::toNativePixels(window()->minimumSize(), window())); never executed: return constrainWindowSize(QHighDpi::toNativePixels(window()->minimumSize(), window())); | 0 | ||||||||||||||||||
| 668 | } | - | ||||||||||||||||||
| 669 | - | |||||||||||||||||||
| 670 | /*! | - | ||||||||||||||||||
| 671 | Returns the QWindow maximum size. | - | ||||||||||||||||||
| 672 | */ | - | ||||||||||||||||||
| 673 | QSize QPlatformWindow::windowMaximumSize() const | - | ||||||||||||||||||
| 674 | { | - | ||||||||||||||||||
| 675 | return constrainWindowSize(QHighDpi::toNativePixels(window()->maximumSize(), window())); never executed: return constrainWindowSize(QHighDpi::toNativePixels(window()->maximumSize(), window())); | 0 | ||||||||||||||||||
| 676 | } | - | ||||||||||||||||||
| 677 | - | |||||||||||||||||||
| 678 | /*! | - | ||||||||||||||||||
| 679 | Returns the QWindow base size. | - | ||||||||||||||||||
| 680 | */ | - | ||||||||||||||||||
| 681 | QSize QPlatformWindow::windowBaseSize() const | - | ||||||||||||||||||
| 682 | { | - | ||||||||||||||||||
| 683 | return QHighDpi::toNativePixels(window()->baseSize(), window()); never executed: return QHighDpi::toNativePixels(window()->baseSize(), window()); | 0 | ||||||||||||||||||
| 684 | } | - | ||||||||||||||||||
| 685 | - | |||||||||||||||||||
| 686 | /*! | - | ||||||||||||||||||
| 687 | Returns the QWindow size increment. | - | ||||||||||||||||||
| 688 | */ | - | ||||||||||||||||||
| 689 | QSize QPlatformWindow::windowSizeIncrement() const | - | ||||||||||||||||||
| 690 | { | - | ||||||||||||||||||
| 691 | QSize increment = window()->sizeIncrement(); | - | ||||||||||||||||||
| 692 | if (!QHighDpiScaling::isActive())
| 0 | ||||||||||||||||||
| 693 | return increment; never executed: return increment; | 0 | ||||||||||||||||||
| 694 | - | |||||||||||||||||||
| 695 | // Normalize the increment. If not set the increment can be | - | ||||||||||||||||||
| 696 | // (-1, -1) or (0, 0). Make that (1, 1) which is scalable. | - | ||||||||||||||||||
| 697 | if (increment.isEmpty())
| 0 | ||||||||||||||||||
| 698 | increment = QSize(1, 1); never executed: increment = QSize(1, 1); | 0 | ||||||||||||||||||
| 699 | - | |||||||||||||||||||
| 700 | return QHighDpi::toNativePixels(increment, window()); never executed: return QHighDpi::toNativePixels(increment, window()); | 0 | ||||||||||||||||||
| 701 | } | - | ||||||||||||||||||
| 702 | - | |||||||||||||||||||
| 703 | /*! | - | ||||||||||||||||||
| 704 | Returns the QWindow geometry. | - | ||||||||||||||||||
| 705 | */ | - | ||||||||||||||||||
| 706 | QRect QPlatformWindow::windowGeometry() const | - | ||||||||||||||||||
| 707 | { | - | ||||||||||||||||||
| 708 | return QHighDpi::toNativePixels(window()->geometry(), window()); never executed: return QHighDpi::toNativePixels(window()->geometry(), window()); | 0 | ||||||||||||||||||
| 709 | } | - | ||||||||||||||||||
| 710 | - | |||||||||||||||||||
| 711 | /*! | - | ||||||||||||||||||
| 712 | Returns the QWindow frame geometry. | - | ||||||||||||||||||
| 713 | */ | - | ||||||||||||||||||
| 714 | QRect QPlatformWindow::windowFrameGeometry() const | - | ||||||||||||||||||
| 715 | { | - | ||||||||||||||||||
| 716 | return QHighDpi::toNativePixels(window()->frameGeometry(), window()); never executed: return QHighDpi::toNativePixels(window()->frameGeometry(), window()); | 0 | ||||||||||||||||||
| 717 | } | - | ||||||||||||||||||
| 718 | - | |||||||||||||||||||
| 719 | /*! | - | ||||||||||||||||||
| 720 | Returns the closest acceptable geometry for a given geometry before | - | ||||||||||||||||||
| 721 | a resize/move event for platforms that support it, for example to | - | ||||||||||||||||||
| 722 | implement heightForWidth(). | - | ||||||||||||||||||
| 723 | */ | - | ||||||||||||||||||
| 724 | - | |||||||||||||||||||
| 725 | QRectF QPlatformWindow::closestAcceptableGeometry(const QWindow *qWindow, const QRectF &nativeRect) | - | ||||||||||||||||||
| 726 | { | - | ||||||||||||||||||
| 727 | const QRectF rectF = QHighDpi::fromNativePixels(nativeRect, qWindow); | - | ||||||||||||||||||
| 728 | const QRectF correctedGeometryF = qt_window_private(const_cast<QWindow *>(qWindow))->closestAcceptableGeometry(rectF); | - | ||||||||||||||||||
| 729 | return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF never executed: return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF ? QHighDpi::toNativePixels(correctedGeometryF, qWindow) : nativeRect;
| 0 | ||||||||||||||||||
| 730 | ? QHighDpi::toNativePixels(correctedGeometryF, qWindow) : nativeRect; never executed: return !correctedGeometryF.isEmpty() && rectF != correctedGeometryF ? QHighDpi::toNativePixels(correctedGeometryF, qWindow) : nativeRect; | 0 | ||||||||||||||||||
| 731 | } | - | ||||||||||||||||||
| 732 | - | |||||||||||||||||||
| 733 | QRectF QPlatformWindow::windowClosestAcceptableGeometry(const QRectF &nativeRect) const | - | ||||||||||||||||||
| 734 | { | - | ||||||||||||||||||
| 735 | return QPlatformWindow::closestAcceptableGeometry(window(), nativeRect); never executed: return QPlatformWindow::closestAcceptableGeometry(window(), nativeRect); | 0 | ||||||||||||||||||
| 736 | } | - | ||||||||||||||||||
| 737 | - | |||||||||||||||||||
| 738 | /*! | - | ||||||||||||||||||
| 739 | \class QPlatformWindow | - | ||||||||||||||||||
| 740 | \since 4.8 | - | ||||||||||||||||||
| 741 | \internal | - | ||||||||||||||||||
| 742 | \preliminary | - | ||||||||||||||||||
| 743 | \ingroup qpa | - | ||||||||||||||||||
| 744 | - | |||||||||||||||||||
| 745 | \brief The QPlatformWindow class provides an abstraction for top-level windows. | - | ||||||||||||||||||
| 746 | - | |||||||||||||||||||
| 747 | The QPlatformWindow abstraction is used by QWindow for all its top level windows. It is being | - | ||||||||||||||||||
| 748 | created by calling the createPlatformWindow function in the loaded QPlatformIntegration | - | ||||||||||||||||||
| 749 | instance. | - | ||||||||||||||||||
| 750 | - | |||||||||||||||||||
| 751 | QPlatformWindow is used to signal to the windowing system, how Qt perceives its frame. | - | ||||||||||||||||||
| 752 | However, it is not concerned with how Qt renders into the window it represents. | - | ||||||||||||||||||
| 753 | - | |||||||||||||||||||
| 754 | Visible QWindows will always have a QPlatformWindow. However, it is not necessary for | - | ||||||||||||||||||
| 755 | all windows to have a QBackingStore. This is the case for QOpenGLWidget. And could be the case for | - | ||||||||||||||||||
| 756 | windows where some 3.party renders into it. | - | ||||||||||||||||||
| 757 | - | |||||||||||||||||||
| 758 | The platform specific window handle can be retrieved by the winId function. | - | ||||||||||||||||||
| 759 | - | |||||||||||||||||||
| 760 | QPlatformWindow is also the way QPA defines how native child windows should be supported | - | ||||||||||||||||||
| 761 | through the setParent function. | - | ||||||||||||||||||
| 762 | - | |||||||||||||||||||
| 763 | \section1 Implementation Aspects | - | ||||||||||||||||||
| 764 | - | |||||||||||||||||||
| 765 | \list 1 | - | ||||||||||||||||||
| 766 | \li Mouse grab: Qt expects windows to automatically grab the mouse if the user presses | - | ||||||||||||||||||
| 767 | a button until the button is released. | - | ||||||||||||||||||
| 768 | Automatic grab should be released if some window is explicitly grabbed. | - | ||||||||||||||||||
| 769 | \li Enter/Leave events: If there is a window explicitly grabbing mouse events | - | ||||||||||||||||||
| 770 | (\c{setMouseGrabEnabled()}), enter and leave events should only be sent to the | - | ||||||||||||||||||
| 771 | grabbing window when mouse cursor passes over the grabbing window boundary. | - | ||||||||||||||||||
| 772 | Other windows will not receive enter or leave events while the grab is active. | - | ||||||||||||||||||
| 773 | While an automatic mouse grab caused by a mouse button press is active, no window | - | ||||||||||||||||||
| 774 | will receive enter or leave events. When the last mouse button is released, the | - | ||||||||||||||||||
| 775 | autograbbing window will receive leave event if mouse cursor is no longer within | - | ||||||||||||||||||
| 776 | the window boundary. | - | ||||||||||||||||||
| 777 | When any grab starts, the window under cursor will receive a leave event unless | - | ||||||||||||||||||
| 778 | it is the grabbing window. | - | ||||||||||||||||||
| 779 | When any grab ends, the window under cursor will receive an enter event unless it | - | ||||||||||||||||||
| 780 | was the grabbing window. | - | ||||||||||||||||||
| 781 | \li Window positioning: When calling \c{QWindow::setFramePosition()}, the flag | - | ||||||||||||||||||
| 782 | \c{QWindowPrivate::positionPolicy} is set to \c{QWindowPrivate::WindowFrameInclusive}. | - | ||||||||||||||||||
| 783 | This means the position includes the window frame, whose size is at this point | - | ||||||||||||||||||
| 784 | unknown and the geometry's topleft point is the position of the window frame. | - | ||||||||||||||||||
| 785 | \endlist | - | ||||||||||||||||||
| 786 | - | |||||||||||||||||||
| 787 | Apart from the auto-tests (\c{tests/auto/gui/kernel/qwindow}, | - | ||||||||||||||||||
| 788 | \c{tests/auto/gui/kernel/qguiapplication} and \c{tests/auto/widgets/kernel/qwidget}), | - | ||||||||||||||||||
| 789 | there are a number of manual tests and examples that can help testing a platform plugin: | - | ||||||||||||||||||
| 790 | - | |||||||||||||||||||
| 791 | \list 1 | - | ||||||||||||||||||
| 792 | \li \c{examples/qpa/windows}: Basic \c{QWindow} creation. | - | ||||||||||||||||||
| 793 | \li \c{examples/opengl/hellowindow}: Basic Open GL windows. | - | ||||||||||||||||||
| 794 | \li \c{tests/manual/windowflags}: Tests setting the window flags. | - | ||||||||||||||||||
| 795 | \li \c{tests/manual/windowgeometry} Tests setting the window geometry. | - | ||||||||||||||||||
| 796 | \li \c{tests/manual/windowmodality} Tests setting the window modality. | - | ||||||||||||||||||
| 797 | \li \c{tests/manual/widgetgrab} Tests mouse grab and dialogs. | - | ||||||||||||||||||
| 798 | \endlist | - | ||||||||||||||||||
| 799 | - | |||||||||||||||||||
| 800 | \sa QBackingStore, QWindow | - | ||||||||||||||||||
| 801 | */ | - | ||||||||||||||||||
| 802 | - | |||||||||||||||||||
| 803 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |