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