Commit f4dbec3f authored by Méven Car's avatar Méven Car Committed by Méven Car
Browse files

Allow to use Immediate Shutter mode in Plasma 5.19.80+

parent a5149896
...@@ -91,9 +91,10 @@ Platform::GrabModes PlatformKWinWayland::supportedGrabModes() const ...@@ -91,9 +91,10 @@ Platform::GrabModes PlatformKWinWayland::supportedGrabModes() const
return lSupportedModes; return lSupportedModes;
} }
static QPair<int,int> s_plasmaVersion = {-1, -1}; static std::array<int, 3> s_plasmaVersion = {-1, -1, -1};
QPair<int, int> findPlasmaMinorVersion () {
if (s_plasmaVersion == QPair<int, int>(-1, -1)) { std::array<int, 3> findPlasmaMinorVersion () {
if (s_plasmaVersion == std::array<int, 3>{-1, -1, -1}) {
auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"),
QStringLiteral("/MainApplication"), QStringLiteral("/MainApplication"),
QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("org.freedesktop.DBus.Properties"),
...@@ -125,7 +126,12 @@ QPair<int, int> findPlasmaMinorVersion () { ...@@ -125,7 +126,12 @@ QPair<int, int> findPlasmaMinorVersion () {
qWarning() << "error parsing plasma minor version"; qWarning() << "error parsing plasma minor version";
return s_plasmaVersion; 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; return s_plasmaVersion;
} }
...@@ -134,7 +140,7 @@ Platform::ShutterModes PlatformKWinWayland::supportedShutterModes() const ...@@ -134,7 +140,7 @@ Platform::ShutterModes PlatformKWinWayland::supportedShutterModes() const
{ {
// TODO remove sometime after Plasma 5.20 is released // TODO remove sometime after Plasma 5.20 is released
auto plasmaVersion = findPlasmaMinorVersion(); 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 }; return { ShutterMode::Immediate | ShutterMode::OnClick };
} else { } else {
return { ShutterMode::OnClick }; return { ShutterMode::OnClick };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment