diff options
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qhighdpiscaling_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformintegration.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qplatformscreen.cpp | 11 | ||||
-rw-r--r-- | src/gui/kernel/qplatformscreen.h | 12 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.cpp | 19 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qtestsupport_gui.cpp | 13 |
8 files changed, 60 insertions, 5 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 54f3996b6e..f09f7e941b 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1040,7 +1040,9 @@ QList<QScreen *> QGuiApplication::screens() The \a point is in relation to the virtualGeometry() of each set of virtual siblings. If the point maps to more than one set of virtual siblings the first - match is returned. + match is returned. If you wish to search only the virtual desktop siblings + of a known screen (for example siblings of the screen of your application + window \c QWidget::windowHandle()->screen()), use QScreen::virtualSiblingAt(). \since 5.10 */ diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index f58944a7d2..3c85481495 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -313,7 +313,7 @@ public: static inline QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *) { return pos; } static inline QPoint mapPositionToGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window) { return pos; } static inline QPoint mapPositionFromGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window) { return pos; } - static inline QDpi logicalDpi() { return QDpi(-1,-1); } + static inline QDpi logicalDpi(const QScreen *screen) { return QDpi(-1,-1); } }; namespace QHighDpi { diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index d9f349555a..01406958e2 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -106,7 +106,8 @@ public: ApplicationIcon, SwitchableWidgetComposition, TopStackedNativeChildWindows, - OpenGLOnRasterSurface + OpenGLOnRasterSurface, + MaximizeUsingFullscreenGeometry }; virtual ~QPlatformIntegration() { } diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index f3213bf5ea..7daf48b191 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -410,15 +410,22 @@ void QPlatformScreen::resizeMaximizedWindows() const QRect newGeometry = deviceIndependentGeometry(); const QRect newAvailableGeometry = QHighDpi::fromNative(availableGeometry(), QHighDpiScaling::factor(this), newGeometry.topLeft()); + const bool supportsMaximizeUsingFullscreen = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MaximizeUsingFullscreenGeometry); + for (QWindow *w : windows()) { // Skip non-platform windows, e.g., offscreen windows. if (!w->handle()) continue; - if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) + if (supportsMaximizeUsingFullscreen + && w->windowState() & Qt::WindowMaximized + && w->flags() & Qt::MaximizeUsingFullscreenGeometryHint) { + w->setGeometry(newGeometry); + } else if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) { w->setGeometry(newAvailableGeometry); - else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) + } else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) { w->setGeometry(newGeometry); + } } } diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index d7378aed51..e27355a940 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -105,6 +105,8 @@ public: QPlatformScreen(); virtual ~QPlatformScreen(); + virtual bool isPlaceholder() const { return false; }; + virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; virtual QRect geometry() const = 0; @@ -172,6 +174,16 @@ private: friend class QScreenPrivate; }; +// Qt doesn't currently support running with no platform screen +// QPA plugins can use this class to create a fake screen +class QPlatformPlaceholderScreen : public QPlatformScreen { + bool isPlaceholder() const override { return true; }; + QRect geometry() const override { return QRect(); } + QRect availableGeometry() const override { return QRect(); } + int depth() const override { return 32; } + QImage::Format format() const override { return QImage::Format::Format_RGB32; } +}; + QT_END_NAMESPACE #endif // QPLATFORMSCREEN_H diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 7adf3db1b8..80de561297 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -700,6 +700,25 @@ void QScreenPrivate::updatePrimaryOrientation() } /*! + Returns the screen at \a point within the set of \l QScreen::virtualSiblings(), + or \c nullptr if outside of any screen. + + The \a point is in relation to the virtualGeometry() of each set of virtual + siblings. + + \since 5.15 +*/ +QScreen *QScreen::virtualSiblingAt(const QPoint &point) +{ + const auto &siblings = virtualSiblings(); + for (QScreen *sibling : siblings) { + if (sibling->geometry().contains(point)) + return sibling; + } + return nullptr; +} + +/*! Creates and returns a pixmap constructed by grabbing the contents of the given \a window restricted by QRect(\a x, \a y, \a width, \a height). diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h index 14392d3036..88925ab731 100644 --- a/src/gui/kernel/qscreen.h +++ b/src/gui/kernel/qscreen.h @@ -125,6 +125,7 @@ public: QRect availableGeometry() const; QList<QScreen *> virtualSiblings() const; + QScreen *virtualSiblingAt(const QPoint &point); QSize virtualSize() const; QRect virtualGeometry() const; diff --git a/src/gui/kernel/qtestsupport_gui.cpp b/src/gui/kernel/qtestsupport_gui.cpp index 7aad4d8c7d..79da26f2ca 100644 --- a/src/gui/kernel/qtestsupport_gui.cpp +++ b/src/gui/kernel/qtestsupport_gui.cpp @@ -37,10 +37,15 @@ ** ****************************************************************************/ +#include <private/qguiapplication_p.h> + +#include <qpa/qplatformintegration.h> + #include "qtestsupport_gui.h" #include "qwindow.h" #include <QtCore/qtestsupport_core.h> +#include <QtCore/QDebug> QT_BEGIN_NAMESPACE @@ -55,6 +60,14 @@ QT_BEGIN_NAMESPACE */ Q_GUI_EXPORT bool QTest::qWaitForWindowActive(QWindow *window, int timeout) { + if (Q_UNLIKELY(!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))) { + qWarning() << "qWaitForWindowActive was called on a platform that doesn't support window" + << "activation. This means there is an error in the test and it should either" + << "check for the WindowActivation platform capability before calling" + << "qWaitForWindowActivate, use qWaitForWindowExposed instead, or skip the test." + << "Falling back to qWaitForWindowExposed."; + return qWaitForWindowExposed(window, timeout); + } return QTest::qWaitFor([&]() { return window->isActive(); }, timeout); } |