[libwnck/wip/muktupavels/icons: 2/17] icon-cache: add invalidation function
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libwnck/wip/muktupavels/icons: 2/17] icon-cache: add invalidation function
- Date: Fri, 16 Sep 2022 14:25:03 +0000 (UTC)
commit d0251d9921173028c0263e510d430374c5a34021
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Mar 14 13:57:40 2022 +0200
icon-cache: add invalidation function
And use that to invalidate cache when icon sizes are changed using
set_default_icon_size() and/or set_default_mini_icon_size().
libwnck/application.c | 9 ++++++++-
libwnck/private.h | 4 ++--
libwnck/window.c | 9 ++++++++-
libwnck/wnck-handle.c | 4 ++--
libwnck/wnck-icon-cache-private.h | 2 ++
libwnck/wnck-icon-cache.c | 17 ++++++-----------
6 files changed, 28 insertions(+), 17 deletions(-)
---
diff --git a/libwnck/application.c b/libwnck/application.c
index 9ab7f489..abf4cbf4 100644
--- a/libwnck/application.c
+++ b/libwnck/application.c
@@ -356,7 +356,7 @@ get_icons (WnckApplication *app)
!(app->priv->icon || app->priv->mini_icon));
}
-void
+static void
_wnck_application_load_icons (WnckApplication *app)
{
g_return_if_fail (WNCK_IS_APPLICATION (app));
@@ -366,6 +366,13 @@ _wnck_application_load_icons (WnckApplication *app)
emit_icon_changed (app);
}
+void
+_wnck_application_invalidate_icons (WnckApplication *self)
+{
+ _wnck_icon_cache_invalidate (self->priv->icon_cache);
+ _wnck_application_load_icons (self);
+}
+
/* Prefer to get group icon from a window of type "normal" */
static WnckWindow*
find_icon_window (WnckApplication *app)
diff --git a/libwnck/private.h b/libwnck/private.h
index d5e48d93..9286e12d 100644
--- a/libwnck/private.h
+++ b/libwnck/private.h
@@ -51,7 +51,7 @@ WnckWindow* _wnck_window_create (Window xwindow,
gint sort_order);
void _wnck_window_destroy (WnckWindow *window);
-void _wnck_window_load_icons (WnckWindow *window);
+void _wnck_window_invalidate_icons (WnckWindow *self);
char* _wnck_window_get_name_for_display (WnckWindow *window,
gboolean use_icon_name,
@@ -84,7 +84,7 @@ void _wnck_application_remove_window (WnckApplication *app,
WnckApplication* _wnck_application_create (Window xwindow,
WnckScreen *screen);
void _wnck_application_destroy (WnckApplication *app);
-void _wnck_application_load_icons (WnckApplication *app);
+void _wnck_application_invalidate_icons (WnckApplication *self);
WnckClassGroup *_wnck_class_group_create (WnckScreen *screen,
const char *res_class);
diff --git a/libwnck/window.c b/libwnck/window.c
index 35bb37c1..79c2cc8b 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -2146,7 +2146,7 @@ get_icons (WnckWindow *window)
!(window->priv->icon || window->priv->mini_icon));
}
-void
+static void
_wnck_window_load_icons (WnckWindow *window)
{
g_return_if_fail (WNCK_IS_WINDOW (window));
@@ -2158,6 +2158,13 @@ _wnck_window_load_icons (WnckWindow *window)
*/
}
+void
+_wnck_window_invalidate_icons (WnckWindow *self)
+{
+ _wnck_icon_cache_invalidate (self->priv->icon_cache);
+ _wnck_window_load_icons (self);
+}
+
/**
* wnck_window_get_icon:
* @window: a #WnckWindow.
diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
index e12ff882..80efbe23 100644
--- a/libwnck/wnck-handle.c
+++ b/libwnck/wnck-handle.c
@@ -93,10 +93,10 @@ invalidate_icons (WnckHandle *self)
window = WNCK_WINDOW (l->data);
application = wnck_window_get_application (window);
- _wnck_window_load_icons (window);
+ _wnck_window_invalidate_icons (window);
if (application != NULL)
- _wnck_application_load_icons (application);
+ _wnck_application_invalidate_icons (application);
}
}
}
diff --git a/libwnck/wnck-icon-cache-private.h b/libwnck/wnck-icon-cache-private.h
index 6a3d5ecb..2a89213e 100644
--- a/libwnck/wnck-icon-cache-private.h
+++ b/libwnck/wnck-icon-cache-private.h
@@ -46,6 +46,8 @@ gboolean _wnck_read_icons (WnckScreen *screen,
GdkPixbuf **mini_iconp,
int ideal_mini_size);
+void _wnck_icon_cache_invalidate (WnckIconCache *self);
+
G_END_DECLS
#endif
diff --git a/libwnck/wnck-icon-cache.c b/libwnck/wnck-icon-cache.c
index 9ff8d15b..6a89ff08 100644
--- a/libwnck/wnck-icon-cache.c
+++ b/libwnck/wnck-icon-cache.c
@@ -46,8 +46,6 @@ struct _WnckIconCache
Pixmap prev_mask;
GdkPixbuf *icon;
GdkPixbuf *mini_icon;
- int ideal_size;
- int ideal_mini_size;
guint want_fallback : 1;
/* TRUE if these props have changed */
guint wm_hints_dirty : 1;
@@ -466,8 +464,6 @@ _wnck_icon_cache_new (void)
icon_cache->prev_pixmap = None;
icon_cache->icon = NULL;
icon_cache->mini_icon = NULL;
- icon_cache->ideal_size = -1; /* won't be a legit size */
- icon_cache->ideal_mini_size = -1;
icon_cache->want_fallback = TRUE;
icon_cache->wm_hints_dirty = TRUE;
icon_cache->net_wm_icon_dirty = TRUE;
@@ -556,13 +552,6 @@ _wnck_read_icons (WnckScreen *screen,
*iconp = NULL;
*mini_iconp = NULL;
- if (ideal_size != icon_cache->ideal_size ||
- ideal_mini_size != icon_cache->ideal_mini_size)
- clear_icon_cache (icon_cache, TRUE);
-
- icon_cache->ideal_size = ideal_size;
- icon_cache->ideal_mini_size = ideal_mini_size;
-
if (!_wnck_icon_cache_get_icon_invalidated (icon_cache))
return FALSE; /* we have no new info to use */
@@ -671,3 +660,9 @@ _wnck_read_icons (WnckScreen *screen,
/* found nothing new */
return FALSE;
}
+
+void
+_wnck_icon_cache_invalidate (WnckIconCache *self)
+{
+ clear_icon_cache (self, TRUE);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]