Skip to content

Commit 65ae4f3

Browse files
committed
nemo-icon-info.c: Track widget scale-factor as part of the cache
key. When using wayland/layer-shell, desktop windows may initially start on the primary monitor with a given scale-factor, before being positioned to a different one, which may have a different scale- factor. Without tracking scale as part of the cache key, windows with the same configured icon size may render their icons incorrectly if the monitor is scaled differently.
1 parent 4bdbb2c commit 65ae4f3

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

libnemo-private/nemo-icon-info.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ nemo_icon_info_new_for_icon_info (GtkIconInfo *icon_info,
168168
typedef struct {
169169
GIcon *icon;
170170
int size;
171+
int scale;
171172
} IconKey;
172173

173174
static GHashTable *loadable_icon_cache = NULL;
@@ -253,25 +254,27 @@ nemo_icon_info_clear_caches (void)
253254
static guint
254255
icon_key_hash (IconKey *key)
255256
{
256-
return g_icon_hash (key->icon) ^ key->size;
257+
return g_icon_hash (key->icon) ^ key->size ^ key->scale;
257258
}
258259

259260
static gboolean
260261
icon_key_equal (const IconKey *a,
261262
const IconKey *b)
262263
{
263264
return a->size == b->size &&
265+
a->scale == b->scale &&
264266
g_icon_equal (a->icon, b->icon);
265267
}
266268

267269
static IconKey *
268-
icon_key_new (GIcon *icon, int size)
270+
icon_key_new (GIcon *icon, int size, int scale)
269271
{
270272
IconKey *key;
271273

272274
key = g_new0 (IconKey, 1);
273275
key->icon = g_object_ref (icon);
274276
key->size = size;
277+
key->scale = scale;
275278

276279
return key;
277280
}
@@ -311,6 +314,7 @@ nemo_icon_info_lookup (GIcon *icon,
311314

312315
lookup_key.icon = icon;
313316
lookup_key.size = size;
317+
lookup_key.scale = scale;
314318

315319
icon_info = g_hash_table_lookup (loadable_icon_cache, &lookup_key);
316320
if (icon_info) {
@@ -344,7 +348,7 @@ nemo_icon_info_lookup (GIcon *icon,
344348

345349
icon_info = nemo_icon_info_new_for_pixbuf (pixbuf, scale);
346350

347-
key = icon_key_new (icon, size);
351+
key = icon_key_new (icon, size, scale);
348352
g_hash_table_insert (loadable_icon_cache, key, icon_info);
349353

350354
g_clear_object (&pixbuf);
@@ -363,6 +367,7 @@ nemo_icon_info_lookup (GIcon *icon,
363367

364368
lookup_key.icon = icon;
365369
lookup_key.size = size;
370+
lookup_key.scale = scale;
366371

367372
icon_info = g_hash_table_lookup (themed_icon_cache, &lookup_key);
368373
if (icon_info) {
@@ -388,7 +393,7 @@ nemo_icon_info_lookup (GIcon *icon,
388393
icon_info = nemo_icon_info_new_for_icon_info (gtkicon_info, scale);
389394
g_object_unref (gtkicon_info);
390395

391-
key = icon_key_new (icon, size);
396+
key = icon_key_new (icon, size, scale);
392397
g_hash_table_insert (themed_icon_cache, key, icon_info);
393398

394399
return nemo_icon_info_ref (icon_info);

0 commit comments

Comments
 (0)