From 75b7f5c2fa63bc1ef13ac6fb5f82c7d52bfabd6c Mon Sep 17 00:00:00 2001 From: Eike Hein Date: Thu, 3 Aug 2017 21:12:14 +0900 Subject: [PATCH] Keep fallback icon updated Summary: Windows we can't find an app icon for using the normal means get the icon used by the windowing system in the Task Manager. This fallback icon was then not updated when changed on the window, only occasionally as a side-effect of cache evictions and model data requests. This patch notes which windows hit the fallback path, and for those windows evicts the cache when the icon changes on the window, causing it to be re-retrieved from the windowing system as views respond to the dataChanged signal for the decoration role. Evicting the entire cache is a little bit costly, but: - This is a fallback codepath. - Apps conventionally update title and icon in one go, meaning the cache is often already getting evicted anyway. - Icons don't change that often. BUG:383017 Reviewers: #plasma, davidedmundson Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D7092 --- libtaskmanager/xwindowtasksmodel.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libtaskmanager/xwindowtasksmodel.cpp b/libtaskmanager/xwindowtasksmodel.cpp index d0b3e28d5..1cef6c97d 100644 --- a/libtaskmanager/xwindowtasksmodel.cpp +++ b/libtaskmanager/xwindowtasksmodel.cpp @@ -62,6 +62,7 @@ public: QHash windowInfoCache; QHash appDataCache; QHash delegateGeometries; + QSet usingFallbackIcon; WId activeWindow = -1; KSharedConfig::Ptr rulesConfig; KDirWatch *configWatcher = nullptr; @@ -251,6 +252,7 @@ void XWindowTasksModel::Private::removeWindow(WId window) transientsDemandingAttention.remove(window); windowInfoCache.remove(window); appDataCache.remove(window); + usingFallbackIcon.remove(window); delegateGeometries.remove(window); q->endRemoveRows(); } else { // Could be a transient. @@ -329,8 +331,12 @@ void XWindowTasksModel::Private::windowChanged(WId window, NET::Properties prope changedRoles << Qt::DisplayRole << Qt::DecorationRole << AppId << AppName << GenericName << LauncherUrl << AppPid; } - if ((properties & NET::WMIcon) && !changedRoles.contains(Qt::DecorationRole)) { - changedRoles << Qt::DecorationRole; + if ((properties & NET::WMIcon) && usingFallbackIcon.contains(window)) { + wipeAppDataCache = true; + + if (!changedRoles.contains(Qt::DecorationRole)) { + changedRoles << Qt::DecorationRole; + } } // FIXME TODO: It might be worth keeping track of which windows were demanding @@ -374,6 +380,7 @@ void XWindowTasksModel::Private::windowChanged(WId window, NET::Properties prope if (wipeAppDataCache) { appDataCache.remove(window); + usingFallbackIcon.remove(window); } if (!changedRoles.isEmpty()) { @@ -452,6 +459,7 @@ QIcon XWindowTasksModel::Private::icon(WId window) icon.addPixmap(KWindowSystem::icon(window, KIconLoader::SizeLarge, KIconLoader::SizeLarge, false)); appDataCache[window].icon = icon; + usingFallbackIcon.insert(window); return icon; }