diff --git a/powerdevil-5.2.1-fix-kded5-cpu-usage.patch b/powerdevil-5.2.1-fix-kded5-cpu-usage.patch deleted file mode 100644 index 6ab9913..0000000 --- a/powerdevil-5.2.1-fix-kded5-cpu-usage.patch +++ /dev/null @@ -1,330 +0,0 @@ -commit 2c2c13751e19b0a37bb8b41096b08f80383e61df -Author: Kai Uwe Broulik -Date: Thu Jan 29 22:46:36 2015 +0100 - - Fix PowerDevil brightness calls breaking kded, Volume 3521 - - Query both brightness and maximum only once and then only listen to udev change - events and just kick off the set job and forget about it. That way we do not have - nested event loops outside the init method anymore. - - BUG: 337674 - FIXED-IN: 5.2.1 - - This prevents re-entrancy issues - -diff --git a/daemon/actions/bundled/brightnesscontrol.cpp b/daemon/actions/bundled/brightnesscontrol.cpp -index 692a643..af6ad68 100644 ---- a/daemon/actions/bundled/brightnesscontrol.cpp -+++ b/daemon/actions/bundled/brightnesscontrol.cpp -@@ -107,15 +107,18 @@ void BrightnessControl::onProfileLoad() - - void BrightnessControl::triggerImpl(const QVariantMap& args) - { -+ int newBrightness = -1; - if (args.contains("Step")) { - backend()->setBrightnessStep(args["Step"].toInt()); - } else if ((QMetaType::Type) args["Value"].type() == QMetaType::Int) { - backend()->setBrightnessValue(args["Value"].toInt()); -+ newBrightness = brightnessPercent(args["Value"].toInt()); - } else { - backend()->setBrightness(args["Value"].toFloat()); -+ newBrightness = args["Value"].toFloat(); - } -- if (args["Explicit"].toBool() && !args["Silent"].toBool()) { -- BrightnessOSDWidget::show(brightness()); -+ if (args["Explicit"].toBool() && !args["Silent"].toBool() && newBrightness > -1) { -+ BrightnessOSDWidget::show(newBrightness); - } - } - -@@ -180,14 +183,18 @@ void BrightnessControl::setBrightnessSilent(int percent) - - void BrightnessControl::increaseBrightness() - { -- backend()->brightnessKeyPressed(BrightnessLogic::Increase); -- BrightnessOSDWidget::show(brightness()); -+ const int newBrightness = backend()->brightnessKeyPressed(BrightnessLogic::Increase); -+ if (newBrightness > -1) { -+ BrightnessOSDWidget::show(brightnessPercent(newBrightness)); -+ } - } - - void BrightnessControl::decreaseBrightness() - { -- backend()->brightnessKeyPressed(BrightnessLogic::Decrease); -- BrightnessOSDWidget::show(brightness()); -+ const int newBrightness = backend()->brightnessKeyPressed(BrightnessLogic::Decrease); -+ if (newBrightness > -1) { -+ BrightnessOSDWidget::show(brightnessPercent(newBrightness)); -+ } - } - - int BrightnessControl::brightnessValue() const -@@ -235,5 +242,15 @@ void BrightnessControl::setBrightnessStep(int step) - trigger(args); - } - -+int BrightnessControl::brightnessPercent(float value) const -+{ -+ const float maxBrightness = brightnessValueMax(); -+ if (maxBrightness <= 0) { -+ return 0; -+ } -+ -+ return qRound(value / maxBrightness * 100); -+} -+ - } - } -diff --git a/daemon/actions/bundled/brightnesscontrol.h b/daemon/actions/bundled/brightnesscontrol.h -index 5e569fd..0310f39 100644 ---- a/daemon/actions/bundled/brightnesscontrol.h -+++ b/daemon/actions/bundled/brightnesscontrol.h -@@ -74,6 +74,8 @@ Q_SIGNALS: - void brightnessStepChanged(int step); - - private: -+ int brightnessPercent(float value) const; -+ - int m_defaultValue; - QString m_lastProfile; - QString m_currentProfile; -diff --git a/daemon/backends/hal/powerdevilhalbackend.cpp b/daemon/backends/hal/powerdevilhalbackend.cpp -index bec528a..6413b45 100644 ---- a/daemon/backends/hal/powerdevilhalbackend.cpp -+++ b/daemon/backends/hal/powerdevilhalbackend.cpp -@@ -173,17 +173,17 @@ void PowerDevilHALBackend::init() - setBackendIsReady(controls, supported); - } - --void PowerDevilHALBackend::brightnessKeyPressed(PowerDevil::BrightnessLogic::BrightnessKeyType type, BrightnessControlType controlType) -+int PowerDevilHALBackend::brightnessKeyPressed(PowerDevil::BrightnessLogic::BrightnessKeyType type, BrightnessControlType controlType) - { - BrightnessControlsList allControls = brightnessControlsAvailable(); - QList controls = allControls.keys(controlType); - - if (controls.isEmpty()) { -- return; // ignore as we are not able to determine the brightness level -+ return -1; // ignore as we are not able to determine the brightness level - } - - if (type == PowerDevil::BrightnessLogic::Toggle && controlType == Screen) { -- return; // ignore as we wont toggle the display off -+ return -1; // ignore as we wont toggle the display off - } - - int currentBrightness = brightnessValue(controlType); -@@ -218,6 +218,8 @@ void PowerDevilHALBackend::brightnessKeyPressed(PowerDevil::BrightnessLogic::Bri - } else { - m_cachedKeyboardBrightness = cachedBrightness; - } -+ -+ return cachedBrightness; - } - - int PowerDevilHALBackend::brightnessValue(PowerDevil::BackendInterface::BrightnessControlType type) const -diff --git a/daemon/backends/hal/powerdevilhalbackend.h b/daemon/backends/hal/powerdevilhalbackend.h -index ab04e53..b34b893 100644 ---- a/daemon/backends/hal/powerdevilhalbackend.h -+++ b/daemon/backends/hal/powerdevilhalbackend.h -@@ -48,7 +48,7 @@ public: - virtual int brightnessValue(BrightnessControlType type = Screen) const; - virtual int brightnessValueMax(BrightnessControlType type = Screen) const; - -- virtual void brightnessKeyPressed(PowerDevil::BrightnessLogic::BrightnessKeyType type, BrightnessControlType controlType = Screen); -+ virtual int brightnessKeyPressed(PowerDevil::BrightnessLogic::BrightnessKeyType type, BrightnessControlType controlType = Screen); - virtual bool setBrightnessValue(int brightnessValue, PowerDevil::BackendInterface::BrightnessControlType type = Screen); - virtual KJob* suspend(PowerDevil::BackendInterface::SuspendMethod method); - -diff --git a/daemon/backends/upower/powerdevilupowerbackend.cpp b/daemon/backends/upower/powerdevilupowerbackend.cpp -index 51a052a..9b959a4 100644 ---- a/daemon/backends/upower/powerdevilupowerbackend.cpp -+++ b/daemon/backends/upower/powerdevilupowerbackend.cpp -@@ -132,23 +132,44 @@ void PowerDevilUPowerBackend::init() - m_upowerInterface = new OrgFreedesktopUPowerInterface(UPOWER_SERVICE, "/org/freedesktop/UPower", QDBusConnection::systemBus(), this); - m_brightnessControl = new XRandrBrightness(); - if (!m_brightnessControl->isSupported()) { -- qCDebug(POWERDEVIL) << "Using helper"; -- KAuth::Action action("org.kde.powerdevil.backlighthelper.syspath"); -- action.setHelperId(HELPER_ID); -- KAuth::ExecuteJob* job = action.execute(); -- if (job->exec()) { -- m_syspath = job->data()["syspath"].toString(); -- m_syspath = QFileInfo(m_syspath).readLink(); -- -- UdevQt::Client *client = new UdevQt::Client(QStringList("backlight"), this); -- connect(client, SIGNAL(deviceChanged(UdevQt::Device)), SLOT(onDeviceChanged(UdevQt::Device))); -- screenBrightnessAvailable = true; -+ qCDebug(POWERDEVIL) << "Falling back to helper to get brightness"; -+ -+ KAuth::Action brightnessValueAction("org.kde.powerdevil.backlighthelper.brightnessvalue"); -+ brightnessValueAction.setHelperId(HELPER_ID); -+ KAuth::ExecuteJob *brightnessValueJob = brightnessValueAction.execute(); -+ if (!brightnessValueJob->exec()) { -+ qCWarning(POWERDEVIL) << "org.kde.powerdevil.backlighthelper.brightnessvalue failed"; -+ } else { -+ m_cachedBrightnessMap.insert(Screen, brightnessValueJob->data()["brightnessvalue"].toFloat()); -+ -+ KAuth::Action brightnessValueMaxAction("org.kde.powerdevil.backlighthelper.brightnessvaluemax"); -+ brightnessValueMaxAction.setHelperId(HELPER_ID); -+ KAuth::ExecuteJob *brightnessValueMaxJob = brightnessValueMaxAction.execute(); -+ if (brightnessValueMaxJob->exec()) { -+ m_brightnessValueMax = brightnessValueMaxJob->data()["brightnessvaluemax"].toInt(); -+ } else { -+ qCWarning(POWERDEVIL) << "org.kde.powerdevil.backlighthelper.brightnessvaluemax failed"; -+ } -+ -+ KAuth::Action syspathAction("org.kde.powerdevil.backlighthelper.syspath"); -+ syspathAction.setHelperId(HELPER_ID); -+ KAuth::ExecuteJob* syspathJob = syspathAction.execute(); -+ if (syspathJob->exec()) { -+ m_syspath = syspathJob->data()["syspath"].toString(); -+ m_syspath = QFileInfo(m_syspath).readLink(); -+ -+ UdevQt::Client *client = new UdevQt::Client(QStringList("backlight"), this); -+ connect(client, SIGNAL(deviceChanged(UdevQt::Device)), SLOT(onDeviceChanged(UdevQt::Device))); -+ -+ screenBrightnessAvailable = true; -+ } - } - } else { - qCDebug(POWERDEVIL) << "Using XRandR"; - m_randrHelper = XRandRXCBHelper::self(); - Q_ASSERT(m_randrHelper); - connect(m_randrHelper, SIGNAL(brightnessChanged()), this, SLOT(slotScreenBrightnessChanged())); -+ m_cachedBrightnessMap.insert(Screen, brightnessValue(Screen)); - screenBrightnessAvailable = true; - } - -@@ -178,7 +199,6 @@ void PowerDevilUPowerBackend::init() - BrightnessControlsList controls; - if (screenBrightnessAvailable) { - controls.insert(QLatin1String("LVDS1"), Screen); -- m_cachedBrightnessMap.insert(Screen, brightnessValue(Screen)); - qCDebug(POWERDEVIL) << "current screen brightness value: " << m_cachedBrightnessMap.value(Screen); - } - -@@ -278,29 +298,30 @@ void PowerDevilUPowerBackend::onDeviceChanged(const UdevQt::Device &device) - } - } - --void PowerDevilUPowerBackend::brightnessKeyPressed(PowerDevil::BrightnessLogic::BrightnessKeyType type, BrightnessControlType controlType) -+int PowerDevilUPowerBackend::brightnessKeyPressed(PowerDevil::BrightnessLogic::BrightnessKeyType type, BrightnessControlType controlType) - { - BrightnessControlsList allControls = brightnessControlsAvailable(); - QList controls = allControls.keys(controlType); - - if (controls.isEmpty()) { -- return; // ignore as we are not able to determine the brightness level -+ return -1; // ignore as we are not able to determine the brightness level - } - - int currentBrightness = brightnessValue(controlType); - if (currentBrightness != m_cachedBrightnessMap.value(controlType)) { - m_cachedBrightnessMap[controlType] = currentBrightness; -- return; -+ return currentBrightness; - } - - int maxBrightness = brightnessValueMax(controlType), - newBrightness = calculateNextStep(currentBrightness, maxBrightness, controlType, type); - - if (newBrightness < 0) { -- return; -+ return -1; - } - - setBrightnessValue(newBrightness, controlType); -+ return newBrightness; - } - - int PowerDevilUPowerBackend::brightnessValue(PowerDevil::BackendInterface::BrightnessControlType type) const -@@ -312,17 +333,7 @@ int PowerDevilUPowerBackend::brightnessValue(PowerDevil::BackendInterface::Brigh - //qCDebug(POWERDEVIL) << "Calling xrandr brightness"; - result = (int) m_brightnessControl->brightnessValue(); - } else { -- //qCDebug(POWERDEVIL) << "Falling back to helper to get brightness"; -- KAuth::Action action("org.kde.powerdevil.backlighthelper.brightnessvalue"); -- action.setHelperId(HELPER_ID); -- KAuth::ExecuteJob *job = action.execute(); -- if (job->exec()) { -- result = job->data()["brightnessvalue"].toFloat(); -- //qCDebug(POWERDEVIL) << "org.kde.powerdevil.backlighthelper.brightnessvalue succeeded: " << reply.data()["brightnessvalue"]; -- } -- else -- qCWarning(POWERDEVIL) << "org.kde.powerdevil.backlighthelper.brightnessvalue failed"; -- -+ return m_cachedBrightnessMap[Screen]; - } - qCDebug(POWERDEVIL) << "Screen brightness value: " << result; - } else if (type == Keyboard) { -@@ -342,17 +353,7 @@ int PowerDevilUPowerBackend::brightnessValueMax(PowerDevil::BackendInterface::Br - //qCDebug(POWERDEVIL) << "Calling xrandr brightness"; - result = (int) m_brightnessControl->brightnessValueMax(); - } else { -- //qCDebug(POWERDEVIL) << "Falling back to helper to get brightness"; -- KAuth::Action action("org.kde.powerdevil.backlighthelper.brightnessvaluemax"); -- action.setHelperId(HELPER_ID); -- KAuth::ExecuteJob *job = action.execute(); -- if (job->exec()) { -- result = job->data()["brightnessvaluemax"].toInt(); -- //qCDebug(POWERDEVIL) << "org.kde.powerdevil.backlighthelper.brightnessvaluemax succeeded: " << reply.data()["brightnessvaluemax"]; -- } -- else -- qCWarning(POWERDEVIL) << "org.kde.powerdevil.backlighthelper.brightnessvaluemax failed"; -- -+ return m_brightnessValueMax; - } - qCDebug(POWERDEVIL) << "Screen brightness value max: " << result; - } else if (type == Keyboard) { -@@ -376,10 +377,8 @@ bool PowerDevilUPowerBackend::setBrightnessValue(int brightnessValue, PowerDevil - action.setHelperId(HELPER_ID); - action.addArgument("brightnessvalue", brightnessValue); - KAuth::ExecuteJob *job = action.execute(); -- if (!job->exec()) { -- qCWarning(POWERDEVIL) << "org.kde.powerdevil.backlighthelper.setbrightnessvalue failed"; -- return false; -- } -+ // we don't care about the result since executing the job sync is bad -+ job->start(); - } - - success = true; -diff --git a/daemon/backends/upower/powerdevilupowerbackend.h b/daemon/backends/upower/powerdevilupowerbackend.h -index 220289c..60d8525 100644 ---- a/daemon/backends/upower/powerdevilupowerbackend.h -+++ b/daemon/backends/upower/powerdevilupowerbackend.h -@@ -57,7 +57,7 @@ public: - virtual int brightnessValue(BrightnessControlType type = Screen) const; - virtual int brightnessValueMax(BrightnessControlType type = Screen) const; - -- virtual void brightnessKeyPressed(PowerDevil::BrightnessLogic::BrightnessKeyType type, BrightnessControlType controlType); -+ virtual int brightnessKeyPressed(PowerDevil::BrightnessLogic::BrightnessKeyType type, BrightnessControlType controlType); - virtual bool setBrightnessValue(int brightnessValue, PowerDevil::BackendInterface::BrightnessControlType type = Screen); - virtual KJob* suspend(PowerDevil::BackendInterface::SuspendMethod method); - -@@ -93,6 +93,7 @@ private: - OrgFreedesktopUPowerInterface *m_upowerInterface; - OrgFreedesktopUPowerKbdBacklightInterface *m_kbdBacklight; - int m_kbdMaxBrightness; -+ int m_brightnessValueMax = 0; - - // login1 interface - QWeakPointer m_login1Interface; -diff --git a/daemon/powerdevilbackendinterface.h b/daemon/powerdevilbackendinterface.h -index 702b66b..6708da2 100644 ---- a/daemon/powerdevilbackendinterface.h -+++ b/daemon/powerdevilbackendinterface.h -@@ -262,9 +262,10 @@ public: - * Should be called when the user presses a brightness key. - * - * @param type the type of the brightness key press -+ * @return the new brightness value, or -1 if it could not be changed or determined - * @see PowerDevil::BrightnessLogic::BrightnessKeyType - */ -- virtual void brightnessKeyPressed(BrightnessLogic::BrightnessKeyType type, BrightnessControlType controlType = Screen) = 0; -+ virtual int brightnessKeyPressed(BrightnessLogic::BrightnessKeyType type, BrightnessControlType controlType = Screen) = 0; - - /** - * Retrieves the capacities of the installed batteries in percentage. diff --git a/powerdevil.spec b/powerdevil.spec index 1fce4d7..a7041b3 100644 --- a/powerdevil.spec +++ b/powerdevil.spec @@ -16,10 +16,6 @@ Source0: http://download.kde.org/%{stable}/plasma/%{version}/%{name}-%{ve Patch0: powerdevil-enable-upower.patch -# Upstream patches -# BKO#337674 -Patch10: powerdevil-5.2.1-fix-kded5-cpu-usage.patch - BuildRequires: libxcb-devel BuildRequires: xcb-util-keysyms-devel BuildRequires: xcb-util-image-devel @@ -58,8 +54,6 @@ of a daemon (a KDED module) and a KCModule for its configuration. %patch0 -p1 -b .enable-upower -%patch10 -p1 -b .kded5 - %build mkdir -p %{_target_platform}