[libwnck/wip/muktupavels/icons: 7/21] icon-cache: store xwindow in struct
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libwnck/wip/muktupavels/icons: 7/21] icon-cache: store xwindow in struct
- Date: Fri, 16 Sep 2022 12:25:54 +0000 (UTC)
commit 1cbd4424b2ed26c61d0bbf75d4b5194db604e228
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Mar 14 14:22:43 2022 +0200
icon-cache: store xwindow in struct
Icon cache is always used with same xwindow.
libwnck/application.c | 10 ++++------
libwnck/window.c | 7 +++----
libwnck/wnck-icon-cache-private.h | 3 +--
libwnck/wnck-icon-cache.c | 11 +++++++----
4 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/libwnck/application.c b/libwnck/application.c
index abf4cbf4..472145c8 100644
--- a/libwnck/application.c
+++ b/libwnck/application.c
@@ -98,9 +98,6 @@ static void
wnck_application_init (WnckApplication *application)
{
application->priv = wnck_application_get_instance_private (application);
-
- application->priv->icon_cache = _wnck_icon_cache_new ();
- _wnck_icon_cache_set_want_fallback (application->priv->icon_cache, FALSE);
}
static void
@@ -167,8 +164,7 @@ wnck_application_finalize (GObject *object)
g_object_unref (G_OBJECT (application->priv->mini_icon));
application->priv->mini_icon = NULL;
- _wnck_icon_cache_free (application->priv->icon_cache);
- application->priv->icon_cache = NULL;
+ g_clear_pointer (&application->priv->icon_cache, _wnck_icon_cache_free);
g_free (application->priv->startup_id);
application->priv->startup_id = NULL;
@@ -327,7 +323,6 @@ get_icons (WnckApplication *app)
mini_size = _wnck_handle_get_default_mini_icon_size (handle);
if (_wnck_read_icons (app->priv->screen,
- app->priv->xwindow,
app->priv->icon_cache,
&icon,
normal_size,
@@ -523,6 +518,9 @@ _wnck_application_create (Window xwindow,
application->priv->xwindow = xwindow;
application->priv->screen = screen;
+ application->priv->icon_cache = _wnck_icon_cache_new (xwindow);
+ _wnck_icon_cache_set_want_fallback (application->priv->icon_cache, FALSE);
+
application->priv->name = _wnck_get_name (xscreen, xwindow);
if (application->priv->name == NULL)
diff --git a/libwnck/window.c b/libwnck/window.c
index 79c2cc8b..ce755c82 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -222,7 +222,6 @@ wnck_window_init (WnckWindow *window)
{
window->priv = wnck_window_get_instance_private (window);
- window->priv->icon_cache = _wnck_icon_cache_new ();
window->priv->icon_geometry.width = -1; /* invalid cached value */
window->priv->workspace = -1;
window->priv->sort_order = G_MAXINT;
@@ -419,8 +418,7 @@ wnck_window_finalize (GObject *object)
g_object_unref (G_OBJECT (window->priv->mini_icon));
window->priv->mini_icon = NULL;
- _wnck_icon_cache_free (window->priv->icon_cache);
- window->priv->icon_cache = NULL;
+ g_clear_pointer (&window->priv->icon_cache, _wnck_icon_cache_free);
g_free (window->priv->startup_id);
window->priv->startup_id = NULL;
@@ -488,6 +486,8 @@ _wnck_window_create (Window xwindow,
window->priv->xwindow = xwindow;
window->priv->screen = screen;
+ window->priv->icon_cache = _wnck_icon_cache_new (xwindow);
+
_wnck_handle_insert_window (handle, &window->priv->xwindow, window);
/* Handle now owns one ref, caller gets none */
@@ -2123,7 +2123,6 @@ get_icons (WnckWindow *window)
mini_size = _wnck_handle_get_default_mini_icon_size (handle);
if (_wnck_read_icons (window->priv->screen,
- window->priv->xwindow,
window->priv->icon_cache,
&icon,
normal_size,
diff --git a/libwnck/wnck-icon-cache-private.h b/libwnck/wnck-icon-cache-private.h
index 2a89213e..67eeab8f 100644
--- a/libwnck/wnck-icon-cache-private.h
+++ b/libwnck/wnck-icon-cache-private.h
@@ -29,7 +29,7 @@ G_BEGIN_DECLS
typedef struct _WnckIconCache WnckIconCache;
-WnckIconCache *_wnck_icon_cache_new (void);
+WnckIconCache *_wnck_icon_cache_new (Window xwindow);
void _wnck_icon_cache_free (WnckIconCache *icon_cache);
void _wnck_icon_cache_property_changed (WnckIconCache *icon_cache,
Atom atom);
@@ -39,7 +39,6 @@ void _wnck_icon_cache_set_want_fallback (WnckIconCache *icon_cache
gboolean _wnck_icon_cache_get_is_fallback (WnckIconCache *icon_cache);
gboolean _wnck_read_icons (WnckScreen *screen,
- Window xwindow,
WnckIconCache *icon_cache,
GdkPixbuf **iconp,
int ideal_size,
diff --git a/libwnck/wnck-icon-cache.c b/libwnck/wnck-icon-cache.c
index 6a89ff08..627223e9 100644
--- a/libwnck/wnck-icon-cache.c
+++ b/libwnck/wnck-icon-cache.c
@@ -41,6 +41,8 @@ typedef enum
struct _WnckIconCache
{
+ Window xwindow;
+
IconOrigin origin;
Pixmap prev_pixmap;
Pixmap prev_mask;
@@ -454,12 +456,14 @@ scaled_from_pixdata (guchar *pixdata,
}
WnckIconCache*
-_wnck_icon_cache_new (void)
+_wnck_icon_cache_new (Window xwindow)
{
WnckIconCache *icon_cache;
icon_cache = g_slice_new0 (WnckIconCache);
+ icon_cache->xwindow = xwindow;
+
icon_cache->origin = USING_NO_ICON;
icon_cache->prev_pixmap = None;
icon_cache->icon = NULL;
@@ -525,7 +529,6 @@ _wnck_icon_cache_get_is_fallback (WnckIconCache *icon_cache)
gboolean
_wnck_read_icons (WnckScreen *screen,
- Window xwindow,
WnckIconCache *icon_cache,
GdkPixbuf **iconp,
int ideal_size,
@@ -572,7 +575,7 @@ _wnck_read_icons (WnckScreen *screen,
{
icon_cache->net_wm_icon_dirty = FALSE;
- if (read_rgb_icon (xscreen, xwindow,
+ if (read_rgb_icon (xscreen, icon_cache->xwindow,
ideal_size,
ideal_mini_size,
&w, &h, &pixdata,
@@ -596,7 +599,7 @@ _wnck_read_icons (WnckScreen *screen,
icon_cache->wm_hints_dirty = FALSE;
_wnck_error_trap_push (display);
- hints = XGetWMHints (display, xwindow);
+ hints = XGetWMHints (display, icon_cache->xwindow);
_wnck_error_trap_pop (display);
pixmap = None;
mask = None;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]