[libwnck/wip/muktupavels/icons: 11/16] icon-cache: add invalidated signal
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libwnck/wip/muktupavels/icons: 11/16] icon-cache: add invalidated signal
- Date: Mon, 14 Mar 2022 18:09:03 +0000 (UTC)
commit 8bf64ede9f9c0f16a75015210ca796a6c2d68056
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Mar 14 19:28:02 2022 +0200
icon-cache: add invalidated signal
And use to to emit icon changed signals in WnckApplication and
WnckWindow.
libwnck/application.c | 21 +++++++++++++--------
libwnck/window.c | 27 +++++++++++++--------------
libwnck/wnck-icon-cache.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 59 insertions(+), 22 deletions(-)
---
diff --git a/libwnck/application.c b/libwnck/application.c
index bb3c2069..31b18987 100644
--- a/libwnck/application.c
+++ b/libwnck/application.c
@@ -69,8 +69,6 @@ struct _WnckApplicationPrivate
char *startup_id;
guint name_from_leader : 1; /* name is from group leader */
-
- guint need_emit_icon_changed : 1;
};
G_DEFINE_TYPE_WITH_PRIVATE (WnckApplication, wnck_application, G_TYPE_OBJECT);
@@ -295,6 +293,13 @@ wnck_application_get_pid (WnckApplication *app)
return app->priv->pid;
}
+static void
+icon_cache_invalidated_cb (WnckIconCache *icon_cache,
+ WnckApplication *self)
+{
+ emit_icon_changed (self);
+}
+
static void
get_icons (WnckApplication *app)
{
@@ -304,8 +309,7 @@ get_icons (WnckApplication *app)
icon = NULL;
mini_icon = NULL;
- if (_wnck_read_icons (app->priv->icon_cache, &icon, &mini_icon))
- app->priv->need_emit_icon_changed = TRUE;
+ _wnck_read_icons (app->priv->icon_cache, &icon, &mini_icon);
/* FIXME we should really fall back to using the icon
* for one of the windows. But then we need to be more
@@ -325,8 +329,6 @@ _wnck_application_load_icons (WnckApplication *app)
g_return_if_fail (WNCK_IS_APPLICATION (app));
get_icons (app);
- if (app->priv->need_emit_icon_changed)
- emit_icon_changed (app);
}
void
@@ -497,6 +499,11 @@ _wnck_application_create (Window xwindow,
application->priv->icon_cache = _wnck_icon_cache_new (xwindow, screen);
_wnck_icon_cache_set_want_fallback (application->priv->icon_cache, FALSE);
+ g_signal_connect (application->priv->icon_cache,
+ "invalidated",
+ G_CALLBACK (icon_cache_invalidated_cb),
+ application);
+
application->priv->name = _wnck_get_name (xscreen, xwindow);
if (application->priv->name == NULL)
@@ -637,7 +644,6 @@ _wnck_application_process_property_notify (WnckApplication *app,
{
_wnck_icon_cache_property_changed (app->priv->icon_cache,
xevent->xproperty.atom);
- emit_icon_changed (app);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("_NET_STARTUP_ID"))
@@ -657,7 +663,6 @@ emit_name_changed (WnckApplication *app)
static void
emit_icon_changed (WnckApplication *app)
{
- app->priv->need_emit_icon_changed = FALSE;
g_signal_emit (G_OBJECT (app),
signals[ICON_CHANGED],
0);
diff --git a/libwnck/window.c b/libwnck/window.c
index fdae373d..8acae684 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -156,7 +156,6 @@ struct _WnckWindowPrivate
guint need_update_role : 1;
guint need_emit_name_changed : 1;
- guint need_emit_icon_changed : 1;
guint need_emit_class_changed : 1;
guint need_emit_role_changed : 1;
guint need_emit_type_changed : 1;
@@ -214,6 +213,13 @@ static WnckWindow* find_last_transient_for (GList *windows,
static guint signals[LAST_SIGNAL] = { 0 };
+static void
+icon_cache_invalidated_cb (WnckIconCache *icon_cache,
+ WnckWindow *self)
+{
+ emit_icon_changed (self);
+}
+
static void
wnck_window_init (WnckWindow *window)
{
@@ -477,6 +483,11 @@ _wnck_window_create (Window xwindow,
window->priv->icon_cache = _wnck_icon_cache_new (xwindow, screen);
+ g_signal_connect (window->priv->icon_cache,
+ "invalidated",
+ G_CALLBACK (icon_cache_invalidated_cb),
+ window);
+
_wnck_handle_insert_window (handle, &window->priv->xwindow, window);
/* Handle now owns one ref, caller gets none */
@@ -528,7 +539,6 @@ _wnck_window_create (Window xwindow,
window->priv->need_update_frame_extents = TRUE;
window->priv->need_update_role = TRUE;
window->priv->need_emit_name_changed = FALSE;
- window->priv->need_emit_icon_changed = FALSE;
window->priv->need_emit_class_changed = FALSE;
window->priv->need_emit_role_changed = FALSE;
window->priv->need_emit_type_changed = FALSE;
@@ -2104,8 +2114,7 @@ get_icons (WnckWindow *window)
icon = NULL;
mini_icon = NULL;
- if (_wnck_read_icons (window->priv->icon_cache, &icon, &mini_icon))
- window->priv->need_emit_icon_changed = TRUE;
+ _wnck_read_icons (window->priv->icon_cache, &icon, &mini_icon);
g_assert ((icon && mini_icon) || !(icon || mini_icon));
@@ -2119,10 +2128,6 @@ _wnck_window_load_icons (WnckWindow *window)
g_return_if_fail (WNCK_IS_WINDOW (window));
get_icons (window);
- if (window->priv->need_emit_icon_changed)
- queue_update (window); /* not done in get_icons since we call that from
- * the update
- */
}
void
@@ -2587,7 +2592,6 @@ _wnck_window_process_property_notify (WnckWindow *window,
{
_wnck_icon_cache_property_changed (window->priv->icon_cache,
xevent->xproperty.atom);
- queue_update (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("WM_HINTS"))
@@ -3291,9 +3295,6 @@ force_update_now (WnckWindow *window)
emit_actions_changed (window, old_actions ^ window->priv->actions,
window->priv->actions);
- if (window->priv->need_emit_icon_changed)
- emit_icon_changed (window);
-
if (window->priv->need_emit_class_changed)
emit_class_changed (window);
@@ -3304,7 +3305,6 @@ force_update_now (WnckWindow *window)
emit_type_changed (window);
}
-
static gboolean
update_idle (gpointer data)
{
@@ -3364,7 +3364,6 @@ emit_workspace_changed (WnckWindow *window)
static void
emit_icon_changed (WnckWindow *window)
{
- window->priv->need_emit_icon_changed = FALSE;
g_signal_emit (G_OBJECT (window),
signals[ICON_CHANGED],
0);
diff --git a/libwnck/wnck-icon-cache.c b/libwnck/wnck-icon-cache.c
index 193b3260..aa631d45 100644
--- a/libwnck/wnck-icon-cache.c
+++ b/libwnck/wnck-icon-cache.c
@@ -59,6 +59,14 @@ struct _WnckIconCache
guint net_wm_icon_dirty : 1;
};
+enum
+{
+ INVALIDATED,
+ LAST_SIGNAL
+};
+
+static guint icon_cache_signals[LAST_SIGNAL] = { 0 };
+
G_DEFINE_TYPE (WnckIconCache, _wnck_icon_cache, G_TYPE_OBJECT)
static gboolean
@@ -511,6 +519,12 @@ scaled_from_pixdata (guchar *pixdata,
return dest;
}
+static void
+emit_invalidated (WnckIconCache *self)
+{
+ g_signal_emit (self, icon_cache_signals[INVALIDATED], 0);
+}
+
static void
_wnck_icon_cache_finalize (GObject *object)
{
@@ -531,6 +545,17 @@ _wnck_icon_cache_class_init (WnckIconCacheClass *self_class)
object_class = G_OBJECT_CLASS (self_class);
object_class->finalize = _wnck_icon_cache_finalize;
+
+ icon_cache_signals[INVALIDATED] =
+ g_signal_new ("invalidated",
+ WNCK_TYPE_ICON_CACHE,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ G_TYPE_NONE,
+ 0);
}
static void
@@ -571,6 +596,12 @@ _wnck_icon_cache_property_changed (WnckIconCache *icon_cache,
icon_cache->kwm_win_icon_dirty = TRUE;
else if (atom == _wnck_atom_get ("WM_HINTS"))
icon_cache->wm_hints_dirty = TRUE;
+
+ if (!_wnck_icon_cache_get_icon_invalidated (icon_cache))
+ return;
+
+ clear_icon_cache (icon_cache, FALSE);
+ emit_invalidated (icon_cache);
}
gboolean
@@ -769,6 +800,7 @@ _wnck_read_icons (WnckIconCache *icon_cache,
{
/* Get rid of current icon */
clear_icon_cache (icon_cache, FALSE);
+ emit_invalidated (icon_cache);
return TRUE;
}
@@ -793,4 +825,5 @@ void
_wnck_icon_cache_invalidate (WnckIconCache *self)
{
clear_icon_cache (self, TRUE);
+ emit_invalidated (self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]