[libwnck/wip/muktupavels/icons] window: get icons in getters
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libwnck/wip/muktupavels/icons] window: get icons in getters
- Date: Wed, 22 Dec 2021 13:25:56 +0000 (UTC)
commit 8b8aad7705eb776aaf30354ca13f2b7864748e23
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Dec 19 22:28:22 2021 +0200
window: get icons in getters
libwnck users might not use icons at all or might use only normal
or mini icon. Redo code to get icons only when getters are used.
libwnck/private.h | 2 +-
libwnck/util.c | 2 +-
libwnck/window.c | 76 ++++++++++++++++++++++---------------------------------
3 files changed, 32 insertions(+), 48 deletions(-)
---
diff --git a/libwnck/private.h b/libwnck/private.h
index fb6594f..c373ac3 100644
--- a/libwnck/private.h
+++ b/libwnck/private.h
@@ -60,7 +60,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_icon_changed (WnckWindow *window);
char* _wnck_window_get_name_for_display (WnckWindow *window,
gboolean use_icon_name,
diff --git a/libwnck/util.c b/libwnck/util.c
index 9cf5b11..8aa1875 100644
--- a/libwnck/util.c
+++ b/libwnck/util.c
@@ -730,7 +730,7 @@ wnck_set_default_mini_icon_size (gsize size)
WnckWindow *window = WNCK_WINDOW (l->data);
WnckApplication *application = wnck_window_get_application (window);
- _wnck_window_load_icons (window);
+ _wnck_window_icon_changed (window);
if (WNCK_IS_APPLICATION (application))
_wnck_application_icon_changed (application);
diff --git a/libwnck/window.c b/libwnck/window.c
index f90933f..1796401 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -2119,56 +2119,42 @@ wnck_window_transient_is_most_recently_activated (WnckWindow *window)
}
static void
-get_icons (WnckWindow *window)
+ensure_icon (WnckWindow *window)
{
- GdkPixbuf *icon;
- GdkPixbuf *mini_icon;
-
- icon = NULL;
- mini_icon = NULL;
-
- if (_wnck_read_icon (window->priv->screen,
- window->priv->xwindow,
- window->priv->icon_cache,
- &icon,
- _wnck_get_default_icon_size ()))
- {
- window->priv->need_emit_icon_changed = TRUE;
-
- if (window->priv->icon)
- g_object_unref (G_OBJECT (window->priv->icon));
-
- window->priv->icon = icon;
- }
-
- if (_wnck_read_icon (window->priv->screen,
- window->priv->xwindow,
- window->priv->mini_icon_cache,
- &mini_icon,
- _wnck_get_default_mini_icon_size ()))
- {
- window->priv->need_emit_icon_changed = TRUE;
+ if (window->priv->icon != NULL)
+ return;
- if (window->priv->mini_icon)
- g_object_unref (G_OBJECT (window->priv->mini_icon));
+ _wnck_read_icon (window->priv->screen,
+ window->priv->xwindow,
+ window->priv->icon_cache,
+ &window->priv->icon,
+ _wnck_get_default_icon_size ());
+}
- window->priv->mini_icon = mini_icon;
- }
+static void
+ensure_mini_icon (WnckWindow *window)
+{
+ if (window->priv->mini_icon != NULL)
+ return;
- g_assert ((window->priv->icon && window->priv->mini_icon) ||
- !(window->priv->icon || window->priv->mini_icon));
+ _wnck_read_icon (window->priv->screen,
+ window->priv->xwindow,
+ window->priv->mini_icon_cache,
+ &window->priv->mini_icon,
+ _wnck_get_default_mini_icon_size ());
}
void
-_wnck_window_load_icons (WnckWindow *window)
+_wnck_window_icon_changed (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
- */
+ g_clear_object (&window->priv->icon);
+ g_clear_object (&window->priv->mini_icon);
+
+ window->priv->need_emit_icon_changed = TRUE;
+
+ queue_update (window);
}
/**
@@ -2188,7 +2174,7 @@ wnck_window_get_icon (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
- _wnck_window_load_icons (window);
+ ensure_icon (window);
return window->priv->icon;
}
@@ -2210,7 +2196,7 @@ wnck_window_get_mini_icon (WnckWindow *window)
{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
- _wnck_window_load_icons (window);
+ ensure_mini_icon (window);
return window->priv->mini_icon;
}
@@ -2625,7 +2611,8 @@ _wnck_window_process_property_notify (WnckWindow *window,
xevent->xproperty.atom);
_wnck_icon_cache_property_changed (window->priv->mini_icon_cache,
xevent->xproperty.atom);
- queue_update (window);
+
+ _wnck_window_icon_changed (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("WM_HINTS"))
@@ -3315,8 +3302,6 @@ force_update_now (WnckWindow *window)
update_frame_extents (window); /* emits signals */
update_role (window); /* emits signals */
- get_icons (window);
-
new_state = COMPRESS_STATE (window);
if (old_state != new_state)
@@ -3339,7 +3324,6 @@ force_update_now (WnckWindow *window)
emit_type_changed (window);
}
-
static gboolean
update_idle (gpointer data)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]