From eb442efc24edbd9eebb17510a89977322a7d049367e56857655b679ecd6e29ab Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Sun, 2 Oct 2016 11:54:10 +0000 Subject: [PATCH] - Add add-tray-icon-cache.patch (kde#356479): * High load due to animated tray icons OBS-URL: https://build.opensuse.org/package/show/KDE:Frameworks5:LTS/plasma5-workspace?expand=0&rev=22 --- add-tray-icon-cache.patch | 36 ++++++++++++++++++++++++++++++++++++ plasma5-workspace.changes | 6 ++++++ plasma5-workspace.spec | 3 +++ 3 files changed, 45 insertions(+) create mode 100644 add-tray-icon-cache.patch diff --git a/add-tray-icon-cache.patch b/add-tray-icon-cache.patch new file mode 100644 index 0000000..db11ffa --- /dev/null +++ b/add-tray-icon-cache.patch @@ -0,0 +1,36 @@ +From: Fabian Vogt +Subject: Workaround for high load due to animated tray icons +References: kde#356479 + +When a tray icon name changes, it always does a full lookup, which is expensive. +Add a small QHash as cache to work around this. + +diff --git a/applets/systemtray/systemtray.cpp b/applets/systemtray/systemtray.cpp +index 66bb5b4..f440ff0 100644 +--- a/applets/systemtray/systemtray.cpp ++++ b/applets/systemtray/systemtray.cpp +@@ -127,8 +127,13 @@ void SystemTray::cleanupTask(const QString &task) + + QVariant SystemTray::resolveIcon(const QVariant &variant, const QString &iconThemePath) + { ++ static QHash cache; + if (variant.canConvert()) { + if (!iconThemePath.isEmpty()) { ++ auto i = cache.find(variant.toString() + iconThemePath); ++ if(i != cache.end()) ++ return i.value(); ++ qCWarning(SYSTEM_TRAY) << "Cache not hit" << iconThemePath; + const QString path = iconThemePath; + if (!path.isEmpty()) { + // FIXME: If last part of path is not "icons", this won't work! +@@ -136,7 +141,9 @@ QVariant SystemTray::resolveIcon(const QVariant &variant, const QString &iconThe + if (tokens.length() >= 3 && tokens.takeLast() == QLatin1String("icons")) { + const QString appName = tokens.takeLast().toString(); + +- return QVariant(QIcon(new AppIconEngine(variant.toString(), path, appName))); ++ auto v = QVariant(QIcon(new AppIconEngine(variant.toString(), path, appName))); ++ cache.insert(variant.toString() + iconThemePath, v); ++ return v; + } else { + qCWarning(SYSTEM_TRAY) << "Wrong IconThemePath" << path << ": too short or does not end with 'icons'"; + } diff --git a/plasma5-workspace.changes b/plasma5-workspace.changes index 8c28092..45db8e1 100644 --- a/plasma5-workspace.changes +++ b/plasma5-workspace.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Sun Oct 2 09:30:48 UTC 2016 - fabian@ritter-vogt.de + +- Add add-tray-icon-cache.patch (kde#356479): + * High load due to animated tray icons + ------------------------------------------------------------------- Sat Oct 1 17:25:04 UTC 2016 - fabian@ritter-vogt.de diff --git a/plasma5-workspace.spec b/plasma5-workspace.spec index 8008268..7351e69 100644 --- a/plasma5-workspace.spec +++ b/plasma5-workspace.spec @@ -35,6 +35,8 @@ Patch0: 0001-Rename-qdbus-in-startkde.patch Patch1: change-kioremote-severity.patch # PATCH-FIX-OPENSUSE 0001-Ignore-default-sddm-face-icons.patch boo#1001364 fabian@ritter-vogt.de -- Ignore default sddm face icons Patch2: 0001-Ignore-default-sddm-face-icons.patch +# PATCH-FIX-OPENSUSE add-tray-icon-cache.patch kde#356479 fabian@ritter-vogt.de -- Workaround for high load due to animated tray icons +Patch3: add-tray-icon-cache.patch # PATCHES 100-200 and above are from upstream 5.8 branch # PATCHES 201-300 and above are from upstream master/5.9 branch BuildRequires: breeze5-icons @@ -205,6 +207,7 @@ workspace. Development files. %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 %build %cmake_kf5 -d build -- -DKDE4_COMMON_PAM_SERVICE=xdm -DKDE_DEFAULT_HOME=.kde4 -DCMAKE_INSTALL_LOCALEDIR=%{_kf5_localedir}