diff options
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qcursor.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qcursor.h | 8 | ||||
-rw-r--r-- | src/gui/kernel/qhighdpiscaling.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qpixelformat.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 29 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 72 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.h | 2 |
9 files changed, 96 insertions, 29 deletions
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 7f6fdafbd0..1efa28a5af 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -621,7 +621,7 @@ const QBitmap *QCursor::mask() const QBitmap bmpVal = cursor->bitmap(); \endcode */ -QBitmap QCursor::bitmap(Qt::ReturnByValue_t) const +QBitmap QCursor::bitmap(Qt::ReturnByValueConstant) const { if (!QCursorData::initialized) QCursorData::initialize(); @@ -653,7 +653,7 @@ QBitmap QCursor::bitmap(Qt::ReturnByValue_t) const QBitmap bmpVal = cursor->mask(); \endcode */ -QBitmap QCursor::mask(Qt::ReturnByValue_t) const +QBitmap QCursor::mask(Qt::ReturnByValueConstant) const { if (!QCursorData::initialized) QCursorData::initialize(); diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h index 7a11fe59ee..3ae6b98ced 100644 --- a/src/gui/kernel/qcursor.h +++ b/src/gui/kernel/qcursor.h @@ -104,11 +104,11 @@ public: QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QBitmap by-value") const QBitmap *mask() const; // ### Qt 7: Remove function - QBitmap bitmap(Qt::ReturnByValue_t) const; - QBitmap mask(Qt::ReturnByValue_t) const; + QBitmap bitmap(Qt::ReturnByValueConstant) const; + QBitmap mask(Qt::ReturnByValueConstant) const; #else - QBitmap bitmap(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg - QBitmap mask(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg + QBitmap bitmap(Qt::ReturnByValueConstant = Qt::ReturnByValue) const; // ### Qt 7: Remove arg + QBitmap mask(Qt::ReturnByValueConstant = Qt::ReturnByValue) const; // ### Qt 7: Remove arg #endif // QT_DEPRECATED_SINCE(5, 15) QPixmap pixmap() const; QPoint hotSpot() const; diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index fde6bb0180..671c2d93ef 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -535,7 +535,7 @@ void QHighDpiScaling::updateHighDpiScaling() ++i; } } - m_active = m_globalScalingActive || m_screenFactorSet || m_usePixelDensity; + m_active = m_globalScalingActive || m_screenFactorSet || m_pixelDensityScalingActive; } /* diff --git a/src/gui/kernel/qpixelformat.cpp b/src/gui/kernel/qpixelformat.cpp index c28fe7ac63..3100d13398 100644 --- a/src/gui/kernel/qpixelformat.cpp +++ b/src/gui/kernel/qpixelformat.cpp @@ -485,7 +485,7 @@ QT_BEGIN_NAMESPACE /*! \fn ByteOrder QPixelFormat::byteOrder() const - The byte order is almost always set the the byte order of the current + The byte order is almost always set the byte order of the current system. However, it can be useful to describe some YUV formats. This function should never return QPixelFormat::CurrentSystemEndian as this value is translated to a endian value in the constructor. diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 65accc9f68..15d7505133 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -482,19 +482,17 @@ bool QPlatformWindow::windowEvent(QEvent *event) } /*! - Reimplement this method to start a system size grip drag - operation if the system supports it and return true to indicate - success. - It is called from the mouse press event handler of the size grip. + Reimplement this method to start a system resize operation if + the system supports it and return true to indicate success. + + The default implementation is empty and does nothing with \a edges. - The default implementation is empty and does nothing with \a pos - and \a corner. + \since 5.15 */ -bool QPlatformWindow::startSystemResize(const QPoint &pos, Qt::Corner corner) +bool QPlatformWindow::startSystemResize(Qt::Edges edges) { - Q_UNUSED(pos) - Q_UNUSED(corner) + Q_UNUSED(edges) return false; } @@ -502,18 +500,13 @@ bool QPlatformWindow::startSystemResize(const QPoint &pos, Qt::Corner corner) Reimplement this method to start a system move operation if the system supports it and return true to indicate success. - The \a pos is a position of MouseButtonPress event or TouchBegin - event from a sequence of mouse events that triggered the movement. - It must be specified in window coordinates. - - The default implementation is empty and does nothing with \a pos. + The default implementation is empty and does nothing. - \since 5.11 + \since 5.15 */ -bool QPlatformWindow::startSystemMove(const QPoint &pos) +bool QPlatformWindow::startSystemMove() { - Q_UNUSED(pos) return false; } @@ -747,7 +740,7 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeo QPlatformWindow subclasses can re-implement this function to provide display refresh synchronized updates. The event should be delivered using QPlatformWindow::deliverUpdateRequest() - to not get out of sync with the the internal state of QWindow. + to not get out of sync with the internal state of QWindow. The default implementation posts an UpdateRequest event to the window after 5 ms. The additional time is there to give the event diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index b6aeb3a86a..7b85090cc0 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -132,8 +132,8 @@ public: virtual bool windowEvent(QEvent *event); - virtual bool startSystemResize(const QPoint &pos, Qt::Corner corner); - virtual bool startSystemMove(const QPoint &pos); + virtual bool startSystemResize(Qt::Edges edges); + virtual bool startSystemMove(); virtual void setFrameStrutEventsEnabled(bool enabled); virtual bool frameStrutEventsEnabled() const; diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 9de59f8c7e..fd25becbca 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -149,6 +149,8 @@ QScreen::~QScreen() /*! Get the platform screen handle. + + \sa {Qt Platform Abstraction}{Qt Platform Abstraction (QPA)} */ QPlatformScreen *QScreen::handle() const { 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) diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 5ee1d00f5b..7aae7ffffa 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -292,6 +292,8 @@ public Q_SLOTS: bool close(); void raise(); void lower(); + bool startSystemResize(Qt::Edges edges); + bool startSystemMove(); void setTitle(const QString &); |