From f4dbec3f8ffdd7feb5538837e1d12bf75b1c1107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Fri, 7 Aug 2020 14:29:44 +0200 Subject: [PATCH] Allow to use Immediate Shutter mode in Plasma 5.19.80+ --- src/Platforms/PlatformKWinWayland.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Platforms/PlatformKWinWayland.cpp b/src/Platforms/PlatformKWinWayland.cpp index e2c85f4..85e547a 100644 --- a/src/Platforms/PlatformKWinWayland.cpp +++ b/src/Platforms/PlatformKWinWayland.cpp @@ -91,9 +91,10 @@ Platform::GrabModes PlatformKWinWayland::supportedGrabModes() const return lSupportedModes; } -static QPair s_plasmaVersion = {-1, -1}; -QPair findPlasmaMinorVersion () { - if (s_plasmaVersion == QPair(-1, -1)) { +static std::array s_plasmaVersion = {-1, -1, -1}; + +std::array findPlasmaMinorVersion () { + if (s_plasmaVersion == std::array{-1, -1, -1}) { auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), QStringLiteral("/MainApplication"), QStringLiteral("org.freedesktop.DBus.Properties"), @@ -125,7 +126,12 @@ QPair findPlasmaMinorVersion () { qWarning() << "error parsing plasma minor version"; return s_plasmaVersion; } - s_plasmaVersion = {plasmaMajorVersion, plasmaMinorVersion}; + int plasmaPatchVersion = splitted[2].toInt(&ok); + if (!ok) { + qWarning() << "error parsing plasma patch version"; + return s_plasmaVersion; + } + s_plasmaVersion = {plasmaMajorVersion, plasmaMinorVersion, plasmaPatchVersion}; } return s_plasmaVersion; } @@ -134,7 +140,7 @@ Platform::ShutterModes PlatformKWinWayland::supportedShutterModes() const { // TODO remove sometime after Plasma 5.20 is released auto plasmaVersion = findPlasmaMinorVersion(); - if (plasmaVersion.first != -1 && (plasmaVersion.first != 5 || plasmaVersion.second >= 20)) { + if (plasmaVersion.at(0) != -1 && (plasmaVersion.at(0) != 5 || (plasmaVersion.at(1) >= 20 || (plasmaVersion.at(1) == 19 && plasmaVersion.at(2) >= 80)))) { return { ShutterMode::Immediate | ShutterMode::OnClick }; } else { return { ShutterMode::OnClick }; -- GitLab