Hello community, here is the log from the commit of package powerdevil5 for openSUSE:Factory checked in at 2015-01-30 15:08:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/powerdevil5 (Old) and /work/SRC/openSUSE:Factory/.powerdevil5.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "powerdevil5" Changes: -------- --- /work/SRC/openSUSE:Factory/powerdevil5/powerdevil5.changes 2015-01-29 13:18:20.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.powerdevil5.new/powerdevil5.changes 2015-01-30 15:08:09.000000000 +0100 @@ -1,0 +2,6 @@ +Fri Jan 30 01:47:22 UTC 2015 - hrvoje.sen...@gmail.com + +- Added 0001-Fix-PowerDevil-brightness-calls-breaking-kded-Volume.patch + (kde#337674) + +------------------------------------------------------------------- New: ---- 0001-Fix-PowerDevil-brightness-calls-breaking-kded-Volume.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ powerdevil5.spec ++++++ --- /var/tmp/diff_new_pack.i1zrjv/_old 2015-01-30 15:08:10.000000000 +0100 +++ /var/tmp/diff_new_pack.i1zrjv/_new 2015-01-30 15:08:10.000000000 +0100 @@ -25,6 +25,8 @@ Url: http://www.kde.org Source: powerdevil-%{version}.tar.xz Source99: %{name}-rpmlintrc +# PATCH-FIX- UPSTREAM 0001-Fix-PowerDevil-brightness-calls-breaking-kded-Volume.patch +Patch0: 0001-Fix-PowerDevil-brightness-calls-breaking-kded-Volume.patch BuildRequires: kauth-devel BuildRequires: kconfig-devel BuildRequires: kdelibs4support-devel @@ -59,6 +61,7 @@ %lang_package %prep %setup -q -n powerdevil-%{version} +%patch0 -p1 %build %cmake_kf5 -d build -- -DCMAKE_INSTALL_LOCALEDIR=share/locale/kf5 ++++++ 0001-Fix-PowerDevil-brightness-calls-breaking-kded-Volume.patch ++++++ >From 2c2c13751e19b0a37bb8b41096b08f80383e61df Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik <k...@privat.broulik.de> Date: Thu, 29 Jan 2015 22:46:36 +0100 Subject: [PATCH 1/1] 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 --- daemon/actions/bundled/brightnesscontrol.cpp | 29 ++++++-- daemon/actions/bundled/brightnesscontrol.h | 2 + daemon/backends/hal/powerdevilhalbackend.cpp | 8 ++- daemon/backends/hal/powerdevilhalbackend.h | 2 +- daemon/backends/upower/powerdevilupowerbackend.cpp | 83 +++++++++++----------- daemon/backends/upower/powerdevilupowerbackend.h | 3 +- daemon/powerdevilbackendinterface.h | 3 +- 7 files changed, 76 insertions(+), 54 deletions(-) diff --git a/daemon/actions/bundled/brightnesscontrol.cpp b/daemon/actions/bundled/brightnesscontrol.cpp index 692a6438d90c97f89c4b554cf8fcf8dd0e003597..af6ad688206b3584fcee0784c0ff85d2a336f695 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 5e569fdf608283573909bb0820adcd2648f1bb29..0310f3983f53cf7cdb2fd014475b0180838317a2 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 bec528a2950b91c7817bd6bd52010bbc2c9903e0..6413b45a372b674bca6d35e1b32a3ee9fdfbc7eb 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<QString> 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 ab04e53d02fccfaf084dadea8497f94c05523f08..b34b89314ca961eb871404fe27aab5f2f42ddf69 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 51a052ae49bf3787334cabe21638da6f0781020e..9b959a41c3eeb9bbb26476907096ec38b64ccba2 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<QString> 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 220289c1aaa41bffb99a95d42dda374d27f97498..60d852523ffc93e0186e92ccbfa1fda03af2798f 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<QDBusInterface> m_login1Interface; diff --git a/daemon/powerdevilbackendinterface.h b/daemon/powerdevilbackendinterface.h index 702b66b7b9ec47b210c5e40fecb14b75e7b7c3da..6708da2add5b95035dd754811f85b5865688ab21 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. -- 2.2.2 -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org