diff options
author | Liang Qi <liang.qi@qt.io> | 2020-02-13 09:14:09 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-02-13 18:31:40 +0100 |
commit | 6b2535ea15cdbdb2355416b604f072fc13ff36b2 (patch) | |
tree | 4bf1560bab77c8b315850c5337ba31a0ea87b5f0 /src/gui/kernel/qwindow.cpp | |
parent | 54c2cebabdda0280b8443c6947b6fee02445e138 (diff) | |
parent | 67491e2df5357706dbf88ddaf1f030ff095b4528 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
examples/widgets/graphicsview/boxes/scene.h
src/corelib/Qt5CoreMacros.cmake
src/corelib/Qt6CoreMacros.cmake
src/network/ssl/qsslsocket.cpp
src/network/ssl/qsslsocket.h
src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
src/testlib/CMakeLists.txt
src/testlib/.prev_CMakeLists.txt
tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp
Disabled building manual tests with CMake for now, because qmake
doesn't do it, and it confuses people.
Done-With: Alexandru Croitor <alexandru.croitor@qt.io>
Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io>
Change-Id: I865ae347bd01f4e59f16d007b66d175a52f1f152
Diffstat (limited to 'src/gui/kernel/qwindow.cpp')
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index dad1b6ba2d..c099ec9692 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1051,6 +1051,71 @@ void QWindow::lower() } /*! + \brief Start a system-specific resize operation + \since 5.15 + + Calling this will start an interactive resize operation on the window by platforms + that support it. The actual behavior may vary depending on the platform. Usually, + it will make the window resize so that its edge follows the mouse cursor. + + On platforms that support it, this method of resizing windows is preferred over + \c setGeometry, because it allows a more native look-and-feel of resizing windows, e.g. + letting the window manager snap this window against other windows, or special resizing + behavior with animations when dragged to the edge of the screen. + + \a edges should either be a single edge, or two adjacent edges (a corner). Other values + are not allowed. + + Returns true if the operation was supported by the system. +*/ +bool QWindow::startSystemResize(Qt::Edges edges) +{ + Q_D(QWindow); + if (Q_UNLIKELY(!isVisible() || !d->platformWindow || d->maximumSize == d->minimumSize)) + return false; + + const bool isSingleEdge = edges == Qt::TopEdge || edges == Qt::RightEdge || edges == Qt::BottomEdge || edges == Qt::LeftEdge; + const bool isCorner = + edges == (Qt::TopEdge | Qt::LeftEdge) || + edges == (Qt::TopEdge | Qt::RightEdge) || + edges == (Qt::BottomEdge | Qt::RightEdge) || + edges == (Qt::BottomEdge | Qt::LeftEdge); + + if (Q_UNLIKELY(!isSingleEdge && !isCorner)) { + qWarning() << "Invalid edges" << edges << "passed to QWindow::startSystemResize, ignoring."; + return false; + } + + return d->platformWindow->startSystemResize(edges); +} + +/*! + \brief Start a system-specific move operation + \since 5.15 + + Calling this will start an interactive move operation on the window by platforms + that support it. The actual behavior may vary depending on the platform. Usually, + it will make the window follow the mouse cursor until a mouse button is released. + + On platforms that support it, this method of moving windows is preferred over + \c setPosition, because it allows a more native look-and-feel of moving windows, e.g. + letting the window manager snap this window against other windows, or special tiling + or resizing behavior with animations when dragged to the edge of the screen. + Furthermore, on some platforms such as Wayland, \c setPosition is not supported, so + this is the only way the application can influence its position. + + Returns true if the operation was supported by the system. +*/ +bool QWindow::startSystemMove() +{ + Q_D(QWindow); + if (Q_UNLIKELY(!isVisible() || !d->platformWindow)) + return false; + + return d->platformWindow->startSystemMove(); +} + +/*! \property QWindow::opacity \brief The opacity of the window in the windowing system. \since 5.1 @@ -1793,7 +1858,10 @@ void QWindow::setFramePosition(const QPoint &point) The position is in relation to the virtualGeometry() of its screen. - \sa position() + For interactively moving windows, see startSystemMove(). For interactively + resizing windows, see startSystemResize(). + + \sa position(), startSystemMove() */ void QWindow::setPosition(const QPoint &pt) { @@ -1830,6 +1898,8 @@ void QWindow::setPosition(int posx, int posy) set the size of the window, excluding any window frame, to a QSize constructed from width \a w and height \a h + For interactively resizing windows, see startSystemResize(). + \sa size(), geometry() */ void QWindow::resize(int w, int h) |