Commit 75b7f5c2 authored by Eike Hein's avatar Eike Hein
Browse files

Keep fallback icon updated

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

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.


Reviewers: #plasma, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision:
parent 3558afa9
......@@ -62,6 +62,7 @@ public:
QHash<WId, KWindowInfo*> windowInfoCache;
QHash<WId, AppData> appDataCache;
QHash<WId, QRect> delegateGeometries;
QSet<WId> usingFallbackIcon;
WId activeWindow = -1;
KSharedConfig::Ptr rulesConfig;
KDirWatch *configWatcher = nullptr;
......@@ -251,6 +252,7 @@ void XWindowTasksModel::Private::removeWindow(WId window)
} 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) {
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;
return icon;
Supports Markdown
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