diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 1427db5c614..c6382243b91 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -260,6 +260,10 @@ QPlatformServices *QPlatformIntegration::services() const where there is an alternative, such as Qt Quick with its \c software backend, an automatic fallback to that alternative may occur, if applicable. The default implementation of hasCapability() returns \c true. + + \value ScreenWindowGrabbing The platform supports grabbing window on screen. + On Wayland, this capability can be reported as \c false. The default implementation + of hasCapability() returns \c true. */ /*! @@ -284,7 +288,8 @@ QPlatformServices *QPlatformIntegration::services() const bool QPlatformIntegration::hasCapability(Capability cap) const { return cap == NonFullScreenWindows || cap == NativeWidgets || cap == WindowManagement - || cap == TopStackedNativeChildWindows || cap == WindowActivation || cap == RhiBasedRendering; + || cap == TopStackedNativeChildWindows || cap == WindowActivation + || cap == RhiBasedRendering || cap == ScreenWindowGrabbing; } QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 75b942f9988..d76aeee59e9 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -133,7 +133,8 @@ public: OpenGLOnRasterSurface, MaximizeUsingFullscreenGeometry, PaintEvents, - RhiBasedRendering + RhiBasedRendering, + ScreenWindowGrabbing // whether QScreen::grabWindow() is supported }; virtual ~QPlatformIntegration() { } diff --git a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp index c29162ee67a..ea644e2e2b1 100644 --- a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp +++ b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -205,6 +207,10 @@ void tst_QScreen::orientationChange() void tst_QScreen::grabWindow_data() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability( + QPlatformIntegration::ScreenWindowGrabbing)) { + QSKIP("This platform does not support grabbing windows on screen."); + } QTest::addColumn("screenIndex"); QTest::addColumn("screenName"); QTest::addColumn("grabWindow"); @@ -302,8 +308,6 @@ void tst_QScreen::grabWindow() QImage grabbedImage = pixmap.toImage(); const QSize grabbedSize = grabbedImage.size(); - if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) - QEXPECT_FAIL("", "Wayland: Screen grabbing not implemented, See QTBUG-100792.", Abort); QCOMPARE(grabbedSize, expectedGrabSize); QPoint pixelOffset = QPoint(0, 0);