Commit 8339cba1 authored by Méven Car's avatar Méven Car
Browse files

[KWindowSystem] in icon() return realistic icon size

Summary:
The icon function did not take into account the fact that icons have limited size options available.
Also take into account scale parameter.

Reviewers: #kwin, davidedmundson, zzag

Reviewed By: #kwin, zzag

Subscribers: anthonyfieroni, mart, zzag, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D24683
parent aa48fd7b
......@@ -162,10 +162,32 @@ bool WindowSystem::icccmCompliantMappingState()
QPixmap WindowSystem::icon(WId win, int width, int height, bool scale, int flags)
{
Q_UNUSED(scale)
Q_UNUSED(flags)
// Since width can be any arbitrary size, but the icons cannot,
// take the nearest value for best results (ignoring 22 pixel
// icons as they don't exist for apps):
int iconWidth;
if (width < 24) {
iconWidth = 16;
} else if (width < 40) {
iconWidth = 32;
} else if (width < 56) {
iconWidth = 48;
} else if (width < 96) {
iconWidth = 64;
} else if (width < 192) {
iconWidth = 128;
} else {
iconWidth = 256;
}
if (PlasmaWindow *w = window(win)) {
return w->icon().pixmap(width, height);
QPixmap pixmap = w->icon().pixmap(iconWidth, iconWidth);
if (scale) {
return pixmap.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
return pixmap;
}
return QPixmap();
}
......
Markdown is supported
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