Changeset View
Standalone View
src/windowsystem/windowsystem.cpp
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Line(s) | |||||
157 | 157 | | |||
158 | bool WindowSystem::icccmCompliantMappingState() | 158 | bool WindowSystem::icccmCompliantMappingState() | ||
159 | { | 159 | { | ||
160 | return false; | 160 | return false; | ||
161 | } | 161 | } | ||
162 | 162 | | |||
163 | QPixmap WindowSystem::icon(WId win, int width, int height, bool scale, int flags) | 163 | QPixmap WindowSystem::icon(WId win, int width, int height, bool scale, int flags) | ||
164 | { | 164 | { | ||
165 | Q_UNUSED(scale) | | |||
166 | Q_UNUSED(flags) | 165 | Q_UNUSED(flags) | ||
166 | | ||||
167 | // Since width can be any arbitrary size, but the icons cannot, | ||||
168 | // take the nearest value for best results (ignoring 22 pixel | ||||
169 | // icons as they don't exist for apps): | ||||
170 | int iconWidth; | ||||
171 | if (width < 24) { | ||||
172 | iconWidth = 16; | ||||
173 | } else if (width < 40) { | ||||
mart: what's the logic behind the numbers 40, 56, 96 ans 192?
should at least be in a comment | |||||
It was copied from kwindowsystem/src/platforms/xcb/kwindowsytem.cpp meven: It was copied from kwindowsystem/src/platforms/xcb/kwindowsytem.cpp
So I don't know precisely… | |||||
I can't explain the current logic. @mart Do you think I should change the logic to give it more sense ? Perhaps make the 24, 40.. values match the iconWidth i.e : if (width <= 16){ iconWidth = 16; else if (width <= 32) iconWidth = 32 else if (width <= 48){ iconWidth = 48 ... meven: I can't explain the current logic.
@mart Do you think I should change the logic to give it… | |||||
@anthonyfieroni Hey Anthony meven: @anthonyfieroni Hey Anthony
Do you remember where the if comparison width values come from in… | |||||
That's adjustment, 16, 32, 48, 64, 128, 256 are standard icon sizes, when you got a value between 2 sizes you adjust it by lower bound. Say (256 - 128) / 2 = 64, so 128 + 64 = 192, when request is smaller than 192 and bigger than 96 (which is same calculated for previous values) it returns 128. If you want write an algorithm for that. anthonyfieroni: That's adjustment, 16, 32, 48, 64, 128, 256 are standard icon sizes, when you got a value… | |||||
Thank you @anthonyfieroni for the explanation
I don't think more comment is necessary. meven: Thank you @anthonyfieroni for the explanation
So in fact the comment stated already this simply… | |||||
174 | iconWidth = 32; | ||||
175 | } else if (width < 56) { | ||||
176 | iconWidth = 48; | ||||
177 | } else if (width < 96) { | ||||
178 | iconWidth = 64; | ||||
179 | } else if (width < 192) { | ||||
180 | iconWidth = 128; | ||||
181 | } else { | ||||
182 | iconWidth = 256; | ||||
183 | } | ||||
184 | | ||||
167 | if (PlasmaWindow *w = window(win)) { | 185 | if (PlasmaWindow *w = window(win)) { | ||
168 | return w->icon().pixmap(width, height); | 186 | QPixmap pixmap = w->icon().pixmap(iconWidth, iconWidth); | ||
187 | if (scale) { | ||||
188 | return pixmap.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); | ||||
You forgot to assign the copied pixmap to something. However, I think you could just return it from this point. zzag: You forgot to assign the copied pixmap to something. However, I think you could just return it… | |||||
zzag: edit: scaled pixmap | |||||
189 | } | ||||
190 | return pixmap; | ||||
169 | } | 191 | } | ||
170 | return QPixmap(); | 192 | return QPixmap(); | ||
171 | } | 193 | } | ||
172 | 194 | | |||
173 | void WindowSystem::lowerWindow(WId win) | 195 | void WindowSystem::lowerWindow(WId win) | ||
174 | { | 196 | { | ||
175 | Q_UNUSED(win) | 197 | Q_UNUSED(win) | ||
176 | qCDebug(KWAYLAND_KWS) << "This plugin does not support lower window"; | 198 | qCDebug(KWAYLAND_KWS) << "This plugin does not support lower window"; | ||
▲ Show 20 Lines • Show All 363 Lines • Show Last 20 Lines |
what's the logic behind the numbers 40, 56, 96 ans 192?
should at least be in a comment