[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: Sun, 19 Dec 2021 22:20:13 +0000 (UTC)
commit c84fadf6564f31d67befc290fd2108499883c8fc
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 | 88 ++++++++++++++++++++-----------------------------------
3 files changed, 33 insertions(+), 59 deletions(-)
---
diff --git a/libwnck/private.h b/libwnck/private.h
index 01bbd89..cbd41b5 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_icons_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 90dd70b..7695599 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_icons_changed (window);
if (WNCK_IS_APPLICATION (application))
_wnck_application_icons_changed (application);
diff --git a/libwnck/window.c b/libwnck/window.c
index 25c56a5..5d83844 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -161,7 +161,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;
@@ -189,7 +188,6 @@ static void emit_state_changed (WnckWindow *window,
WnckWindowState changed_mask,
WnckWindowState new_state);
static void emit_workspace_changed (WnckWindow *window);
-static void emit_icon_changed (WnckWindow *window);
static void emit_actions_changed (WnckWindow *window,
WnckWindowActions changed_mask,
WnckWindowActions new_actions);
@@ -555,7 +553,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;
@@ -2114,52 +2111,44 @@ wnck_window_transient_is_most_recently_activated (WnckWindow *window)
}
static void
-get_icons (WnckWindow *window)
+ensure_icon (WnckWindow *window)
{
- GdkPixbuf *icon;
- GdkPixbuf *mini_icon;
- gsize normal_size;
- gsize mini_size;
-
- icon = NULL;
- mini_icon = NULL;
- normal_size = _wnck_get_default_icon_size ();
- mini_size = _wnck_get_default_mini_icon_size ();
-
- if (_wnck_read_icons (window->priv->screen,
- window->priv->xwindow,
- window->priv->icon_cache,
- &icon,
- normal_size,
- &mini_icon,
- mini_size))
- {
- window->priv->need_emit_icon_changed = TRUE;
-
- if (window->priv->icon)
- g_object_unref (G_OBJECT (window->priv->icon));
+ if (window->priv->icon != NULL)
+ return;
- if (window->priv->mini_icon)
- g_object_unref (G_OBJECT (window->priv->mini_icon));
+ _wnck_read_icons (window->priv->screen,
+ window->priv->xwindow,
+ window->priv->icon_cache,
+ &window->priv->icon,
+ _wnck_get_default_icon_size (),
+ NULL,
+ 0);
+}
- window->priv->icon = icon;
- 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_icons (window->priv->screen,
+ window->priv->xwindow,
+ window->priv->icon_cache,
+ NULL,
+ 0,
+ &window->priv->mini_icon,
+ _wnck_get_default_mini_icon_size ());
}
void
-_wnck_window_load_icons (WnckWindow *window)
+_wnck_window_icons_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);
+
+ g_signal_emit (window, signals[ICON_CHANGED], 0);
}
/**
@@ -2179,7 +2168,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;
}
@@ -2201,7 +2190,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;
}
@@ -2614,7 +2603,7 @@ _wnck_window_process_property_notify (WnckWindow *window,
{
_wnck_icon_cache_property_changed (window->priv->icon_cache,
xevent->xproperty.atom);
- queue_update (window);
+ _wnck_window_icons_changed (window);
}
else if (xevent->xproperty.atom ==
_wnck_atom_get ("WM_HINTS"))
@@ -3300,8 +3289,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)
@@ -3311,9 +3298,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);
@@ -3324,7 +3308,6 @@ force_update_now (WnckWindow *window)
emit_type_changed (window);
}
-
static gboolean
update_idle (gpointer data)
{
@@ -3381,15 +3364,6 @@ emit_workspace_changed (WnckWindow *window)
0);
}
-static void
-emit_icon_changed (WnckWindow *window)
-{
- window->priv->need_emit_icon_changed = FALSE;
- g_signal_emit (G_OBJECT (window),
- signals[ICON_CHANGED],
- 0);
-}
-
static void
emit_class_changed (WnckWindow *window)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]