diff --git a/src/Platforms/PlatformKWinWayland.cpp b/src/Platforms/PlatformKWinWayland.cpp --- a/src/Platforms/PlatformKWinWayland.cpp +++ b/src/Platforms/PlatformKWinWayland.cpp @@ -91,18 +91,46 @@ return lSupportedModes; } +static int s_plasmaMinorVersion = -1; +int findPlasmaMinorVersion () { + if (s_plasmaMinorVersion == -1) { + QDBusInterface remoteApp( QStringLiteral("org.kde.plasmashell"), + QStringLiteral("/MainApplication"), + QStringLiteral("org.qtproject.Qt.QCoreApplication")); + QVariant reply = remoteApp.property("applicationVersion"); + + if (!reply.isValid()) { + qWarning() << "error querying plasma version"; + return -1; + } + const QString rawVersion = reply.value(); + const QStringList splitted = rawVersion.split(QLatin1Char('.')); + if (splitted.size() != 3) { + qWarning() << "error parsing plasma version"; + return -1; + } + bool ok; + int s_plasmaMinorVersion = splitted[1].toInt(&ok); + if (!ok) { + s_plasmaMinorVersion = -1; + qWarning() << "error parsing plasma version"; + } + } + return s_plasmaMinorVersion; +} + Platform::ShutterModes PlatformKWinWayland::supportedShutterModes() const { - return { ShutterMode::OnClick }; + // TODO remove sometime after Plasma 5.20 is released + if (findPlasmaMinorVersion() >= 20) { + return { ShutterMode::Immediate | ShutterMode::OnClick }; + } else { + return { ShutterMode::OnClick }; + } } void PlatformKWinWayland::doGrab(ShutterMode theShutterMode, GrabMode theGrabMode, bool theIncludePointer, bool theIncludeDecorations) { - if (theShutterMode != ShutterMode::OnClick) { - emit newScreenshotFailed(); - return; - } - switch(theGrabMode) { case GrabMode::AllScreens: { doGrabHelper(QStringLiteral("screenshotFullscreen"), theIncludePointer);